nixvim
nixvim copied to clipboard
[BUG] lsp is not working (keymaps, autocommands, ...)
| Field | Description |
|---|---|
| Plugin | lsp |
| Nixpkgs | unstable |
| Home Manager | unstable |
- [x] I have read the FAQ and my bug is not listed there.
Description
Error 1: Keymaps not working
When we are in a Rust piece of code, let's say here:
If I do the keymap action, it doesn't work (and isn't even registered as an option in which-key menu).
However, if I call manually, like: lua vim.lsp.buf.code_action(), it works!
This is true for every lsp action, like open_float diagnostics, go to references, defnition, etc.
Also, this isn't only for Rust (which I setup with Rustaceanvim), but the same behaviour happens in Nix.
Error 2: Lsp getting into some sort of mixup with autocommands
ordinal = ' Error 13:25:34 Error detected while processing LspProgress Autocommands for "*":'
Error 3: Lsp breaking Noice
Error executing lua callback: neovimPackages/start/noice.nvim/lua/noice/lsp/progress.lua:20: attempt to index local 'result' (a nil value)
Minimal, Reproducible Example (MRE)
programs.nixvim = {
plugins.lsp = {
enable = true;
servers = {
# in my case I enabled rustaceanvim, but you could enable rust-analyzer here, as well
nil_ls = {
enable = true;
settings.formatting.command = [ "nixpkgs-fmt" ];
};
};
keymaps = {
diagnostic = {
"[d" = {
action = "goto_prev";
desc = "Go to prev diagnostic";
};
"]d" = {
action = "goto_next";
desc = "Go to next diagnostic";
};
"<leader>ld" = {
action = "open_float";
desc = "Show Line Diagnostics";
};
};
lspBuf = {
"<leader>ca" = {
action = "code_action";
desc = "Code Actions";
};
"<leader>rn" = {
action = "rename";
desc = "Rename Symbol";
};
"<leader>f" = {
action = "format";
desc = "Format";
};
"gd" = {
action = "definition";
desc = "Goto definition (assignment)";
};
"gD" = {
action = "declaration";
desc = "Goto declaration (first occurrence)";
};
"gy" = {
action = "type_definition";
desc = "Goto Type Defition";
};
"gi" = {
action = "implementation";
desc = "Goto Implementation";
};
"<leader>K" = {
action = "hover";
desc = "Hover";
};
"<leader>sh" = {
action = "signature_help";
desc = "Signature Help";
};
"<leader>gr" = {
action = "references";
desc = "References to thing";
};
"<leader>vws" = {
action = "workspace_symbol";
desc = "Workspace symbol";
};
};
};
};
};
I found the fix commit: https://github.com/neovim/neovim/commit/e14e75099883e6904cf3575b612f3820cd122938
I just don't understand why it doesn't already work for me, since nixvim unstable is at https://github.com/neovim/neovim/commit/e3ec974324bd73b63f54503480a4e48d1887f8d9.
i'm unable to reproduce with the provided example (i tried both nix and rust). ensure that nixvim is updated. if using flakes that would be nix flake lock --update-input nixvim
Thanks for the help! The issue was that I was using neovim 0.10, and we were still in 0.9. After nixvim migrated to 0.10 package everything started working again.
I will try to be more mindful in the future, but at the time I didn't understand enough to give more context. So I really appreciate the effort and help!