From 91e9433fa354c000cc4cd3b2f87c78eb22f547ed Mon Sep 17 00:00:00 2001 From: Alecto Irene Perez Date: Tue, 24 Aug 2021 00:10:54 -0600 Subject: [PATCH] Added section on how to do customization with coc.nvim. --- coc.nvim.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/coc.nvim.md b/coc.nvim.md index 4b00866..d012faf 100644 --- a/coc.nvim.md +++ b/coc.nvim.md @@ -101,3 +101,54 @@ nn :call CocLocations('ccls','$ccls/navigate',{'direction nn :call CocLocations('ccls','$ccls/navigate',{'direction':'R'}) nn :call CocLocations('ccls','$ccls/navigate',{'direction':'U'}) ``` + +### Customization with coc.nvim + +Options listed in [Customization](https://github.com/MaskRay/ccls/wiki/Customization) can be passed to CCLS via `initializationOptions` in the Coc configuration file. For example, if to direct ccls to look for `compile_commands.json` in the project `build` directory, you could add an entry for `compilationDatabaseDirectory`, and update `rootPatterns` accordingly. + +```json +{ + "languageserver": { + "ccls": { + "command": "ccls", + "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"], + "rootPatterns": [".ccls-root", "build/compile_commands.json"], + "initializationOptions": { + "cache": { + "directory": ".ccls-cache" + }, + "client": { + "snippetSupport": true + }, + "compilationDatabaseDirectory": "build" + } + } + } +} +``` + +Options like `clang.extraArgs` may be similarly be added using the same syntax as `client.snippetSupport` in the example above. For example, we can support C++20 by default by passing `-std=c++20` as an extra argument to clang: + +```json +{ + "languageserver": { + "ccls": { + "command": "ccls", + "filetypes": ["c", "cpp", "cuda", "objc", "objcpp"], + "rootPatterns": [".ccls-root", "build/compile_commands.json"], + "initializationOptions": { + "cache": { + "directory": ".ccls-cache" + }, + "client": { + "snippetSupport": true + }, + "compilationDatabaseDirectory": "build", + "clang": { + "extraArgs": [ "-std=c++20" ] + } + } + } + } +} +``` \ No newline at end of file