summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <matt@matthewlemon.com>2022-09-10 08:12:47 +0100
committerMatthew Lemon <matt@matthewlemon.com>2022-09-10 08:12:47 +0100
commit2ee9385753b519e7af6e26dd5c5e0572251de922 (patch)
tree6d3dcce01cdd4b6fd2a237b5e44f4e4a6c421bdc
parent37cd62049e052b9fbd5a197cf0639bc2ebe200da (diff)
added new go vim plugin
-rw-r--r--vim/plugin/lsp.vim45
-rw-r--r--vim/vimrc3
2 files changed, 47 insertions, 1 deletions
diff --git a/vim/plugin/lsp.vim b/vim/plugin/lsp.vim
new file mode 100644
index 0000000..ea2f62d
--- /dev/null
+++ b/vim/plugin/lsp.vim
@@ -0,0 +1,45 @@
+func! s:setup_ls(...) abort
+ let l:servers = lsp#get_allowed_servers()
+
+ " key mappings
+ for l:server in l:servers
+ let l:cap = lsp#get_server_capabilities(l:server)
+
+ if has_key(l:cap, 'completionProvider')
+ setlocal completefunc=lsp#complete
+ endif
+
+ if has_key(l:cap, 'hoverProvider')
+ setlocal keywordprg=:LspHover
+ endif
+
+ if has_key(l:cap, 'codeActionProvider')
+ nmap <silent><buffer>ga <plug>(lsp-code-action)
+ endif
+
+ if has_key(l:cap, 'definitionProvider')
+ nmap <silent><buffer>gd <plug>(lsp-definition)
+ nmap <silent><buffer>gk <plug>(lsp-peek-definition)
+ endif
+ endfor
+endfunc
+
+" register language server
+augroup LSC
+ autocmd!
+ autocmd User lsp_setup call lsp#register_server({
+ \ 'name': 'gopls',
+ \ 'cmd': {_->['gopls']},
+ \ 'allowlist': ['go']
+ \})
+
+ autocmd User lsp_server_init call <SID>setup_ls()
+ autocmd BufEnter * call <SID>setup_ls()
+augroup END
+
+" disable diagnostics etc.
+let g:lsp_diagnostics_enabled = 0
+let g:lsp_diagnostics_signs_enabled = 0
+let g:lsp_diagnostics_virtual_text_enabled = 0
+let g:lsp_diagnostics_highlights_enabled = 0
+let g:lsp_document_code_action_signs_enabled = 0
diff --git a/vim/vimrc b/vim/vimrc
index 8a7be8f..c083015 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -89,7 +89,7 @@ noremap k gk
set shell=/bin/sh
set hi=500
set novisualbell
-set nonumber "show line numbers
+"set nonumber "show line numbers
set wildmenu "enable a menu that shows tab completion options in the status bar
set wildchar=<TAB>
set showmatch "highlights matching brackets on cursor hover
@@ -144,6 +144,7 @@ autocmd BufLeave * call s:copy_filename_as_mdlink()
" vim-plug
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
+Plug 'prabirshrestha/vim-lsp'
Plug 'alok/notational-fzf-vim'
Plug 'sheerun/vim-polyglot'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}