From a54ce118f4816541078159ee031205255cfb899a Mon Sep 17 00:00:00 2001 From: Bruno Carlin Date: Mon, 16 Mar 2020 09:12:13 +0100 Subject: [PATCH] Improve coc.nvim --- nvim/.config/nvim/coc-settings.json | 7 +++++-- vim/.vimrc | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/nvim/.config/nvim/coc-settings.json b/nvim/.config/nvim/coc-settings.json index 842960c..b2e6df1 100644 --- a/nvim/.config/nvim/coc-settings.json +++ b/nvim/.config/nvim/coc-settings.json @@ -1,9 +1,12 @@ { "languageserver": { "golang": { - "command": "gopls", + "command": "/home/bca/.go/bin/gopls", "rootPatterns": ["go.mod", ".vim/", ".git/", ".hg/"], - "filetypes": ["go"] + "filetypes": ["go"], + "initializationOptions": { + "usePlaceholders": true + } }, "bash": { "command": "bash-language-server", diff --git a/vim/.vimrc b/vim/.vimrc index a4d33ad..7db2099 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -219,6 +219,7 @@ nmap lc :lclose autocmd BufNewFile,BufRead *.tmpl set syntax=gohtmltmpl +" Coc mappings nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) @@ -227,8 +228,6 @@ nmap go :CocList outline nnoremap K :call show_documentation() nmap rn (coc-rename) -"inoremap pumvisible() ? "\" : "\" -"inoremap pumvisible() ? "\" : "\" function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) @@ -238,6 +237,28 @@ function! s:show_documentation() endif endfunction +" Use tab for trigger completion with characters ahead and navigate. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to confirm completion, `u` means break undo chain at current +" position. Coc only does snippet and additional edit on confirm. +if has('patch8.1.1068') + " Use `complete_info` if your (Neo)Vim version supports it. + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + imap pumvisible() ? "\" : "\u\" +endif + + nmap :Clap files nmap b :Clap buffers nmap r :Clap grep