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