diff options
| author | Robert Günzler <r@gnzler.io> | 2020-06-01 18:14:07 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-06-01 18:32:20 +0200 |
| commit | 7edcb8133bfd469458f94039021d74258b3bf72c (patch) | |
| tree | 87b5f578c03dba0ad8da5fa95e6184cd5aef092d | |
| parent | 8367490e2637385aae3984696c71949b640c8fc4 (diff) | |
vim: remove coc and add nvim-lsp+compl
| -rw-r--r-- | .vim/after/plugin/coc.vim | 86 | ||||
| -rw-r--r-- | .vim/after/plugin/lsp.vim | 25 | ||||
| -rw-r--r-- | .vim/coc-settings.json | 82 | ||||
| -rw-r--r-- | .vim/init.vim | 59 | ||||
| -rw-r--r-- | .vim/plug.vim | 19 |
5 files changed, 57 insertions, 214 deletions
diff --git a/.vim/after/plugin/coc.vim b/.vim/after/plugin/coc.vim deleted file mode 100644 index c0e8f38..0000000 --- a/.vim/after/plugin/coc.vim +++ /dev/null @@ -1,86 +0,0 @@ -" coc json config -> ../../coc-settings.json -finish - -if !exists('g:did_coc_loaded') - finish -endif - -set completeopt=noinsert,menuone,noselect -set completeopt-=preview -set shortmess+=c -" set showmatch - -" let g:coc_auto_copen = 1 -let g:coc_snippet_next = '<Tab>' -let g:coc_snippet_prev = '<S-Tab>' - -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>" : -" \ coc#refresh() -inoremap <silent><expr> <Tab> - \ pumvisible() ? coc#_select_confirm() : - \ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" : - \ <SID>check_back_space() ? "\<Tab>" : - \ coc#refresh() - -inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" -inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" -inoremap <silent><expr> <C-Space> coc#refresh() - -vmap <Tab> <Plug>(coc-snippets-select) - -nmap <silent> [c <Plug>(coc-diagnostic-next) -nmap <silent> ]c <Plug>(coc-diagnostic-prev) -nmap <leader>lc :CocList diagnostics<CR> - -imap <silent> <C-p> <Plug>(coc-complete-custom) -nmap <leader>d <Plug>(coc-definition) -nmap <leader>t <Plug>(coc-type-definition) -nmap <leader>i <Plug>(coc-implementation) -nmap <leader>r <Plug>(coc-references) -nmap <leader>rn <Plug>(coc-rename) -nmap <leader>qf <Plug>(coc-fix-current) -nmap <leader>ac <Plug>(coc-codeaction) - -xmap <leader>f <Plug>(coc-format-selected) -nmap <leader>f <Plug>(coc-format-selected) - -xmap <leader>a <Plug>(coc-codeaction-current) -nmap <leader>a <Plug>(coc-codeaction-current) -nmap <leader>ac <Plug>(coc-codeaction) - -nmap <Leader>o :CocList outline<CR> - -function! s:show_doc() - if (index(['vim', 'help'], &filetype) >= 0) - execute 'h ' . expand('<cword>') - else - call CocAction('doHover') - endif -endfunction -nmap <Leader>i :silent! call <SID>show_doc()<CR> - -au CursorHold * silent call CocActionAsync('highlight') - -command! -nargs=0 Format :call CocAction('format') -command! -nargs=? Fold :call CocAction('fold', <f-args>) - -let g:lightline.component_function.coc = 'LightLineCocStatus' -function! LightLineCocStatus() - let info = get(b:, 'coc_diagnostic_info', {}) - if empty(info) | return '' | endif - let msgs = [] - if get(info, 'error', 0) - call add(msgs, '✘ ' . info['error']) - endif - if get(info, 'warning', 0) - call add(msgs, '‼ ' . info['warning']) - endif - return 'coc: ' . join(msgs, ' ') -endfunction diff --git a/.vim/after/plugin/lsp.vim b/.vim/after/plugin/lsp.vim deleted file mode 100644 index ffdea10..0000000 --- a/.vim/after/plugin/lsp.vim +++ /dev/null @@ -1,25 +0,0 @@ -if !has('nvim-0.5.0') - " echoerr 'nvim_lsp only works with neovim>=0.5.0' - finish -endif - -lua << EOF -local lsp = require 'nvim_lsp' -local util = require 'nvim_lsp/util' -local compl = require 'completion' - -lsp.gopls.setup{ - on_attach = compl.on_attach; - root_dir = util.root_pattern("go.mod"); -} -EOF - -" autocmd Filetype bash,shell,css,go,python,rust,tex,latex setl omnifunc=lsp#omnifunc -" au Filetype lua setl omnifunc=v:lua.vim.lsp.omnifunc - -nnoremap <silent> gd :call lsp#text_document_definition()<CR> -nnoremap <silent> gdc :call lsp#text_document_declaration()<CR> -nnoremap <silent> gt :call lsp#text_document_type_definition()<CR> -nnoremap <silent> gi :call lsp#text_document_implementation()<CR> -nnoremap <silent> ;h :call lsp#text_document_hover()<CR> -nnoremap <silent> ;s :call lsp#text_document_signature_help()<CR> diff --git a/.vim/coc-settings.json b/.vim/coc-settings.json deleted file mode 100644 index 6bf350b..0000000 --- a/.vim/coc-settings.json +++ /dev/null @@ -1,82 +0,0 @@ -{ - "coc.preferences.snippets.enable": true, - "coc.preferences.formatOnType": false, - "coc.preferences.formatOnSaveFiletypes": [], - "coc.preferences.hoverTarget": "float", - "coc.preferences.enableFloatHighlight": true, - "coc.preferences.extensionUpdateCheck": "never", - - "list.signOffset": 900, - - "suggest.autoTrigger": "always", - "suggest.triggerAfterInsertEnter": true, - "suggest.minTriggerInputLength": 1, - "suggest.noselect": true, - "suggest.enablePreview": true, - "suggest.enablePreselect": false, - "suggest.floatEnable": true, - - "signature.enable": true, - "signature.target": "float", - "signature.preferShownAbove": true, - - "diagnostic.enable": true, - "diagnostic.checkCurrentLine": false, - "diagnostic.virtualText": true, - "diagnostic.virtualTextLines": 1, - "diagnostic.messageTarget": "float", - "diagnostic.level": "hint", - "diagnostic.enableSign": true, - "diagnostic.errorSign": "✘", - "diagnostic.warningSign": "‼", - "diagnostic.infoSign": "i", - "diagnostic.hintSign": "☛", - - "rust-client.channel": "stable", - "rust-client.rlsPath": "ra_lsp_server", - - "python.linting.flake8Enabled": false, - "python.linting.pylintEnabled": true, - - "languageserver": { - "gopls": { - "enable": false, - "command": "gopls", - "rootPatterns": ["go.mod", ".git/", ".hg/"], - "filetypes": ["go"] - }, - "go-langserver": { - "enable": false, - "command": "go-langserver", - "initializationOptions": { - "gocodeCompletionEnabled": true, - "diagnosticsEnabled": true, - "lintTool": "golint" - }, - "filetypes": ["go"] - }, - "ccls": { - "enable": false, - "command": "ccls", - "rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"], - "initializationOptions": { - "cache": { - "directory": "/tmp/ccls" - } - }, - "filetypes": ["c", "cpp", "objc", "objcpp"] - }, - "rust-analyzer": { - "enable": false, - "command": "ra_lsp_server", - "rootPatterns": ["Cargo.toml", "Cargo.lock", ".git/"], - "filetypes": ["rust"] - }, - "efm": { - "enable": false, - "command": "efm-langserver", - "args": [], - "filetypes": ["vim", "markdown", "yaml"] - } - } -} diff --git a/.vim/init.vim b/.vim/init.vim index aaec266..e9d8e7b 100644 --- a/.vim/init.vim +++ b/.vim/init.vim @@ -232,11 +232,60 @@ let g:neoformat_only_msg_on_error = 1 let g:neoterm_size = 20 let g:neoterm_autoinsert = 1 -let g:UltiSnipsExpandTrigger = "<c-y>" +let g:UltiSnipsExpandTrigger = "<tab>" +" let g:UltiSnipsListSnippets = "<c-tab>" let g:UltiSnipsJumpForwardTrigger = "<c-n>" let g:UltiSnipsJumpBackwardTrigger = "<c-p>" " }}}1 +" lsp + compl {{{1 +if has('nvim-0.5.0') +lua << EOF +local lsp = require 'nvim_lsp' +local util = require 'nvim_lsp/util' +local compl = require 'completion' + +lsp.gopls.setup{ + on_attach = compl.on_attach; + root_dir = util.root_pattern("go.mod"); +} +lsp.rust_analyzer.setup{ + on_attach = compl.on_attach; +} +EOF + " autocmd Filetype bash,shell,css,go,python,rust,tex,latex setl omnifunc=lsp#omnifunc + " au Filetype lua setl omnifunc=v:lua.vim.lsp.omnifunc + nnoremap <silent> gd :call lsp#text_document_definition()<CR> + nnoremap <silent> gdc :call lsp#text_document_declaration()<CR> + nnoremap <silent> gt :call lsp#text_document_type_definition()<CR> + nnoremap <silent> gi :call lsp#text_document_implementation()<CR> + nnoremap <silent> ;h :call lsp#text_document_hover()<CR> + nnoremap <silent> ;s :call lsp#text_document_signature_help()<CR> +else + echoerr 'nvim_lsp only works with neovim>=0.5.0' +endif + +set complete=.,w,b,u +set completeopt=menuone,noinsert,noselect +" set completeopt-=preview +set shortmess+=c + +let g:completion_enable_auto_popup = 1 +let g:completion_enable_auto_signature = 1 +let g:completion_enable_auto_paren = 0 +let g:completion_confirm_key = "\<tab>" +let g:completion_enable_snippet = 'UltiSnips' +let g:completion_auto_change_source = 1 +let g:completion_chain_complete_list = [ + \ {'complete_items': ['lsp', 'snippet']}, + \ {'mode': '<c-p>'}, + \ {'mode': '<c-n>'} + \ ] + +inoremap <silent><expr> <c-n> + \ pumvisible() ? "\<c-n>" : completion#trigger_completion() +" }}}1 + " gui extra config {{{ " probably obsolete... if exists('veonim') @@ -269,7 +318,13 @@ augroup SpecialBuffers au FileType help,qf nmap <buffer>q <c-w><c-q> augroup END -augroup init +" augroup AutoSaveFolds +" autocmd! +" autocmd BufWinLeave * mkview +" autocmd BufWinEnter * silent loadview +" augroup END + +augroup Init au! au VimEnter * set iskeyword-=- " au VimEnter * call vista#RunForNearestMethodOrFunction() diff --git a/.vim/plug.vim b/.vim/plug.vim index 01302af..280ea34 100644 --- a/.vim/plug.vim +++ b/.vim/plug.vim @@ -8,7 +8,6 @@ endif call plug#begin('~/.vim/plugged') " Core - " Plug 'airblade/vim-gitgutter' " line status next to line nums Plug 'mhinz/vim-signify' " git status in the sign column Plug 'tpope/vim-commentary' " auto-comment using `gcc` Plug 'cohama/lexima.vim' " auto-close parens, brackets, etc. @@ -27,19 +26,6 @@ call plug#begin('~/.vim/plugged') Plug 'SirVer/ultisnips' \| Plug 'honza/vim-snippets' - " Plug 'neoclide/coc.nvim', - " \ { 'do': './install.sh nightly' } - " \| Plug 'neoclide/coc-snippets', { 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-json', { 'for': ['json'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-rls', { 'for': ['rust'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-python', { 'for': ['python'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-yaml', { 'for': ['yaml'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-html', { 'for': ['html'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-css', { 'for': ['css'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'josa42/coc-go', { 'for': ['go'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-java', { 'for': ['java'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug 'neoclide/coc-emmet', { 'for': ['html', 'css'], 'do': 'yarn install --frozen-lockfile' } - " \| Plug '~/devel/upstream/github.com/microsoft/vscode-go', { 'for': ['go'] } " search " Plug 'junegunn/fzf', @@ -70,7 +56,6 @@ call plug#begin('~/.vim/plugged') " Languages " NOTE: these should only be loaded when they are required... - " Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } " Plug 'rhysd/vim-grammarous', { 'for': ['markdown', 'latex', 'tex'] } Plug 'lervag/vimtex', { 'for': ['latex', 'tex'] } Plug 'plasticboy/vim-markdown', { 'for': ['markdown'] } @@ -78,7 +63,6 @@ call plug#begin('~/.vim/plugged') Plug 'mattn/emmet-vim', { 'for': ['html', 'vue'] } " super-fast HTML editing " Plug 'valloric/matchtagalways', { 'for': ['html', 'vue', 'xml'] } " visually match HTML tags enclosing cursor location Plug 'ledger/vim-ledger', { 'for': ['ledger'] } - Plug 'jceb/vim-orgmode', { 'for': ['org'] } \| Plug 'tpope/vim-speeddating' " easy time/date incrementing \| Plug 'vim-scripts/utl.vim' " follow links/urls Plug 'gentoo/gentoo-syntax', { 'for': ['ebuild'] } @@ -93,10 +77,7 @@ call plug#begin('~/.vim/plugged') " Plug 'equalsraf/neovim-gui-shim' " Colorschemes - " Plug 'deviantfero/wpgtk.vim' - " Plug 'KeitaNakamura/neodark.vim' Plug 'NLKNguyen/papercolor-theme' - " Plug 'crusoexia/vim-dracula' " Local " Plug '~/devel/projects/nihon-theme/vim' |