From 3cdf79b663b9242c2af9947673bdf5c5c501b394 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 10 Oct 2018 22:04:18 -0700 Subject: [PATCH] LanguageClient-neovim: add formatexpr ; hasSnippetSupport --- LanguageClient-neovim.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/LanguageClient-neovim.md b/LanguageClient-neovim.md index 2a5706a..d0a541f 100644 --- a/LanguageClient-neovim.md +++ b/LanguageClient-neovim.md @@ -20,12 +20,16 @@ nvim +PlugInstall +UpdateRemotePlugins +qa `~/.config/nvim/init.vim` ```vim let g:LanguageClient_serverCommands = { - \ 'cpp': ['ccls', '--log-file=/tmp/cc.log'], \ 'c': ['ccls', '--log-file=/tmp/cc.log'], + \ 'cpp': ['ccls', '--log-file=/tmp/cc.log'], + \ 'cuda': ['ccls', '--log-file=/tmp/cc.log'], + \ 'objc': ['ccls', '--log-file=/tmp/cc.log'], \ } let g:LanguageClient_loadSettings = 1 " Use an absolute configuration path if you want system-wide settings let g:LanguageClient_settingsPath = '/home/YOUR_USERNAME/.config/nvim/settings.json' +" https://github.com/autozimu/LanguageClient-neovim/issues/379 LSP snippet is not supported +let g:LanguageClient_hasSnippetSupport = 0 ``` Make sure you have `.ccls` or [[compile_commands.json]] in your project root. Open a file in the project, run `:LanguageClientStart`. @@ -119,3 +123,14 @@ nn xx x ![$ccls/member](https://ptpb.pw/V8WR.jpg) There are also hierarchical views of `$ccls/call` `$ccls/inheritance` `$ccls/member` (see the Emacs page) but they have not been implemented by a Vim plugin. + +### Formatting + +```vim +fu! C_init() + setl formatexpr=LanguageClient#textDocument_rangeFormatting() +endf +au FileType c,cpp,cuda,objc :call C_init() +``` + +In visual mode, `=` will invoke `textDocument/rangeFormatting`, which is a replacement of the `clang-format` command (both of them use the clangFormat library).