rust-tools.nvim icon indicating copy to clipboard operation
rust-tools.nvim copied to clipboard

duplicate diagnostic item error

Open dvic opened this issue 2 years ago • 2 comments

Does anyone encounter the following issue when opening a file from the standard library:

I asked also on rust-analyzer https://github.com/rust-lang/rust-analyzer/discussions/15041 and someone suggested that it might be because the std lib is loaded as a workspace through the lsp.

I'm using lazyvim with the following setup:

return {
  {
    "neovim/nvim-lspconfig",
    opts = {
      servers = {
        rust_analyzer = {},
      },
    },
    setup = {
      rust_analyzer = function(_, _)
        return true
      end,
    },
  },
  {
    "simrat39/rust-tools.nvim",
    dependencies = "neovim/nvim-lspconfig",
    config = function()
      local rt = require("rust-tools")

      rt.setup({
        server = {
          on_attach = require("lazyvim.util").on_attach(function(_, bufnr)
            -- Hover actions
            vim.keymap.set("n", "K", rt.hover_actions.hover_actions, { buffer = bufnr, desc = "Hover" })
            -- Code action groups
            vim.keymap.set(
              "n",
              "<Leader>ca",
              rt.code_action_group.code_action_group,
              { buffer = bufnr, desc = "Code Action" }
            )
          end),
        },
      })
    end,
  },
}

dvic avatar Jun 21 '23 06:06 dvic

I think I found a clue in the nvim-lspconfig repo: https://github.com/neovim/nvim-lspconfig/blob/5da57456597ac2f25f20d6ecfae7b7c9cbd01fc6/lua/lspconfig/server_configurations/rust_analyzer.lua#L41-L44

It looks like there is custom logic for reusing an instance...

dvic avatar Jun 29 '23 17:06 dvic

I have the same issue, is there any solution? set reuse_active to avoid booting the second instance?

DriedYellowPeach avatar Nov 12 '23 04:11 DriedYellowPeach