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: use_diagnostic_signs = true no longer works due to a recent Neovim change (0.10+) #369

Closed
3 tasks done
xfzv opened this issue Dec 16, 2023 · 12 comments · Fixed by #437
Closed
3 tasks done

bug: use_diagnostic_signs = true no longer works due to a recent Neovim change (0.10+) #369

xfzv opened this issue Dec 16, 2023 · 12 comments · Fixed by #437
Labels
bug Something isn't working

Comments

@xfzv
Copy link

xfzv commented Dec 16, 2023

Did you check docs and existing issues?

  • I have read all the trouble.nvim docs
  • I have searched the existing issues of trouble.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0-dev-1856+gf4f7e2946-dirty

Operating system/version

Gentoo Linux

Describe the bug

Due to a recent change in Neovim (neovim/neovim#26193 I believe), diagnostics signs are now configured differently.

As a result, trouble displays "E" ; "W" ; "H" ; "I" letters instead of respective configured signs, despite using use_diagnostic_signs = true.

Steps To Reproduce

  • trouble config:
return {
  "folke/trouble.nvim",
  cmd = { "Trouble", "TroubleToggle" },
  dependencies = "nvim-tree/nvim-web-devicons",
  opts = {
    use_diagnostic_signs = true, -- Use the signs already defined in LSP
  },
}
  • neovim/nvim-lspconfig config:
return {
  "neovim/nvim-lspconfig",
  event = { "BufReadPre", "BufNewFile" },
  config = function()
    vim.diagnostic.config({
      signs = {
        text = {
          [vim.diagnostic.severity.ERROR] = "",
          [vim.diagnostic.severity.WARN] = "",
          [vim.diagnostic.severity.INFO] = "",
          [vim.diagnostic.severity.HINT] = "",
        },
      },
    })
  end,
}
  1. Using Neovim nightly, trigger a diagnostic in any file
  2. The diagnostic sign is correctly displayed in the SignColumn
  3. Open trouble with :Trouble
  4. The default letter is displayed in trouble instead of the configured sign:
    image

Expected Behavior

trouble displays signs instead of letters

Repro

No response

@xfzv xfzv added the bug Something isn't working label Dec 16, 2023
@gpanders
Copy link

Note that with neovim/neovim#26618, neovim/neovim#26193 is no longer a breaking change. Plugins should still migrate to the new configuration format, but there is no immediate need to do so.

@suliatis
Copy link

I have a neovim config only using the new way to define diagnostic signs, so I decided to fix this by myself. You can see my pr above. Feel free to checkout and give your feedback.

@xfzv
Copy link
Author

xfzv commented Mar 24, 2024

I have a neovim config only using the new way to define diagnostic signs, so I decided to fix this by myself. You can see my pr above. Feel free to checkout and give your feedback.

Thanks for the PR. I've just tried it, works fine here:

image

% nvim --version
NVIM v0.10.0-dev-2678+g3d9c028a4-dirty

folke added a commit that referenced this issue Mar 29, 2024
@folke
Copy link
Owner

folke commented Mar 29, 2024

Development on the main branch is EOL.

Trouble has been rewritten and will be merged in main soon.

This issue/feature either no longer exists or has been implemented on dev.

For more info, see https://github.com/folke/trouble.nvim/tree/dev

@folke folke closed this as completed Mar 29, 2024
@fgr1986
Copy link

fgr1986 commented May 16, 2024

Dear @folke is it possible that it is not yet enabled on dev branch? (I still see the E/W letters instead of icons).

Thanks

@folke
Copy link
Owner

folke commented May 16, 2024

Trouble now always uses the configured Neovim diagnostic signs.

@fgr1986
Copy link

fgr1986 commented May 16, 2024

I configured neovim diagnostics, but somehow they are not picked up (just moved to dev today)
image

@folke
Copy link
Owner

folke commented May 16, 2024

Did you use vim.diagnostic.config? And not sign_define? sign_define is deprecated

@fgr1986
Copy link

fgr1986 commented May 16, 2024

No, could find that in the dev docs.
Could you point me there?

In the lsp handlers I have
vim.diagnostic.config(lsp.diagnostic)

@folke
Copy link
Owner

folke commented May 16, 2024

Can you show me the exact table you pass to diagnostics config?

@fgr1986
Copy link

fgr1986 commented May 16, 2024

Interestingly, everything works on
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1713773202,

but it fails on
NVIM v0.10.0-dev Build type: RelWithDebInfo, LuaJIT 2.1.0-beta3.

The table you asked for:

local M = {}

function M.setup()
  -- LSP handlers configuration
  local lsp = {
    float = {
      focusable = true,
      style = "minimal",
      border = "rounded",
    },
    diagnostic = {
      -- virtual_text = true,
      virtual_text = { spacing = 4, prefix = "●" },
      underline = true,
      update_in_insert = false,
      severity_sort = true,
      float = {
        focusable = true,
        style = "minimal",
        border = "rounded",
      },
    },
  }

  -- Diagnostic signs
  local diagnostic_signs = {
    {
      name = "DiagnosticSignError",
      text = ""
    },
    {
      name = "DiagnosticSignWarn",
      -- text = ""
      text = ""
    },
    {
      name = "DiagnosticSignHint",
      text = ""
    },
    {
      name = "DiagnosticSignInfo",
      text = ""
    },
  }
  for _, sign in ipairs(diagnostic_signs) do
    vim.fn.sign_define(sign.name, { texthl = sign.name, text = sign.text, numhl = sign.name })
  end

  -- Diagnostic configuration
  vim.diagnostic.config(lsp.diagnostic)

  -- Hover configuration
  vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lsp.float)

  -- Signature help configuration
  vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lsp.float)
end

return M

@folke
Copy link
Owner

folke commented May 16, 2024

like I said, on 0.10, you need to pass signs as an option to vim.diagnostic.config. Please check the docs.

So no sign_define

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
5 participants