mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-24 00:25:07 +00:00
LanguageClient-neovim: add formatexpr ; hasSnippetSupport
parent
d014f5d2a0
commit
3cdf79b663
@ -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).
|
||||
|
Loading…
Reference in New Issue
Block a user