Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] lsp is not working (keymaps, autocommands, ...) #1505

Open
1 task done
nicolasauler opened this issue May 9, 2024 · 2 comments
Open
1 task done

[BUG] lsp is not working (keymaps, autocommands, ...) #1505

nicolasauler opened this issue May 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@nicolasauler
Copy link

nicolasauler commented May 9, 2024

Field Description
Plugin lsp
Nixpkgs unstable
Home Manager unstable
  • 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:
image

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";
        };
      };
    };
  };
};
@nicolasauler nicolasauler added the bug Something isn't working label May 9, 2024
@nicolasauler nicolasauler changed the title [BUG] lsp's keymaps are not working [BUG] lsp is not working (keymaps, autocommands, ...) May 14, 2024
@nicolasauler
Copy link
Author

nicolasauler commented May 14, 2024

I found the fix commit:
neovim/neovim@e14e750

I just don't understand why it doesn't already work for me, since nixvim unstable is at neovim/neovim@e3ec974.

@4lxs
Copy link
Contributor

4lxs commented May 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants