From f5fcdec8af08d87a2195cb3299b367eac3c8c0a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Wed, 29 Jun 2022 19:17:49 +0200 Subject: [PATCH] Switch to pyright instead of Ycm --- .vim/coc-settings.json | 3 ++ .vimrc | 68 ++++++++++++++++++++++++++++++++---------- 2 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 .vim/coc-settings.json diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json new file mode 100644 index 0000000..1bcc330 --- /dev/null +++ b/.vim/coc-settings.json @@ -0,0 +1,3 @@ +{ + "python.linting.enabled": false +} diff --git a/.vimrc b/.vimrc index 7425a3f..4bb9255 100644 --- a/.vimrc +++ b/.vimrc @@ -6,11 +6,15 @@ let $VIMHOME = VIMHOME " vim-plug call plug#begin(VIMHOME."/plugs") " Plug 'OmniSharp/omnisharp-vim' +Plug 'prabirshrestha/asyncomplete.vim' +Plug 'prabirshrestha/vim-lsp' +Plug 'prabirshrestha/asyncomplete-lsp.vim' +Plug 'ervandew/supertab' Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'ConradIrwin/vim-bracketed-paste' Plug 'NLKNguyen/papercolor-theme' Plug 'Shougo/deoplete.nvim' -Plug 'Valloric/YouCompleteMe' +" Plug 'Valloric/YouCompleteMe' Plug 'christoomey/vim-tmux-navigator' Plug 'cohama/lexima.vim', {'do': 'sed -i \"s/has(.nvim.) && //\" autoload/lexima/insmode.vim'} Plug 'editorconfig/editorconfig-vim' @@ -54,8 +58,8 @@ nnoremap " don't store .swp files in the file's own directory " neither for .ext~ files -set directory=/home/user/.vim/tmp/ -set backupdir=/home/user/.vim/tmp/ +set directory=/home/server/.vim/tmp/ +set backupdir=/home/server/.vim/tmp/ " VimWiki let g:vimwiki_key_mappings = { 'table_mappings': 0 } @@ -200,22 +204,56 @@ Ext 'coc-snippets' Ext 'coc-emoji' Ext 'coc-highlight' Ext 'coc-emmet' -Ext 'coc-omnisharp' +" Ext 'coc-omnisharp' Ext 'coc-vimtex' Ext 'coc-json' Ext 'coc-java' +Ext 'coc-pyright' delc Ext -" Tab for completion +" Language Server -" use for trigger completion and navigate to the next complete item -" function! s:check_back_space() abort -" let col = col('.') - 1 -" return !col || getline('.')[col - 1] =~ '\s' -" endfunction -" -" inoremap -" \ pumvisible() ? "\" : -" \ check_back_space() ? "\" : -" \ coc#refresh() +if executable('pyls') + " pip install python-language-server + au User lsp_setup call lsp#register_server({ + \ 'name': 'pyls', + \ 'cmd': {server_info->['pyls']}, + \ '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 + + + +" Tab for completion +let g:SuperTabContextDefaultCompletionType = "" +let g:SuperTabDefaultCompletionType = ""