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

Diagnostic Icons #52

Closed
kaykhancheckpoint opened this issue Jun 18, 2021 · 14 comments
Closed

Diagnostic Icons #52

kaykhancheckpoint opened this issue Jun 18, 2021 · 14 comments

Comments

@kaykhancheckpoint
Copy link

Hi, how do i get the diagnostic icons in the gutter?

image

Plug 'kyazdani42/nvim-web-devicons'
Plug 'folke/trouble.nvim'
@folke
Copy link
Owner

folke commented Jun 18, 2021

Until my lsp.config PR lands, you can use the code below:

local signs = { Error = "", Warning = "", Hint = "", Information = "" }
for type, icon in pairs(signs) do
  local hl = "LspDiagnosticsSign" .. type
  vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end

@kaykhancheckpoint
Copy link
Author

Added this after my plugins

lua << EOF
local signs = { Error = " ", Warning = " ", Hint = " ", Information = " " }
for type, icon in pairs(signs) do
  local hl = "LspDiagnosticsSign" .. type
  vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
EOF

It did not work

@kaykhancheckpoint
Copy link
Author

kaykhancheckpoint commented Jun 18, 2021

@folke Can you tihnk of anything else i might be missing?

udpate:

I found i can see the icons for one file but not the other, its quite strange.

@folke
Copy link
Owner

folke commented Jun 20, 2021

@kaykhancheckpoint are you using LSP saga by any chance? If so don't put in the code I posted and configure the symbols through saga

@folke folke reopened this Jun 20, 2021
@folke folke closed this as completed Jul 16, 2021
@euoia
Copy link

euoia commented Aug 26, 2021

At least for me, I had to add the snippet from #52 (comment) to my config, otherwise errors in the gutter would show with "E":

:echo sign_getdefined("LspDiagnosticsSignError")
[{'name': 'LspDiagnosticsSignError', 'numhl': '', 'texthl': 'LspDiagnosticsSignError', 'linehl': '', 'text': 'E '}]

Is trouble.nvim supposed to set the signs automatically?

@Johan-Palacios
Copy link

In my case this not works

@mattleong
Copy link

mattleong commented Oct 10, 2021

At least for me, I had to add the snippet from #52 (comment) to my config, otherwise errors in the gutter would show with "E":

:echo sign_getdefined("LspDiagnosticsSignError")
[{'name': 'LspDiagnosticsSignError', 'numhl': '', 'texthl': 'LspDiagnosticsSignError', 'linehl': '', 'text': 'E '}]

Is trouble.nvim supposed to set the signs automatically?

Same for me. I'm wondering the same myself

@mrshmllow
Copy link

I cant seem to change it no matter what i do

@drover25
Copy link

FWIW, I was having the same issue. Changing the sign from LspDiagnosticsSign .. type to DiagnosticSign .. type resolved the issue for me.

local signs = {
    Error = " ",
    Warning = " ",
    Hint = " ",
    Information = " "
}

for type, icon in pairs(signs) do
    local hl = "DiagnosticSign" .. type
    vim.fn.sign_define(hl, {text = icon, texthl = hl, numhl = hl})
end

@folke
Copy link
Owner

folke commented Oct 23, 2021

@coldis yep, exactly. For 0.6 there were a bunch of changes to diagnostics

@Johan-Palacios
Copy link

Johan-Palacios commented Oct 24, 2021

This works for me
vim.cmd [[ sign define DiagnosticSignError text= linehl= texthl=DiagnosticSignError numhl= sign define DiagnosticSignWarn text= linehl= texthl=DiagnosticSignWarn numhl= sign define DiagnosticSignInfo text= linehl= texthl=DiagnosticSignInfo numhl= sign define DiagnosticSignHint text=💡 linehl= texthl=DiagnosticSignHint numhl= ]]

image

@rd3ka
Copy link

rd3ka commented Nov 10, 2021

If you use the bleeding edge dev build of nvim,
local hl = "DiagnosticSign" .. type works
For 0.51 build local hl = "LspDiagnosticsSign" .. type works

@omertuc
Copy link

omertuc commented Dec 4, 2021

FWIW, I was having the same issue. Changing the sign from LspDiagnosticsSign .. type to DiagnosticSign .. type resolved the issue for me.

Thanks, that worked for me. I want to stress for people who try this:
It's Diagnostic not Diagnostics, it's not just the Lsp prefix that got removed

@Yutsuten
Copy link

Yutsuten commented Dec 8, 2021

Warning and Information has been renamed too.
Here's the full difference between neovim 0.5.1 and 0.6.0:

 local signs = {
   Error = "E",
-  Warning = "W",
+  Warn = "W",
   Hint = "H",
-  Information = "I"
+  Info = "I",
 }
+
 for type, icon in pairs(signs) do
-  local hl = "LspDiagnosticsSign" .. type
+  local hl = "DiagnosticSign" .. type
   vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
 end

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

No branches or pull requests

10 participants