From 5c975cbdc06de606fb328b5429ab9d7f1dcbdb3f Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 31 May 2021 15:21:51 +0300 Subject: [PATCH 1/4] [nvim] add a language server for Vimscript --- nvim/coc-languages/c.vim | 4 +-- nvim/coc-languages/vim.vim | 52 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 nvim/coc-languages/vim.vim diff --git a/nvim/coc-languages/c.vim b/nvim/coc-languages/c.vim index dab445e..6b3e983 100644 --- a/nvim/coc-languages/c.vim +++ b/nvim/coc-languages/c.vim @@ -6,9 +6,7 @@ let g:coc_user_config['languageserver.ccls'] = { \ 'command': 'ccls', \ 'rootPatterns': ['.ccls', 'compile_commands.json', '.vim/', '.git/', '.hg/'], \ 'initializationOptions': { -\ 'cache': { -\ 'directory': '/tmp/ccls', -\ }, +\ 'cache.directory': tempname(), \ }, \ } diff --git a/nvim/coc-languages/vim.vim b/nvim/coc-languages/vim.vim new file mode 100644 index 0000000..c9c0898 --- /dev/null +++ b/nvim/coc-languages/vim.vim @@ -0,0 +1,52 @@ +let s:filetypes = ['vim'] +let g:coc_filetypes += s:filetypes + +let g:coc_global_extensions += ['coc-vimlsp'] +let g:coc_user_config['vimlsp'] = { +\ 'suggest.fromRuntimepath': v:true, +\ } + +" The coc-vimlsp plugin is basically reimplemented here because it doesn't do +" much beyond just wrapping the language server and passing some init options, +" but having two processes (plugin+LSP) almost doubles the memory usage. +" +" On a second thought... Apparently that's just how this extension works... +" Either way it spawns two processes (with the controller process having +" roughly the same memory usage regardless of being in a coc extension). And +" having updates through :CocUpdate is nice, so I'm gonna use the coc-vimlsp +" plugin itself. The janky reimplementation is left in this file for better +" times and bragging purposes. +finish + +" +" workspace.isNvim: +let g:coc_user_config['languageserver.vimls'] = { +\ 'filetypes': s:filetypes, +\ 'command': 'vim-language-server', +\ 'args': ['--stdio'], +\ 'initializationOptions': { +\ 'isNeovim': has('nvim'), +\ 'iskeyword': &iskeyword, +\ 'vimruntime': $VIMRUNTIME, +\ 'runtimepath': &runtimepath, +\ 'suggest.fromRuntimepath': v:true, +\ }, +\ } + +augroup dotfiles-coc-vimls + autocmd! + + " NOTE: Apparently delaying runtimepath initialization even until VimEnter + " is not enough, as coc-snippets adds its plugin to rtp during coc + " intialization phase which happens sometime after VimEnter[1]. Although, + " judging by the coc source code, custom language servers are initialized + " just before activation of extensions[2], and coc-snippets adds its plugin + " to rtp in the activation phase[3], so this might be reasonable for us. + " [1]: + " [2]: + " [3]: + autocmd VimEnter * let g:coc_user_config['languageserver.vimls.initializationOptions.runtimepath'] = &runtimepath + + autocmd User CocNvimInit call CocNotify('vimls', '$/change/iskeyword', &iskeyword) + autocmd OptionSet iskeyword call CocNotify('vimls', '$/change/iskeyword', v:option_new) +augroup END From f944dbe5e266649387589a3f65be6ac80c266bcf Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 31 May 2021 15:32:36 +0300 Subject: [PATCH 2/4] [nvim] increase textwidth just a little bit By default it was set to 78. --- nvim/plugin/editing.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index 5a81cec..11d29c2 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -60,7 +60,7 @@ set commentstring=//%s " Wrapping {{{ - set nowrap colorcolumn=81,101,121 + set nowrap colorcolumn=81,101,121 textwidth=79 " }}} From 4694ecc6658fa25427abc2aad83d1bbf4abcae2c Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 31 May 2021 16:00:43 +0300 Subject: [PATCH 3/4] [nvim] retract some hacks in response to vim-airline/vim-airline@1f94ec1556db36088897c85db62251b62b683ab3 --- nvim/autoload/airline/extensions/dotfiles_tweaks.vim | 10 +++------- nvim/plugin/interface.vim | 4 ++-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/nvim/autoload/airline/extensions/dotfiles_tweaks.vim b/nvim/autoload/airline/extensions/dotfiles_tweaks.vim index d1822a3..ee76228 100644 --- a/nvim/autoload/airline/extensions/dotfiles_tweaks.vim +++ b/nvim/autoload/airline/extensions/dotfiles_tweaks.vim @@ -1,11 +1,7 @@ function! airline#extensions#dotfiles_tweaks#init(ext) abort " Undo this commit a little bit: " - call airline#parts#define('maxlinenr', { - \ 'raw': trim(airline#parts#get('maxlinenr').raw), - \ }) - call airline#parts#define('colnr', { - \ 'raw': trim(airline#parts#get('colnr').raw), - \ 'accent': 'none', - \ }) + " Most of the hacks present here are not required anymore: + " + call airline#parts#define_accent('colnr', 'none') endfunction diff --git a/nvim/plugin/interface.vim b/nvim/plugin/interface.vim index 975c079..082f3b4 100644 --- a/nvim/plugin/interface.vim +++ b/nvim/plugin/interface.vim @@ -92,8 +92,8 @@ endif let g:airline_symbols = { \ 'readonly': 'RO', \ 'whitespace': '', - \ 'colnr': '', - \ 'linenr': '', + \ 'colnr': ' :', + \ 'linenr': ' :', \ 'maxlinenr': ' ', \ 'branch': '', \ 'notexists': ' [?]', From 8534342632ea97770957bf86071b2d914b4b1256 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Mon, 31 May 2021 16:51:17 +0300 Subject: [PATCH 4/4] fixup! [nvim] increase textwidth just a little bit --- nvim/plugin/editing.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index 11d29c2..a294e71 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -203,10 +203,12 @@ set commentstring=//%s " Formatting {{{ - " don't insert a comment after hitting 'o' or 'O' in the Normal mode + " -o: don't insert a comment after hitting 'o' or 'O' in the Normal mode + " -t: don't auto-wrap regular code while typing + " -c: don't auto-wrap comments while typing augroup vimrc-editing-formatting autocmd! - autocmd FileType * set formatoptions-=o + autocmd FileType * set formatoptions-=o | set formatoptions-=t | set formatoptions-=c augroup END " }}}