feat(neovim): add initial nvim-lsp config (WIP)

This commit is contained in:
Felix Schröter 2020-03-21 17:03:23 +01:00
parent d2db7cd863
commit 4a98a06bed
No known key found for this signature in database
GPG key ID: A12D7C9D2FD34458
2 changed files with 48 additions and 2 deletions

43
home/editors/lsp.vim Normal file
View file

@ -0,0 +1,43 @@
" autocomplete config
set completeopt=menu,preview,menuone,noinsert
set omnifunc=v:lua.vim.lsp.omnifunc
let g:deoplete#enable_at_startup = 1
" let g:deoplete#auto_refresh_delay = 10 " TODO disable it again if it doesn't make a difference
let g:deoplete#smart_case = 1
let g:deoplete#min_pattern_length = 1
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> deoplete#manual_complete()
"Autocomplete and cycle from top-to-bottom of suggestions using <Tab>.
inoremap <expr><TAB> pumvisible() ? "\<c-n>" : "\<TAB>"
" <TAB>: completion.
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#manual_complete()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" these will likely interfere with coc.vim maps
nnoremap <silent> gd <cmd>lua vim.lsp.buf.declaration()<CR>
nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
" nvim-lsp config
packloadall " https://github.com/neovim/neovim/issues/11407
lua << EOF
local nvim_lsp = require'nvim_lsp'
nvim_lsp.tsserver.setup{}
EOF

View file

@ -15,7 +15,7 @@ let
};
nvim-lsp = buildVimPluginFrom2Nix {
pname = "nvim-lsp";
version = "master";
version = "2020-03-17";
src = pkgs.fetchFromGitHub {
owner = "neovim";
repo = "nvim-lsp";
@ -71,7 +71,9 @@ in
camelcasemotion
argtextobj-vim
# nvim-lsp # nixos-rebuild currently fails
nvim-lsp
deoplete-nvim
deoplete-lsp
vim-orgmode
vim-nix
@ -98,6 +100,7 @@ in
omnisharp-vim
];
extraConfig = with builtins; readFile ./init.vim + readFile ./coc.vim;
# extraConfig = with builtins; readFile ./init.vim + readFile ./lsp.vim;
withNodeJs = true;
};