From 34a5318c14117335f53004be724b6b7a0cc0b3f5 Mon Sep 17 00:00:00 2001 From: yushyin Date: Sat, 29 Sep 2018 14:29:24 +0200 Subject: Vim: Add vim-lsp Replace language specific autocompletion for Haskell, Rust and C/C++ with vim-lsp's omnifunc. --- vim/after/ftplugin/haskell.vim | 1 + vim/dein.toml | 29 ++++++++--------------------- vim/ftplugin/haskell.vim | 1 - vim/ftplugin/rust.vim | 1 + vim/plugrc/clang_complete.rc.vim | 4 ---- vim/vimrc | 32 +++++++++++++++++++++++++------- 6 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 vim/after/ftplugin/haskell.vim create mode 100644 vim/ftplugin/rust.vim delete mode 100644 vim/plugrc/clang_complete.rc.vim diff --git a/vim/after/ftplugin/haskell.vim b/vim/after/ftplugin/haskell.vim new file mode 100644 index 0000000..aebbe1a --- /dev/null +++ b/vim/after/ftplugin/haskell.vim @@ -0,0 +1 @@ +setlocal omnifunc=lsp#complete diff --git a/vim/dein.toml b/vim/dein.toml index 6ddebb3..54e7fe1 100644 --- a/vim/dein.toml +++ b/vim/dein.toml @@ -25,29 +25,12 @@ repo = 'vim-scripts/a.vim' lazy = 1 on_ft = ['c', 'cpp'] -[[plugins]] -repo = 'Rip-Rip/clang_complete.git' -lazy = 1 -on_ft = ['c', 'cpp'] - [[plugins]] repo = 'Twinside/vim-hoogle' lazy = 1 external_commands = 'hoogle' on_ft = ['haskell', 'lhaskell', 'chaskell'] -[[plugins]] -repo = 'eagletmt/ghcmod-vim' -lazy = 1 -external_commands = 'ghc-mod' -on_ft = ['haskell', 'lhaskell', 'chaskell'] - -[[plugins]] -repo = 'eagletmt/neco-ghc' -lazy = 1 -external_commands = 'ghc-mod' -on_ft = ['haskell', 'lhaskell', 'chaskell'] - [[plugins]] repo = 'ujihisa/unite-haskellimport' lazy = 1 @@ -58,10 +41,6 @@ repo = 'rust-lang/rust.vim' lazy = 1 on_ft = 'rust' -[[plugins]] -repo = 'racer-rust/vim-racer' -on_ft = 'rust' - [[plugins]] repo = 'MarcWeber/vim-addon-local-vimrc' @@ -116,3 +95,11 @@ repo = 'kana/vim-textobj-indent' lazy = 1 on_map = { xo = '' } depends = ['vim-textobj-user'] + +[[plugins]] +repo = 'prabirshrestha/async.vim' + +[[plugins]] +repo = 'prabirshrestha/vim-lsp' +lazy = 0 +depends = ['async.vim'] diff --git a/vim/ftplugin/haskell.vim b/vim/ftplugin/haskell.vim index a3ed140..23a4130 100644 --- a/vim/ftplugin/haskell.vim +++ b/vim/ftplugin/haskell.vim @@ -1,3 +1,2 @@ setl tags+=codex.tags -setl omnifunc=necoghc#omnifunc setl ts=8 sts=4 sw=4 et sr diff --git a/vim/ftplugin/rust.vim b/vim/ftplugin/rust.vim new file mode 100644 index 0000000..aebbe1a --- /dev/null +++ b/vim/ftplugin/rust.vim @@ -0,0 +1 @@ +setlocal omnifunc=lsp#complete diff --git a/vim/plugrc/clang_complete.rc.vim b/vim/plugrc/clang_complete.rc.vim deleted file mode 100644 index 8b776b6..0000000 --- a/vim/plugrc/clang_complete.rc.vim +++ /dev/null @@ -1,4 +0,0 @@ -let g:clang_auto_select = 1 -let g:clang_snippets = 1 -let g:clang_complete_macros = 1 -let g:clang_complete_patterns = 1 diff --git a/vim/vimrc b/vim/vimrc index fda8fa4..959d790 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -65,13 +65,6 @@ if dein#tap('neosnippet.vim') smap (neosnippet_expand_or_jump) xmap (neosnippet_expand_or_jump) endif -if dein#tap('clang_complete') - call s:hook_source() -endif -if dein#tap('vim-racer') - let g:dein#plugin.hook_source = - \ "let $RUST_SRC_PATH= $XDG_DATA_HOME . '/rustc_src_latest/src/'" -endif if dein#tap('vim-easy-align') nmap ga (EasyAlign) endif @@ -102,6 +95,31 @@ endif if dein#tap('vim-addon-local-vimrc') let g:local_vimrc = {'names':['.lvimrc'],'hash_fun':'LVRHashOfFile'} endif +if dein#tap('vim-lsp') + if executable('cquery') + au 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/cache' }, + \ 'whitelist': ['c', 'cpp', 'objc', 'objcpp'], + \ }) + endif + if executable('rls') + au User lsp_setup call lsp#register_server({ + \ 'name': 'rls', + \ 'cmd': {server_info->['rustup', 'run', 'nightly', 'rls']}, + \ 'whitelist': ['rust'], + \ }) + endif + if executable('hie-wrapper') + au User lsp_setup call lsp#register_server({ + \ 'name': 'hie', + \ 'cmd': {server_info->['hie-wrapper']}, + \ 'whitelist': ['haskell'], + \ }) + endif +endif if dein#tap('base16-vim') set bg=dark let base16colorspace=256 -- cgit v1.2.3-24-g4f1b