LanguageClient-neovim: add formatexpr ; hasSnippetSupport

Fangrui Song 2018-10-10 22:04:18 -07:00
parent d014f5d2a0
commit 3cdf79b663

@ -20,12 +20,16 @@ nvim +PlugInstall +UpdateRemotePlugins +qa
`~/.config/nvim/init.vim` `~/.config/nvim/init.vim`
```vim ```vim
let g:LanguageClient_serverCommands = { let g:LanguageClient_serverCommands = {
\ 'cpp': ['ccls', '--log-file=/tmp/cc.log'],
\ 'c': ['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_loadSettings = 1 " Use an absolute configuration path if you want system-wide settings
let g:LanguageClient_settingsPath = '/home/YOUR_USERNAME/.config/nvim/settings.json' 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`. 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) ![$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. 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).