Skip to content

Commit 6fa6287

Browse files
committed
Replace UltiSnips with coc-snippets
1 parent d688dca commit 6fa6287

File tree

2 files changed

+53
-71
lines changed

2 files changed

+53
-71
lines changed

.vim/coc-settings.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
{
2+
"suggest.minTriggerInputLength": 4,
23
"clangd.enabled": true,
34
"clangd.path": "/usr/bin/clangd",
4-
"clangd.semanticHighlighting": true,
5-
"clangd.compilationDatabaseCandidates": [ "bld" ]
5+
"clangd.semanticHighlighting": false,
6+
"inlayHint.enable": true,
7+
"clangd.compilationDatabaseCandidates": [ "bld" ],
8+
"languageserver": {
9+
"suricata": {
10+
"command": "suricata-language-server",
11+
"filetypes": ["suricata","hog"]
12+
}
13+
},
14+
"snippets.ultisnips.directories": [
15+
"UltiSnips",
16+
".vim/UltiSnips"
17+
]
618
}
719

.vimrc

Lines changed: 39 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ Plug 'Xuyuanp/nerdtree-git-plugin'
260260
Plug 'majutsushi/tagbar'
261261
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
262262
Plug 'junegunn/fzf.vim'
263-
Plug 'SirVer/ultisnips'
264263
Plug 'gergap/vim-snippets'
265264
" install yarn using `sudo npm install --global yarn`
266-
Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': 'yarn install --frozen-lockfile'}
267-
Plug 'jackguo380/vim-lsp-cxx-highlight'
265+
Plug 'neoclide/coc.nvim', {'branch': 'release'}
266+
"Plug 'neoclide/coc.nvim', {'branch': 'release', 'do': 'yarn install --frozen-lockfile'}
267+
"Plug 'jackguo380/vim-lsp-cxx-highlight'
268268
Plug 'vim-scripts/valgrind.vim'
269269
Plug 'vim-scripts/a.vim'
270270
"Plug 'vim-syntastic/syntastic'
@@ -513,51 +513,36 @@ let g:AutoClosePumvisible = {"ENTER": "<C-Y>", "ESC": "<ESC>"}
513513
" which conflicts with Vim abbreviation
514514
let g:AutoCloseExpandSpace = 0
515515

516-
"====[ UltiSnips plugin ]================================================
517-
let g:UltiSnipsExpandTrigger = "<tab>"
518-
let g:UltiSnipsListSnippets = "<c-tab>"
519-
let g:UltiSnipsJumpForwardTrigger = "<c-j>"
520-
let g:UltiSnipsJumpBackwardTrigger = "<c-k>"
521-
let g:UltiSnipsEditSplit = "horizontal"
522-
let g:UltiSnipsSnippetDirectories = ['~/.vim/UltiSnips', 'UltiSnips']
523-
inoremap <c-x><c-k> <c-x><c-k>
524-
525-
function! g:UltiSnips_Complete()
526-
call UltiSnips#ExpandSnippet()
527-
if g:ulti_expand_res == 0
528-
if pumvisible()
529-
return "\<C-n>"
530-
else
531-
call UltiSnips#JumpForwards()
532-
if g:ulti_jump_forwards_res == 0
533-
return "\<TAB>"
534-
endif
535-
endif
536-
endif
537-
return ""
538-
endfunction
516+
"====[ coc-snippets plugin ]================================================
517+
" Use <C-l> for trigger snippet expand.
518+
imap <C-l> <Plug>(coc-snippets-expand)
539519
540-
function! g:UltiSnips_Reverse()
541-
call UltiSnips#JumpBackwards()
542-
if g:ulti_jump_backwards_res == 0
543-
return "\<C-P>"
544-
endif
520+
" Use <C-j> for select text for visual placeholder of snippet.
521+
vmap <C-j> <Plug>(coc-snippets-select)
545522
546-
return ""
547-
endfunction
523+
" Use <C-j> for jump to next placeholder, it's default of coc.nvim
524+
let g:coc_snippet_next = '<c-j>'
548525

526+
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim
527+
let g:coc_snippet_prev = '<c-k>'
549528

550-
"if !exists("g:UltiSnipsJumpForwardTrigger")
551-
" let g:UltiSnipsJumpForwardTrigger = "<tab>"
552-
"endif
553-
"
554-
"if !exists("g:UltiSnipsJumpBackwardTrigger")
555-
" let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
556-
"endif
557-
"
558-
"au InsertEnter * exec "inoremap <silent> ".g:UltiSnipsExpandTrigger." <C-R>=g:UltiSnips_Complete()<cr>"
559-
"au InsertEnter * exec "inoremap <silent> ".g:UltiSnipsJumpBackwardTrigger." <C-R>=g:UltiSnips_Reverse()<cr>"
529+
" Use <C-j> for both expand and jump (make expand higher priority.)
530+
imap <C-j> <Plug>(coc-snippets-expand-jump)
531+
532+
" Use <leader>x for convert visual selected code to snippet
533+
xmap <leader>x <Plug>(coc-convert-snippet)
534+
inoremap <silent><expr> <TAB>
535+
\ coc#pum#visible() ? coc#_select_confirm() :
536+
\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" :
537+
\ CheckBackspace() ? "\<TAB>" :
538+
\ coc#refresh()
560539
540+
function! CheckBackspace() abort
541+
let col = col('.') - 1
542+
return !col || getline('.')[col - 1] =~# '\s'
543+
endfunction
544+
545+
let g:coc_snippet_next = '<tab>'
561546

562547
"====[ resize split windows ]============================================
563548
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
@@ -651,27 +636,17 @@ set nowritebackup
651636
set updatetime=300
652637
" Don't pass messages to |ins-completion-menu|.
653638
set shortmess+=c
654-
" Always show the signcolumn, otherwise it would shift the text each time
655-
" diagnostics appear/become resolved.
656-
if has("nvim-0.5.0") || has("patch-8.1.1564")
657-
" Recently vim can merge signcolumn and number column into one
658-
set signcolumn=number
659-
else
660-
set signcolumn=yes
661-
endif
639+
662640
" Use tab for trigger completion with characters ahead and navigate.
663641
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
664642
" other plugin before putting this into your config.
665-
function! s:check_back_space() abort
666-
let col = col('.') - 1
667-
return !col || getline('.')[col - 1] =~# '\s'
668-
endfunction
643+
"inoremap <silent><expr> <TAB> pumvisible() ? "\<C-n>" : "\<Tab>"
644+
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
669645

670-
inoremap <silent><expr> <TAB>
671-
\ pumvisible() ? "\<C-n>" :
672-
\ <SID>check_back_space() ? "\<TAB>" :
673-
\ coc#refresh()
674-
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
646+
" Make <CR> to accept selected completion item or notify coc.nvim to format
647+
" <C-g>u breaks current undo, please make your own choice.
648+
"inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
649+
" \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
675650

676651
" Use <c-space> to trigger completion.
677652
if has('nvim')
@@ -680,11 +655,6 @@ else
680655
inoremap <silent><expr> <c-@> coc#refresh()
681656
endif
682657

683-
" Make <CR> to accept selected completion item or notify coc.nvim to format
684-
" <C-g>u breaks current undo, please make your own choice.
685-
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
686-
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
687-
688658
" Use `[g` and `]g` to navigate diagnostics
689659
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
690660
nmap <silent> [g <Plug>(coc-diagnostic-prev)
@@ -710,10 +680,10 @@ function! s:show_documentation()
710680
endfunction
711681

712682
" Highlight the symbol and its references when holding the cursor.
713-
augroup coc_highlight
714-
autocmd!
715-
autocmd CursorHold * silent call CocActionAsync('highlight')
716-
augroup END
683+
"augroup coc_highlight
684+
" autocmd!
685+
" autocmd CursorHold * silent call CocActionAsync('highlight')
686+
"augroup END
717687

718688
" Symbol renaming.
719689
nmap <leader>rn <Plug>(coc-rename)

0 commit comments

Comments
 (0)