Created
August 30, 2019 14:05
-
-
Save mccurdyc/01040be7d309134ad3a2ab7d32224034 to your computer and use it in GitHub Desktop.
Golang NeoVim Autocomplete Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call plug#begin('~/.vim/plugged') | |
Plug 'prabirshrestha/asyncomplete.vim' | |
Plug 'prabirshrestha/asyncomplete-gocode.vim' | |
Plug 'prabirshrestha/async.vim' | |
Plug 'prabirshrestha/vim-lsp' | |
Plug 'prabirshrestha/asyncomplete-lsp.vim | |
call plug#end() | |
" Plugin: 'prabirshrestha/asyncomplete.vim' | |
" Tab completion | |
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>" | |
" refresh suggestions on backspace | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ asyncomplete#force_refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
set completeopt+=preview | |
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif | |
" https://github.com/prabirshrestha/asyncomplete.vim#language-server-protocol-lsp | |
if executable('gopls') | |
" pip install python-language-server | |
au User lsp_setup call lsp#register_server({ | |
\ 'name': 'gopls', | |
\ 'cmd': {server_info->['gopls']}, | |
\ 'whitelist': ['go'], | |
\ }) | |
endif | |
" https://github.com/prabirshrestha/asyncomplete-gocode.vim | |
call asyncomplete#register_source(asyncomplete#sources#gocode#get_source_options({ | |
\ 'name': 'gocode', | |
\ 'whitelist': ['go'], | |
\ 'completor': function('asyncomplete#sources#gocode#completor'), | |
\ 'config': { | |
\ 'gocode_path': expand('~/go/bin/gocode') | |
\ }, | |
\ })) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment