Skip to content

Commit

Permalink
mixins::vim: add rnix-lsp 0.2.0 to vim configuration
Browse files Browse the repository at this point in the history
This integrates rnix-lsp into my vim setup, it installs it and makes sure that the vimrc will use it via the vim-lsp plugin
  • Loading branch information
MatthewCroughan committed Jul 13, 2021
1 parent e3b324f commit e5c69d7
Showing 1 changed file with 59 additions and 2 deletions.
61 changes: 59 additions & 2 deletions mixins/vim.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,80 @@

{ config, pkgs, ... }:

let
overlay = self: super: {
rnix-lsp_0_2_0 = with super; rustPlatform.buildRustPackage {
pname = "rnix-lsp-unstable";
version = "2021-07-05";
src = fetchFromGitHub {
owner = "ma27";
repo = "rnix-lsp";
rev = "cbd13a0f9f7c066a545a30c63fcb7e225a069cf3";
sha256 = "sha256-CwMa2n53+ZzMoCY1c795iyBMO9W9myByYfjfOGEFim0=";
};
cargoSha256 = "sha256-uKncKlguo78t5jcP17uE2/Ru2tlEMFcxX0oB8l8pYmI=";
};
};
in
{
nixpkgs.overlays = [ overlay ];

nixpkgs.config.vim.ftNix = false;
environment.systemPackages = with pkgs; [
pkgs.rnix-lsp_0_2_0
(vim_configurable.customize {
vimrcConfig.customRC = ''
set mouse-=a
set tw=80
set fo+=t
set wrap linebreak
syntax on
"" filetype plugin indent on
filetype plugin on
set omnifunc=syntaxcomplete#Complete
set backspace=indent,eol,start
if executable('rnix-lsp')
au User lsp_setup call lsp#register_server({
\ 'name': 'rnix-lsp',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'rnix-lsp']},
\ 'whitelist': ['nix'],
\ })
endif
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=no
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
let g:lsp_format_sync_timeout = 1000
autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync')
" refer to doc to add more commands
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
'';
name = "vim";
vimrcConfig.packages.vim =
with pkgs.vimPlugins; {
start = [ vim-nix vim-surround ];
start = [ vim-nix vim-surround vim-lsp ];
};
}
)
Expand Down

0 comments on commit e5c69d7

Please sign in to comment.