История изменений
Исправление
pavlick,
(текущая версия)
:
Я тебе свою конфигурацию описываю, если что, то по ходу импровизируй.
- Nvim
- Менеджер вим плагинов https://github.com/junegunn/vim-plug
- Ставишь Node.js, ставил с репозитория
- конфиги
-------------------~/.config/nvim/coc-settings.json
{
"signature.maxWindowHeight": 20,
"clangd.semanticHighlighting": true
}
-------------------~/.config/nvim/init.vim
call plug#begin(stdpath('data') . '/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'jackguo380/vim-lsp-cxx-highlight'
call plug#end()
function CandCPP_hook()
source ~/.config/nvim/coc.nvim_vimrc
endfunction
augroup Mode_hooks_group
autocmd!
autocmd FileType c call CandCPP_hook()
autocmd FileType cpp call CandCPP_hook()
augroup End
-------------------~/.config/nvim/coc.nvim_vimrc
" if hidden is not set, TextEdit might fail.
setlocal hidden
" Some servers have issues with backup files, see #649
setlocal nobackup
setlocal nowritebackup
" Better display for messages
"set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
setlocal updatetime=300
" don't give |ins-completion-menu| messages.
setlocal shortmess+=c
" always show signcolumns
"setlocal signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <buffer> <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <buffer> <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <buffer> <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <buffer> <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[g` and `]g` to navigate diagnostics
nmap <buffer> <silent> [g <Plug>(coc-diagnostic-prev)
nmap <buffer> <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <buffer> <silent> gd <Plug>(coc-definition)
nmap <buffer> <silent> gy <Plug>(coc-type-definition)
nmap <buffer> <silent> gi <Plug>(coc-implementation)
nmap <buffer> <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window
nnoremap <buffer> <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <buffer> <leader>rn <Plug>(coc-rename)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Using CocList
" Show all diagnostics
nnoremap <buffer> <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <buffer> <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <buffer> <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <buffer> <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <buffer> <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <buffer> <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <buffer> <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <buffer> <silent> <space>p :<C-u>CocListResume<CR>
- Из вим деалешь :PlugInstall, :CocInstall coc-clangd
- compile_commands.json генерю этим https://github.com/rizsotto/Bear (если у тебя обычные makefile, cmake сам умеет). Можно просто кидать в корень compile_flags.txt
- Смотри страницы по этим плагинам на гите, там много инфы.
- Сочетания клавиш смотри в coc.nvim_vimrc. Лучше вообще возьми свежую типовую заготовку со страницы Coc’а и допливай под себя, я там кучу всего поудалял, может чего нужное было.
ЗЫ: как же нудобна это автоправка сообщений, пишешь одно, а показывает другое.
Исходная версия
pavlick,
:
Я тебе свою конфигурацию описываю, если что, то по ходу импровизируй.
- Nvim
- Менеджер вим плагинов https://github.com/junegunn/vim-plug
- Ставишь Node.js, ставил с репозитория
- конфиги
-------------------~/.config/nvim/coc-settings.json
{
"signature.maxWindowHeight": 20,
"clangd.semanticHighlighting": true
}
-------------------~/.config/nvim/init.vim
call plug#begin(stdpath('data') . '/plugged')
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'jackguo380/vim-lsp-cxx-highlight'
call plug#end()
function CandCPP_hook()
source ~/.config/nvim/coc.nvim_vimrc
endfunction
augroup Mode_hooks_group
autocmd!
autocmd FileType c call CandCPP_hook()
autocmd FileType cpp call CandCPP_hook()
augroup End
-------------------~/.config/nvim/coc.nvim_vimrc
" if hidden is not set, TextEdit might fail.
setlocal hidden
" Some servers have issues with backup files, see #649
setlocal nobackup
setlocal nowritebackup
" Better display for messages
"set cmdheight=2
" You will have bad experience for diagnostic messages when it's default 4000.
setlocal updatetime=300
" don't give |ins-completion-menu| messages.
setlocal shortmess+=c
" always show signcolumns
"setlocal signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <buffer> <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <buffer> <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <buffer> <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm.
inoremap <buffer> <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Use `[g` and `]g` to navigate diagnostics
nmap <buffer> <silent> [g <Plug>(coc-diagnostic-prev)
nmap <buffer> <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <buffer> <silent> gd <Plug>(coc-definition)
nmap <buffer> <silent> gy <Plug>(coc-type-definition)
nmap <buffer> <silent> gi <Plug>(coc-implementation)
nmap <buffer> <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window
nnoremap <buffer> <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for rename current word
nmap <buffer> <leader>rn <Plug>(coc-rename)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Using CocList
" Show all diagnostics
nnoremap <buffer> <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <buffer> <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <buffer> <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <buffer> <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <buffer> <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <buffer> <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <buffer> <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <buffer> <silent> <space>p :<C-u>CocListResume<CR>
- Из вим деалешь :PlugInstall :CocInstall coc-clangd
- compile_commands.json генерю этим https://github.com/rizsotto/Bear (если у тебя обычные makefile, cmake сам умеет). Можно просто кидать в корень compile_flags.txt
- Смотри страницы по этим плагинам на гите, там много инфы.
- Сочетания клавиш смотри в coc.nvim_vimrc. Лучше вообще возьми свежую типовую заготовку со страницы Coc’а и допливай под себя, я там кучу всего поудалял, может чего нужное было.