# Largely copied from a great blog post: # https://sharksforarms.dev/posts/neovim-rust/ { pkgs, lib, config, ... }: with lib; { vim.opt = { completeopt = "menuone,noinsert,noselect"; # Set updatetime for CursorHold # 300ms of no cursor movement to trigger CursorHold updatetime = 300; # have a fixed column for the diagnostics to appear in # this removes the jitter when warnings/errors flow in signcolumn = "yes"; }; vim.keybindings.keybindings-shortened = { "K" = {command = "lua vim.lsp.buf.hover()";}; }; vim.g.lightline.component_expand.lsp_status = "LspStatus"; vim.g.lightline.active.right = mkAfter [["lsp_status"]]; # https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/2 output.makeWrapper = "--set RUST_SRC_PATH ${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; output.config_file = '' set shortmess+=c lua < 0') return luaeval("require('lsp-status').status()") endif return "" endfunction autocmd InsertLeave,BufEnter,BufWritePost * call lightline#update() autocmd User LspDiagnosticsChanged call lightline#update() " Show diagnostic popup on cursor hold autocmd CursorHold * lua vim.diagnostic.open_float() " Enable type inlay hints " FIXME: https://github.com/nvim-lua/lsp_extensions.nvim/issues/30 " autocmd CursorMoved,InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost * " \ lua require'lsp_extensions'.inlay_hints{ prefix = "", highlight = "Comment" } ''; output.plugins = with pkgs.vimPlugins; [ nvim-lspconfig lsp_extensions-nvim lsp-status-nvim dhall-vim ]; output.path.path = with pkgs; [ # Rust cargo rustc rust-analyzer # Nix rnix-lsp # C++ clang-tools # Dhall dhall-lsp-server # Python (writeScriptBin "pyright-langserver" '' # pyright has a symlinked `./bin` which breaks Nix's `symlinkJoin` # This wrapper script fixes that. ${pyright}/bin/pyright-langserver $@ '') ]; }