mirror of
https://github.com/oxalica/nil.git
synced 2025-12-23 09:19:49 +00:00
Add config for vim-lsp
This commit is contained in:
parent
31b714f3da
commit
d2a22b8460
4 changed files with 64 additions and 1 deletions
17
README.md
17
README.md
|
|
@ -86,6 +86,23 @@ Merge this setting into your `coc-settings.json`, which can be opened by `:CocCo
|
|||
|
||||
See also [the example config for testing](dev/vim-coc.nix).
|
||||
|
||||
### Vim with [`vim-lsp`]
|
||||
|
||||
[`vim-lsp`]: https://github.com/prabirshrestha/vim-lsp
|
||||
|
||||
Add the following code to your `vimrc` to register the LSP server.
|
||||
Thanks @mitchmindtree
|
||||
|
||||
```vim
|
||||
if executable('nil')
|
||||
autocmd User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'nil',
|
||||
\ 'cmd': {server_info->['nil']},
|
||||
\ 'whitelist': ['nix'],
|
||||
\ })
|
||||
endif
|
||||
```
|
||||
|
||||
### Emacs with [`eglot`]
|
||||
|
||||
[`eglot`]: https://github.com/joaotavora/eglot
|
||||
|
|
|
|||
45
dev/vim-lsp.nix
Normal file
45
dev/vim-lsp.nix
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
{ pkgs ? import <nixpkgs> { } }:
|
||||
pkgs.vim_configurable.customize {
|
||||
name = "vim-lsp";
|
||||
|
||||
vimrcConfig = {
|
||||
packages.myVimPackage.start = with pkgs.vimPlugins; [
|
||||
vim-nix # File type and syntax highlighting.
|
||||
vim-lsp
|
||||
];
|
||||
|
||||
# vim
|
||||
customRC = ''
|
||||
source ${./vimrc.vim}
|
||||
|
||||
au BufRead,BufNewFile *.nix setf nix
|
||||
|
||||
autocmd User lsp_setup call lsp#register_server({
|
||||
\ 'name': 'nil',
|
||||
\ 'cmd': {server_info->[$NIL_PATH]},
|
||||
\ 'whitelist': ['nix'],
|
||||
\ })
|
||||
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
|
||||
|
||||
function! s:on_lsp_buffer_enabled()
|
||||
setlocal omnifunc=lsp#complete
|
||||
setlocal tagfunc=lsp#tagfunc
|
||||
|
||||
nmap <buffer> gd <Plug>(lsp-definition)
|
||||
nmap <buffer> gr <Plug>(lsp-references)
|
||||
nmap <buffer> gs <Plug>(lsp-document-symbol-search)
|
||||
nmap <buffer> gS <Plug>(lsp-workspace-symbol-search)
|
||||
nmap <buffer> gy <Plug>(lsp-type-definition)
|
||||
nmap <buffer> <Space>r <Plug>(lsp-rename)
|
||||
nmap <buffer> [g <Plug>(lsp-previous-diagnostic)
|
||||
nmap <buffer> ]g <Plug>(lsp-next-diagnostic)
|
||||
nmap <buffer> <Space><Space> <Plug>(lsp-hover)
|
||||
nnoremap <buffer> <expr><C-f> lsp#scroll(+4)
|
||||
nnoremap <buffer> <expr><C-d> lsp#scroll(-4)
|
||||
|
||||
let g:lsp_format_sync_timeout = 1000
|
||||
autocmd BufWritePre *.nix call execute('LspDocumentFormatSync')
|
||||
endfunction
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
@ -71,8 +71,9 @@
|
|||
jq
|
||||
pre-commit
|
||||
nixpkgs-fmt
|
||||
(import ./dev/neovim-lsp.nix { inherit pkgs; })
|
||||
(import ./dev/nvim-lsp.nix { inherit pkgs; })
|
||||
(import ./dev/vim-coc.nix { inherit pkgs; })
|
||||
(import ./dev/vim-lsp.nix { inherit pkgs; })
|
||||
] ++ lib.optionals (lib.meta.availableOn stdenv.hostPlatform vscodium) [
|
||||
(import ./dev/vscodium.nix { inherit pkgs; })
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue