-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
LSP: default diagnostic highlight groups not created #14034
Comments
I have the same problem: no underline on errors and warning. I do see them when I do So I had to put |
@clason I can't reproduce this (ignore the garish unset color scheme) |
After I set my colorscheme, all the highlight groups are cleared unless I set them (I guess this is expected). I don't know what the best way to do this is, but this is what I've been using: local api = vim.api
function set_hl()
local ns = api.nvim_create_namespace("hl-lsp")
api.nvim_set_hl(ns, "LspDiagnosticsDefaultError", {fg = "#ff5f87"})
api.nvim_set_hl(ns, "LspDiagnosticsDefaultWarning", {fg = "#d78f00"})
api.nvim_set_hl(ns, "LspDiagnosticsDefaultInformation", {fg = "#d78f00"})
api.nvim_set_hl(ns, "LspDiagnosticsDefaultHint", {fg = "#ff5f87", bold = true})
api.nvim_set_hl(ns, "LspDiagnosticsUnderlineError",
{fg = "#ff5f87", sp = "#ff5f87", undercurl = true})
api.nvim_set_hl(ns, "LspDiagnosticsUnderlineWarning",
{fg = "#d78f00", sp = "#d78f00", undercurl = true})
api.nvim_set_hl(ns, "LspReferenceText", {link = "CursorColumn"})
api.nvim_set_hl(ns, "LspReferenceRead", {link = "LspReferenceText"})
api.nvim_set_hl(ns, "LspReferenceWrite", {link = "LspReferenceText"})
api.nvim__set_hl_ns(ns) -- This changed to unstable API
end My highlights recently disappeared which led me to find that
@ruffson Why a |
Oh just because I'm a noob and don't know what I'm doing :) What is a better way? Just replace |
Update: the issue arises when you use a color scheme that contains the line hi clear in the beginning (to allow switching color schemes cleanly). Removing that line (unsurprisingly) sets the default highlight groups correctly. |
So is this an issue with colorscheme that do not define highlighting for lsp highlight groups rather than a neovim issue ? Do you think it could (and should) be solved in neovim or should we open issues in colorscheme repositories stating that neovim is supported ? (after 0.5 release ?) |
I think this is an issue with how (or whether) neovim defines these groups. Note that it's perfectly fine to define these groups yourself after setting a color scheme, so it's not necessarily a defect in color schemes to not define it. (For example, I'm not sad that I'm not getting the underlines -- quite the converse since I prefer not to have them!) It's just not clear (heh) that this way of setting default highlight groups is possible (or if so, reasonable) so that it a) circumvents color schemes that clear all other highlights, b) doesn't overwrite highlight groups if they are set by color scheme or user, and c) doesn't involve messy |
Closing as duplicate of #12579 (🤦 for not finding this when creating this issue) |
Background: Questions on Gitter about "how do I enable underline for diagnostics", which should be enabled by default.
Tracing this back, it seems that
vim.lsp.diagnostic._define_default_signs_and_highlights
doesn't actually define these groups during startup. (Before refuting this, make sure these highlight groups aren't actually defined by your colorscheme as well.)Tracing further, the issue is that the
highlight
inside thisvim.cmd
never gets executed:neovim/runtime/lua/vim/highlight.lua
Line 12 in c1fbc2d
Which is weird, since
vim.cmd
byprint
;string.format(...)
byecho 'foo'
;:lua vim.lsp.diagnostic._define_default_signs_and_highlights()
while neovim is runningall show the expected behavior.
The text was updated successfully, but these errors were encountered: