Skip to content

Commit

Permalink
Add coc - completion framework support
Browse files Browse the repository at this point in the history
  • Loading branch information
Kien Nguyen committed Oct 15, 2019
1 parent 9661eae commit 8fea2ec
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Using NeoVim as an Python+Go IDE
# Using NeoVim as an Python+Golang IDE

[Neovim](https://neovim.io/) is a pretty cool successor to Vim, focusing on compatibility while adding asynchronous plugin functionality and trying to clean up the code base. Having been fed up at various times with both Sublime Text (2 and 3) and Atom, and after realizing how much development I do over SSH, it seemed reasonable to check out using vim (or nvim, in this case) as my IDE. The advantages essentially boil down to:

Expand Down Expand Up @@ -34,7 +34,9 @@ Complete instructions to Neovim as your IDE - Inspired by [Jarol Rodriguez's vim
$ sudo -H pip3 install powerline-status
```

4. Clone init.vim - neovim configuration file to specific path, in this case is `~/.config/nvim/init.vim`:
4. To use [coc](https://github.com/neoclide/coc.nvim), you have to configure the [Lauguage servers](https://github.com/neoclide/coc.nvim/wiki/Language-servers) also.

5. Clone init.vim - neovim configuration file to specific path, in this case is `~/.config/nvim/init.vim`:

```
$ cd ~/.config/nvim/
Expand Down
69 changes: 69 additions & 0 deletions init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Plug 'majutsushi/tagbar' " Class/module browser
Plug 'bling/vim-bufferline' " Buffer-line vim - show list of buffers in command bar
Plug 'junegunn/limelight.vim' " Hyperfocus-writing in Vim
Plug 'brooth/far.vim' " Find and replace
Plug 'neoclide/coc.nvim', {'tag': '*', 'branch': 'release'} "An intellisense engine

"-------------------=== Fancy things ===----------------------------
Plug 'flazz/vim-colorschemes' " Colorschemes
Expand Down Expand Up @@ -396,3 +397,71 @@ if executable('ag')
endif

let g:go_version_warning = 0

" -----
" COC
" -----

" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages
set shortmess+=c
" always show signcolumns
set 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 <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <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 <silent><expr> <c-space> coc#refresh()
" Use `[c` and `]c` to navigate diagnostics
nmap <silent> [c <Plug>(coc-diagnostic-prev)
nmap <silent> ]c <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use U to show documentation in preview window
nnoremap <silent> U :call <SID>show_documentation()<CR>
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Show all diagnostics
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" disable vim-go :GoDef short cut (gd)
" this is handled by LanguageClient [LC]
let g:go_def_mapping_enabled = 0

0 comments on commit 8fea2ec

Please sign in to comment.