summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZofia Szweda <sophies@disroot.org>2026-09-04 17:51:13 +0200
committerZofia Szweda <sophies@disroot.org>2026-09-04 17:51:13 +0200
commit9cdf96247221df026f5df0374403636a95917718 (patch)
tree2fb1471ff73da7db9ad8c72ef444c87bfdb84fd1
parenta3085bd8f46574576f30bdbccaf9bd2e65caf752 (diff)
vim: lsp stuff
-rw-r--r--vim/.vimrc45
1 files changed, 45 insertions, 0 deletions
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 = "\<Space>"
nnoremap <Space> <Nop>
@@ -65,4 +73,41 @@ let g:which_key_map.b = {
\ 'b' : ['Buffers', 'fuzzy find buffers'],
\ }
call which_key#register('<Space>', '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 <buffer> gd <plug>(lsp-definition)
+ nmap <buffer> gs <plug>(lsp-document-symbol-search)
+ nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
+ nmap <buffer> gr <plug>(lsp-references)
+ nmap <buffer> gi <plug>(lsp-implementation)
+ nmap <buffer> gt <plug>(lsp-type-definition)
+ nmap <buffer> <leader>rn <plug>(lsp-rename)
+ nmap <buffer> [g <plug>(lsp-previous-diagnostic)
+ nmap <buffer> ]g <plug>(lsp-next-diagnostic)
+ nmap <buffer> K <plug>(lsp-hover)
+ nnoremap <buffer> <expr><c-f> lsp#scroll(+4)
+ nnoremap <buffer> <expr><c-d> 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