Skip to content

Latest commit

 

History

History
45 lines (43 loc) · 1.67 KB

vim.md

File metadata and controls

45 lines (43 loc) · 1.67 KB

Development using Vim

  1. Configure your [Neo]Vim to support Language Server Protocol -- I recommend (early 2020) coc.nvim.

  2. Install ccls on your system.

  3. Configure your LSP plugin in Vim to use ccls. In case of coc.nvim, the configuration looks as follows:

    "languageserver": {
        "ccls": {
            "command": "ccls",
            "filetypes": [
                "c",
                "cpp"
            ],
            "settings": {},
            "rootPatterns": [
                ".ccls",
                "compile_commands.json",
                ".vim/",
                ".git/",
                ".hg/"
            ],
            "initializationOptions": {
                "cache": {
                    "directory": "/tmp/ccls"
                },
                "highlight": {
                    "lsRanges": true
                }
            }
  4. Create a build folder and build the project using cmake:

    $ mkdir build-vim
    $ cd build-vim
    $ cmake .. \
        -G Ninja \
        -DCMAKE_TOOLCHAIN_FILE=../cmake/GccArmNoneEabi.cmake \
        -DPRINTER=MINI ... and other cmake flags
    $ ninja
  5. The last step is locating a compile_commands.json file (which was produced as part of the build) for ccls. By default, ccls searches in project's root directory, but ninja produces it in the build folder. There are two options:

    • Update ccls config to let ccls know, that it should search for it in the build-vim subfolder, or
    • make a symbolic link in project's root directory: ln -s build-vim/compile_commands.json.
  6. Get to work! 💪