9

实用刷题、线上赛C++配置(VSCode + ccls)

 3 years ago
source link: https://h-cheung.gitlab.io/post/%E5%AE%9E%E7%94%A8%E5%88%B7%E9%A2%98%E7%BA%BF%E4%B8%8A%E8%B5%9Bc++%E9%85%8D%E7%BD%AEvscode-+-ccls/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

写不动题了,来写篇小文章放松一下,记录一下自己的配置,也供读者参考。

注:运行环境为Arch Linux

需要安装的包

  • gcc 如果不用pbds等,可以直接用clang编译,和gcc的差异基本上只有少量UB,__int128也是支持的,不过Linux基本上不能不装gcc
  • llvm(clang) 除了作为一个编译器之外,还提供强大的自动补全、代码检查、代码格式化等相关工具,clion、qtcreator等都依赖它
  • ccls 基于clang的LSP(language server protocol),完成度比clang的类似组件clangd更高。注意:更新clang后需要用新版本的clang重新编译ccls,否则可能会出现各种问题(包括完全挂掉)
  • visual-studio-code 体验不错,插件生态非常好的编辑器
  • ccls 核心插件,提供语法检查、补全、高亮、变量重命名、code lens等等
  • clang-format ccls的提供的格式化偶尔会抽风,单独用这个比较稳定
  • Code Runner 一键编译运行
  • easy-snippet 非常方便的snippet管理工具,可以用来存板子
  • CodeLLDB 可选,整合lldb,偏好gdb的用户可以不装
  • Vim 可选,vim模拟
  • ICIE 拉取codeforces上面的题目和样例,并根据通用模板生成文件,并且可以一键测试,通过后直接submit,现在已经支持直接拉取正在进行或即将进行的比赛,除了hack和看榜之外可以不用打开浏览器
  • Better Online Judge 和前者类似,用于vjudge上的比赛,功能较弱,拉取不了样例
  • vscode-clangd 备用,比如在睡前更新clang后忘记重编译ccls,第二天开始打了发现ccls炸了,可以把clangd拉出来救急(亲身经历)。目前它的功能略弱于ccls,但毕竟是llvm官方的组件,不排除以后会赶超

注:如果使用第三方调试工具的话,不用安装微软官方的cpptools插件

建议修改的设置

ccls

可以调整自动补全的case sensitivity(大小写敏感)和detailed label(补全时显示标准库函数的详细功能)。高亮部分可以根据自己喜好调整,建议打开type aliases等

Code Runner

可以自己改运行命令,以下供参考:

"c": "cd $dir && gcc -g $fileName -o /tmp/ctest && time /tmp/ctest",
"cpp": "cd $dir && g++ -g $fileName -o /tmp/cpptest && time /tmp/cpptest",

Vim

VSCode的vim插件功能挺多的,尤其是支持neovim做后端,以下设置供参考

"vim.easymotion": true,
"vim.enableNeovim": true,
"vim.sneak": true,
"vim.sneakUseIgnorecaseAndSmartcase": true,
"vim.statusBarColorControl": true,
"vim.autoSwitchInputMethod.enable": true,
"vim.autoSwitchInputMethod.defaultIM": "1",
"vim.autoSwitchInputMethod.obtainIMCmd": "/usr/bin/fcitx-remote",
"vim.autoSwitchInputMethod.switchIMCmd": "/usr/bin/fcitx-remote -t {im}",
"vim.foldfix": true,
"vim.neovimPath": "/usr/bin/nvim",
"vim.useSystemClipboard": true,

ICIE

"icie.template.list"下写你的通用模板的文件路径

Better Online Judge

这个插件的通用模板是硬编码的,直接修改~/.vscode/extensions/yiyangxu.better-oj-<版本号>/out/utils/template.js


Recommend

  • 29
    • studygolang.com 4 years ago
    • Cache

    vscode 实用配置

    install 快捷键 语言配置 插件 settings.json install Windows

  • 9

    Real World CTF 2018 ccls-fringe命题报告 上周日给Real World CTF 2018出了一道forensics题ccls-fringe,向解出此题的31支队伍表达祝贺。 上一次出题已是2016年,一直没有人教我pwn、reverse、we...

  • 8
    • blogs.igalia.com 4 years ago
    • Cache

    Notes on using Emacs (LSP/ccls) for WebKit

    Notes on using Emacs (LSP/ccls) for WebKit I used to regard myself as an austere programmer in terms of tooling: Emacs —with a plain configuration— and grep. This approach forces you to understand all the elements involved in...

  • 6

    点上方蓝字关注公众号「前端从进阶到入院」 精选原创好文助你进入大厂 海 阔凭鱼跃,天高任鸟飞。 Hey 你好! 我是秦爱德。 😄 平平无奇上班摸鱼,甚至想着如何带薪拉屎?不不不,今天我们...

  • 10
    • maskray.me 3 years ago
    • Cache

    C++ language server ccls一周年

    C++ language server ccls一周年 2018年4月1日我写了ccls: a fork of the C++ language server cquery,宣告ccls诞生。如今...

  • 10

    $ccls/navigate和index.multiVersion 忙碌的Labor Day长周末。Growth hacking(希望Hudson River Trading用上无进展,和前clangd、Eclipse CDT开发者交谈、

  • 9
    • maskray.me 3 years ago
    • Cache

    ccls 0.20181225 release

    ccls 0.20181225 release 圣诞发布新版https://github.com/MaskRay/ccls/releases/tag/0.20181225 workspace...

  • 9

    VSCode实用配置及常用快捷键推荐安装的插件:Code RunnerGit GraphGo for Visual Studio CodeMaterail Icon Theme通用配置:

  • 21

    emacs-ccls emacs-ccls is a client for ccls, a C/C++/Objective-C language server supporting multi-million line C++ code-bases, powered by libclang. It leverages

  • 9

    工欲善其事,必先利其器。掌握Go的基础语法还不够,还需要勤加练习,修习“外功”,才能达到出奇制胜的效果。 在大致了解Go语言的基本语法后,我就迫不得已地想使用这门语言。可是我发现编程思路不是问题,很大的问题是“手慢”,不熟...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK