All Projects → nix-community → Rnix Lsp

nix-community / Rnix Lsp

Licence: mit
WIP Language Server for Nix! [[email protected]]

Programming Languages

rust
11053 projects

rnix-lsp Crates.io

A syntax-checking language server using rnix.

  • [x] Syntax-checking diagnostics
  • [x] Basic completion
  • [x] Basic renaming
  • [x] Basic goto definition
  • [x] Expand selection proposal
  • [x] Formatting using nixpkgs-fmt

This is beta-level quality at best - I didn't expect maintaining a language server when writing rnix, the goal was that others would flock around the parser and write a bunch of editor tooling :)

Breakages are expected. No semver compatibility before 1.x.y.

Turn on logging with RUST_LOG=trace, and redirect stderr to a file.

bash -c "env RUST_LOG=trace rnix-lsp 2> /tmp/rnix-lsp.log"

Install

$ nix-env -i -f https://github.com/nix-community/rnix-lsp/archive/master.tar.gz

Integrate with your editor

These instructions are not fully tested - see issue #3. Please raise an issue and/or send a PR if a config below didn't work out of the box.

Vim/Neovim

coc.nvim

{
  "languageserver": {
    "nix": {
      "command": "rnix-lsp",
      "filetypes": [
        "nix"
      ]
    }
  }
}

LanguageClient-neovim

let g:LanguageClient_serverCommands = {
    \ 'nix': ['rnix-lsp']
\ }

vim-lsp

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

Emacs

lsp-mode

(add-to-list 'lsp-language-id-configuration '(nix-mode . "nix"))
(lsp-register-client
 (make-lsp-client :new-connection (lsp-stdio-connection '("rnix-lsp"))
                  :major-modes '(nix-mode)
                  :server-id 'nix))

eglot

(add-to-list 'eglot-server-programs '(nix-mode . ("rnix-lsp")))

Kakoune

kak-lsp

[language.nix]
filetypes = ["nix"]
command = "rnix-lsp"

VSCode

vscode-nix-ide

{
    "nix.enableLanguageServer": true
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].