From 9cdf96247221df026f5df0374403636a95917718 Mon Sep 17 00:00:00 2001 From: Zofia Szweda Date: Fri, 4 Sep 2026 17:51:13 +0200 Subject: vim: lsp stuff --- vim/.vimrc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'vim/.vimrc') diff --git a/vim/.vimrc b/vim/.vimrc index 138455a..6f625c4 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -11,15 +11,19 @@ Plug 'junegunn/fzf.vim' Plug 'kamil-stachowski/flatwhite-vim' Plug 'prabirshrestha/vim-lsp' Plug 'mattn/vim-lsp-settings' +Plug 'prabirshrestha/asyncomplete.vim' Plug 'prabirshrestha/asyncomplete-lsp.vim' Plug 'tpope/vim-vinegar' Plug 'ap/vim-buftabline' +Plug 'sheerun/vim-polyglot' Plug 'kalbasit/vim-colemak' call plug#end() filetype on filetype indent on filetype plugin on set nocompatible +set fileformat=unix +set encoding=UTF-8 set number set rnu set expandtab @@ -39,6 +43,10 @@ set ttimeoutlen=1 set termguicolors set laststatus=2 set noshowmode +set undofile +set undodir=~/.vim/undodir +set signcolumn=yes +set shortmess+=c colorscheme flatwhite let mapleader = "\" nnoremap @@ -65,4 +73,41 @@ let g:which_key_map.b = { \ 'b' : ['Buffers', 'fuzzy find buffers'], \ } call which_key#register('', 'g:which_key_map') +" lsp +if executable('pylsp') + " pip install python-lsp-server + au User lsp_setup call lsp#register_server({ + \ 'name': 'pylsp', + \ 'cmd': {server_info->['pylsp']}, + \ 'allowlist': ['python'], + \ }) +endif + +function! s:on_lsp_buffer_enabled() abort + setlocal omnifunc=lsp#complete + setlocal signcolumn=yes + if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif + nmap gd (lsp-definition) + nmap gs (lsp-document-symbol-search) + nmap gS (lsp-workspace-symbol-search) + nmap gr (lsp-references) + nmap gi (lsp-implementation) + nmap gt (lsp-type-definition) + nmap rn (lsp-rename) + nmap [g (lsp-previous-diagnostic) + nmap ]g (lsp-next-diagnostic) + nmap K (lsp-hover) + nnoremap lsp#scroll(+4) + nnoremap lsp#scroll(-4) + + let g:lsp_format_sync_timeout = 1000 + autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') + + " refer to doc to add more commands +endfunction +augroup lsp_install + au! + " call s:on_lsp_buffer_enabled only for languages that has the server registered. + autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() +augroup END -- cgit v1.2.3