mirror of
https://github.com/MaskRay/ccls.git
synced 2024-11-28 02:21:57 +00:00
add screencast to languageclient-neovim
parent
69a3c1ea3b
commit
0931de3b3a
@ -2,28 +2,13 @@
|
||||
2. Install [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim)
|
||||
You may use the plugin manager [vim-plug](https://github.com/junegunn/vim-plug#unix-1)
|
||||
|
||||
### /home/YOUR_USERNAME/.config/nvim/init.vim
|
||||
```vim
|
||||
" LanguageClient-neovim
|
||||
call plug#begin('~/.local/share/nvim/plugged')
|
||||
Plug 'autozimu/LanguageClient-neovim', {
|
||||
\ 'branch': 'next',
|
||||
\ 'do': 'bash install.sh',
|
||||
\ }
|
||||
LanguageClient-neovim
|
||||
|
||||
" Multi-entry selection UI. FZF
|
||||
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
|
||||
Plug 'junegunn/fzf.vim'
|
||||
|
||||
call plug#end()
|
||||
```
|
||||
|
||||
### bash
|
||||
```bash
|
||||
nvim +PlugInstall +UpdateRemotePlugins +qa
|
||||
```
|
||||
|
||||
`~/.config/nvim/settings.json`
|
||||
`~/.config/nvim/settings.json` (optional, by default it creates cache directory `.ccls-cache` in the project root)
|
||||
```json
|
||||
{
|
||||
"initializationOptions": {
|
||||
@ -35,40 +20,47 @@ nvim +PlugInstall +UpdateRemotePlugins +qa
|
||||
`~/.config/nvim/init.vim`
|
||||
```vim
|
||||
let g:LanguageClient_serverCommands = {
|
||||
\ 'cpp': ['ccls', '--log-file=/tmp/cq.log'],
|
||||
\ 'c': ['ccls', '--log-file=/tmp/cq.log'],
|
||||
\ 'cpp': ['ccls', '--log-file=/tmp/cc.log'],
|
||||
\ 'c': ['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'
|
||||
set completefunc=LanguageClient#complete
|
||||
set formatexpr=LanguageClient_textDocument_rangeFormatting()
|
||||
|
||||
nnoremap <silent> gh :call LanguageClient_textDocument_hover()<CR>
|
||||
nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>
|
||||
nnoremap <silent> gr :call LanguageClient_textDocument_references()<CR>
|
||||
nnoremap <silent> gs :call LanguageClient_textDocument_documentSymbol()<CR>
|
||||
nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()<CR>
|
||||
```
|
||||
|
||||
### In your Project Directory NEED compile_commands.json
|
||||
Make sure you have `.ccls` or [[compile_commands.json]] in your project root. Open a file in the project, run `:LanguageClientStart`.
|
||||
|
||||
[[compile_commands.json]]
|
||||
These features will work out-of-the-box.
|
||||
|
||||
```bash
|
||||
bear make #If you like Makefile
|
||||
```vim
|
||||
nn <silent> <M-j> :call LanguageClient#textDocument_definition()<cr>
|
||||
nn <silent> <C-,> :call LanguageClient#textDocument_references({'includeDeclaration': v:false})<cr>
|
||||
nn <silent> K :call LanguageClient#textDocument_hover()<cr>
|
||||
```
|
||||
|
||||
or
|
||||
### `textDocument/documentHighlight`
|
||||
|
||||
```bash
|
||||
bear gcc x.c -o x
|
||||
```vim
|
||||
augroup LanguageClient_config
|
||||
au!
|
||||
au BufEnter * let b:Plugin_LanguageClient_started = 0
|
||||
au User LanguageClientStarted setl signcolumn=yes
|
||||
au User LanguageClientStarted let b:Plugin_LanguageClient_started = 1
|
||||
au User LanguageClientStopped setl signcolumn=auto
|
||||
au User LanguageClientStopped let b:Plugin_LanguageClient_stopped = 0
|
||||
au CursorMoved * if b:Plugin_LanguageClient_started | sil call LanguageClient#textDocument_documentHighlight() | endif
|
||||
augroup END
|
||||
```
|
||||
|
||||
or any other
|
||||
|
||||
### `$ccls/navigate`
|
||||
|
||||
Semantic navigation. Roughly,
|
||||
|
||||
"D" => first child declaration
|
||||
"L" => previous declaration
|
||||
"R" => next declaration
|
||||
"U" => parent declaration
|
||||
|
||||
```vim
|
||||
nn <silent> xh :call LanguageClient#findLocations({'method':'$ccls/navigate','direction':'L'})<cr>
|
||||
nn <silent> xj :call LanguageClient#findLocations({'method':'$ccls/navigate','direction':'D'})<cr>
|
||||
@ -76,6 +68,8 @@ nn <silent> xk :call LanguageClient#findLocations({'method':'$ccls/navigate','di
|
||||
nn <silent> xl :call LanguageClient#findLocations({'method':'$ccls/navigate','direction':'R'})<cr>
|
||||
```
|
||||
|
||||
![](https://ptpb.pw/89Y2.gif)
|
||||
|
||||
### Custom cross references
|
||||
|
||||
```vim
|
||||
|
Loading…
Reference in New Issue
Block a user