diff --git a/autoload/SpaceVim/layers/lang/nix.vim b/autoload/SpaceVim/layers/lang/nix.vim index a84941950..8d8efe89d 100644 --- a/autoload/SpaceVim/layers/lang/nix.vim +++ b/autoload/SpaceVim/layers/lang/nix.vim @@ -10,8 +10,8 @@ " @section lang#nix, layers-lang-nix " @parentsection layers " @subsection Intro -" The lang#nix layer provides syntax highlighting for the Nix -" expression language. +" The lang#nix layer provides syntax highlighting and basic LSP support for +" the Nix expression language. function! SpaceVim#layers#lang#nix#plugins() abort let plugins = [] @@ -20,11 +20,27 @@ function! SpaceVim#layers#lang#nix#plugins() abort endfunction function! SpaceVim#layers#lang#nix#config() abort + call SpaceVim#mapping#space#regesit_lang_mappings('nix', function('s:language_specified_mappings')) endfunction +function! s:language_specified_mappings() abort + if SpaceVim#layers#lsp#check_filetype('nix') + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'r'], + \ 'call SpaceVim#lsp#rename()', 'rename', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 's'], + \ 'call SpaceVim#lsp#show_line_diagnostics()', 'show-line-diagnostics', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], + \ 'call SpaceVim#lsp#go_to_def()', 'go-to-definition', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'n'], + \ 'call SpaceVim#lsp#diagnostic_goto_next()', 'next-diagnostic', 1) + call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'p'], + \ 'call SpaceVim#lsp#diagnostic_goto_prev()', 'previous-diagnostic', 1) + endif +endfunction function! SpaceVim#layers#lang#nix#health() abort call SpaceVim#layers#lang#nix#plugins() call SpaceVim#layers#lang#nix#config() return 1 endfunction + diff --git a/docs/layers/lang/nix.md b/docs/layers/lang/nix.md index 4f96742ca..fdc726c6e 100644 --- a/docs/layers/lang/nix.md +++ b/docs/layers/lang/nix.md @@ -10,7 +10,6 @@ description: "This layer adds Nix language support to SpaceVim." - [Description](#description) - [Features](#features) - [Install](#install) -- [Key bindings](#key-bindings) @@ -21,6 +20,9 @@ This layer adds [Nix](https://nixos.org/nix/manual/) language support to SpaceVi ## Features - syntax highlighting +- symbol renaming (LSP) +- go to definition (LSP) +- syntax checking (LSP) ## Install