From b6544120a820700785ef0d05b462df2e4bb17c53 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Tue, 5 Mar 2019 16:21:47 +0100 Subject: Test simpler setup using vim-lsp Feels less distracting and faster. I don't actually want to turn this vim setup into a always active intellisense-like experience but rather have code introspection quickly available if I actually need it. --- pkgs/custom-neovim/asset/rc.vim | 40 ++++++++++++++++++++++------------------ pkgs/custom-neovim/default.nix | 4 +--- pkgs/custom-neovim/plugins.nix | 18 ++++++++++++++++++ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/pkgs/custom-neovim/asset/rc.vim b/pkgs/custom-neovim/asset/rc.vim index 822ac87..202b1ad 100644 --- a/pkgs/custom-neovim/asset/rc.vim +++ b/pkgs/custom-neovim/asset/rc.vim @@ -126,25 +126,29 @@ let g:localvimrc_persistent = 2 let g:wordmotion_prefix = '' nmap w +let g:lsp_auto_enable = 0 + " spinning up a language client only makes " sense if such a client is available if executable('cquery') - let g:LanguageClient_serverCommands = { 'cpp': [ 'cquery' ] } - let g:LanguageClient_hoverPreview = "Never" - - set completefunc=LanguageClient#complete - set completeopt-=preview - - inoremap - " allow completion selection via CR without inserting a new line - imap pumvisible() ? "\" : "\" - - noremap lc :call LanguageClient_contextMenu() - noremap lr :call LanguageClient_rename() - nnoremap gd :call LanguageClient#textDocument_definition() - nnoremap gt :call LanguageClient#textDocument_typeDefinition() - nnoremap gi :call LanguageClient#textDocument_implementation() - - nmap :Denite workspaceSymbol - nmap :Denite documentSymbol + let g:lsp_auto_enable = 1 + + autocmd User lsp_setup call lsp#register_server({ + \ 'name': 'cquery', + \ 'cmd': {server_info->['cquery']}, + \ 'root_uri': {server_info->lsp#utils#path_to_uri(lsp#utils#find_nearest_parent_file_directory(lsp#utils#get_buffer_path(), 'compile_commands.json'))}, + \ 'initialization_options': { 'cacheDirectory': '/tmp/cquery' }, + \ 'whitelist': ['c', 'cpp', 'cc'], + \ }) + + nnoremap gd :LspDefinition + nnoremap gt :LspTypeDefinition + nnoremap gi :LspImplementation + nnoremap gr :LspReferences + + nmap :LspWorkspaceSymbol + nmap :LspDocumentSymbol + + autocmd FileType cpp setlocal omnifunc=lsp#complete + inoremap endif diff --git a/pkgs/custom-neovim/default.nix b/pkgs/custom-neovim/default.nix index ca1fc75..1dff1f7 100644 --- a/pkgs/custom-neovim/default.nix +++ b/pkgs/custom-neovim/default.nix @@ -17,9 +17,7 @@ in pkgs.neovim.override { # autocomplete fzfWrapper fzf-vim - LanguageClient-neovim - deoplete-nvim - denite + async vim-lsp # load project specific config vim-localvimrc diff --git a/pkgs/custom-neovim/plugins.nix b/pkgs/custom-neovim/plugins.nix index 9ff92f2..5e0f6ea 100644 --- a/pkgs/custom-neovim/plugins.nix +++ b/pkgs/custom-neovim/plugins.nix @@ -76,6 +76,24 @@ in { }; }; + vim-lsp = buildVimPlugin { + name = "vim-lsp"; + src = fetchgit { + url = "https://github.com/prabirshrestha/vim-lsp.git"; + rev = "0310241af11adc6c3a7ba93955bc27b15744c957"; + sha256 = "0ccd6is75qlk8mg9wpwp1ypq68p7lgbq1c1jbpr6pwr59s53r4lx"; + }; + }; + + async = buildVimPlugin { + name = "async"; + src = fetchgit { + url = "https://github.com/prabirshrestha/async.vim.git"; + rev = "f3014550d7a799097e56b094104dd2cd66cf2612"; + sha256 = "0zn25qwycynagrij5rsp1x7kbfz612gn7xda0hvm4y7qr3pal77p"; + }; + }; + vim-color-akr = buildVimPlugin { name = "vim-color-akr"; src = ./asset/vim-color-akr; -- cgit v1.2.3