Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

duplicate diagnostic item error #394

Open
dvic opened this issue Jun 21, 2023 · 2 comments
Open

duplicate diagnostic item error #394

dvic opened this issue Jun 21, 2023 · 2 comments

Comments

@dvic
Copy link

dvic commented Jun 21, 2023

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

I asked also on rust-analyzer rust-lang/rust-analyzer#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
Copy link
Author

dvic commented Jun 29, 2023

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...

@DriedYellowPeach
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants