nvim: Add LSP support

Though we had removed this earlier bring it back. It saves the hassle of
having different plugin, packages or bindings for different languages.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-01-18 15:02:28 +05:30
parent adc85a9f34
commit e696cbfde3

View file

@ -61,7 +61,6 @@ Plug 'LnL7/vim-nix', { 'for': 'nix' }
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'deoplete-plugins/deoplete-tag'
" For Python
Plug 'davidhalter/jedi-vim', { 'for': 'python' }
Plug 'zchee/deoplete-jedi', { 'for': 'python' }
Plug 'numirias/semshi', { 'for': 'python', 'do': ':UpdateRemotePlugins' }
" Autocomplete for Rust
@ -92,6 +91,7 @@ Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-vinegar'
Plug 'wellle/targets.vim'
Plug 'Yggdroot/indentLine'
Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }
" Miscellaneous
Plug 'editorconfig/editorconfig-vim'
Plug 'igankevich/mesonic'
@ -144,6 +144,7 @@ set noswapfile " no swap files
set foldmethod=syntax " Create folds based on files syntax
set nofoldenable " Open folds by default
set undofile " Enable undo persistence across sessions
set hidden " Required by LC
" Wild menu
set wildmenu
@ -420,11 +421,6 @@ augroup END
augroup rust_maps
au!
au FileType rust nmap <buffer> gd <plug>DeopleteRustGoToDefinitionDefault
au FileType rust nmap <buffer> K <plug>DeopleteRustShowDocumentation
au FileType rust nmap <buffer> gv <plug>DeopleteRustGoToDefinitionVSplit
au FileType rust nmap <buffer> g- <plug>DeopleteRustGoToDefinitionSplit
au FileType rust nmap <buffer> gt <plug>DeopleteRustGoToDefinitionTab
" Taken from http://seenaburns.com/vim-setup-for-rust/
" Neomake
" Gross hack to stop Neomake running when exitting because it creates a zombie cargo check process
@ -490,6 +486,11 @@ augroup END
" Automatically resize the window
autocmd VimResized * wincmd =
augroup LSP
au!
autocmd FileType haskell,rust,python :call SetLspKeybindings()
augroup END
" --------------------------- Plugin settings --------------------------------
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
@ -531,8 +532,9 @@ call deoplete#custom#source('_',
\ 'disabled_syntaxes', ['Comment', 'String'])
call deoplete#custom#option('sources', {
\ '_' : ['buffer', 'tag', 'around', 'file', 'member'],
\ 'haskell': ['buffer', 'tag'],
\ 'rust': ['racer', 'buffer', 'tag'],
\ 'haskell': ['LanguageClient', 'buffer', 'tag'],
\ 'rust': ['LanguageClient', 'buffer'],
\ 'python': ['LanguageClient', 'buffer'],
\ 'purescript': ['buffer', 'omni'],
\})
call deoplete#custom#source('omni', 'functions', {
@ -547,8 +549,6 @@ call deoplete#custom#option({
\ 'smart_case': v:true,
\ })
let g:deoplete#sources#rust#disable_keymap = 1
let g:deoplete#sources#rust#racer_binary=expand('$HOME/.cargo/bin/racer')
let g:deoplete#sources#rust#rust_source_path=expand('$HOME/GitSources/rust/src')
let g:rustfmt_autosave = 1
" Use airline
@ -629,26 +629,6 @@ let g:cpp_class_decl_highlight = 1
let g:cpp_posix_standard = 1
let g:cpp_concepts_highlight = 1
let g:jedi#goto_command = "gt"
let g:jedi#goto_assignments_command = "ga"
let g:jedi#goto_definitions_command = "gd"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "gu"
let g:jedi#completions_command = "<Tab>"
let g:jedi#rename_command = "gr"
let g:jedi#auto_initialization = 1
let g:jedi#auto_vim_configuration = 0
let g:jedi#use_tabs_not_buffers = 1
let g:jedi#popup_on_dot = 1
let g:jedi#popup_select_first = 0
let g:jedi#smart_auto_mappings = 0
let g:jedi#show_call_signatures = "2"
let g:jedi#show_call_signatures_delay = 0
let g:jedi#show_call_signatures_modes = 'i'
let g:jedi#enable_speed_debugging = 0
let g:jedi#completions_enabled = 0
" For SLIMV
let g:lisp_rainbow=1
" For Purescript
@ -662,6 +642,16 @@ let g:fzf_layout = { 'window': 'call CreateCentredFloatingWindow()' }
" Quickr
let g:quickr_cscope_keymaps = 0
" LSP
let g:LanguageClient_autoStart = 0
let g:LanguageClient_loggingFile = expand('$HOME/.cache/LC.log')
let g:LanguageClient_selectionUI = "quickfix"
let g:LanguageClient_serverCommands = {
\ 'haskell': ['ghcide', '--lsp'],
\ 'rust': ['ra_lsp_server'],
\ 'python': ['pyls'],
\ }
" ----------------------------- Functions ------------------------------------
function! NvimGdbNoTKeymaps()
tnoremap <silent> <buffer> <Esc> <C-\><C-n>
@ -700,3 +690,23 @@ function! s:incsearch_config(...) abort
\ 'is_expr': 0
\ }), get(a:, 1, {}))
endfunction
function! SetLspKeybindings()
nnoremap gd :call LanguageClient#textDocument_definition()<CR>
nnoremap gr :call LanguageClient#textDocument_rename()<CR>
nnoremap gx :call LanguageClient#textDocument_references()<CR>
nnoremap K :call LanguageClient#textDocument_hover()<CR>
nnoremap lcs :LanguageClientStart<CR>
nnoremap lch :LanguageClientStop<CR>
nnoremap lcm :call LanguageClient_contextMenu()<CR>
nnoremap ltd :call LanguageClient#textDocument_typeDefinition()<CR>
nnoremap ldi :call LanguageClient#textDocument_implementation()<CR>
nnoremap lcl :call LanguageClient#textDocument_codeLens()<CR>
nnoremap lca :call LanguageClient#textDocument_codeAction()<CR>
nnoremap lrf :call LanguageClient#textDocument_rangeFormatting()<CR>
nnoremap lf :call LanguageClient#textDocument_formatting()<CR>
nnoremap la :call LanguageClient_workspace_applyEdit()<CR>
nnoremap lc :call LanguageClient#textDocument_completion()<CR>
nnoremap ls :call LanguageClient_textDocument_documentSymbol()<CR>
endfunction