mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
LSP: enable using different highlighting rules for LSP signs (#12176)
This commit creates 4 new highlight groups: - LspDiagnosticsErrorSign - LspDiagnosticsWarningSign - LspDiagnosticsInformationSign - LspDiagnosticsHintSign These highlight groups are linked to their corresponding LspDiagnostics highlight groups by default. This lets users choose a different color for their sign columns and virtualtext diagnostics.
This commit is contained in:
@@ -164,12 +164,20 @@ LSP HIGHLIGHT *lsp-highlight*
|
|||||||
|
|
||||||
*hl-LspDiagnosticsError*
|
*hl-LspDiagnosticsError*
|
||||||
LspDiagnosticsError used for "Error" diagnostic virtual text
|
LspDiagnosticsError used for "Error" diagnostic virtual text
|
||||||
|
*hl-LspDiagnosticsErrorSign*
|
||||||
|
LspDiagnosticsErrorSign used for "Error" diagnostic signs in sign column
|
||||||
*hl-LspDiagnosticsWarning*
|
*hl-LspDiagnosticsWarning*
|
||||||
LspDiagnosticsWarning used for "Warning" diagnostic virtual text
|
LspDiagnosticsWarning used for "Warning" diagnostic virtual text
|
||||||
|
*hl-LspDiagnosticsWarningSign*
|
||||||
|
LspDiagnosticsWarningSign used for "Warning" diagnostic signs in sign column
|
||||||
*hl-LspDiagnosticsInformation*
|
*hl-LspDiagnosticsInformation*
|
||||||
LspDiagnosticInformation used for "Information" diagnostic virtual text
|
LspDiagnosticInformation used for "Information" diagnostic virtual text
|
||||||
|
*hl-LspDiagnosticsInformationSign*
|
||||||
|
LspDiagnosticInformationSign used for "Information" signs in sign column
|
||||||
*hl-LspDiagnosticsHint*
|
*hl-LspDiagnosticsHint*
|
||||||
LspDiagnosticHint used for "Hint" diagnostic virtual text
|
LspDiagnosticHint used for "Hint" diagnostic virtual text
|
||||||
|
*hl-LspDiagnosticsHintSign*
|
||||||
|
LspDiagnosticHintSign used for "Hint" diagnostic signs in sign column
|
||||||
*hl-LspReferenceText*
|
*hl-LspReferenceText*
|
||||||
LspReferenceText used for highlighting "text" references
|
LspReferenceText used for highlighting "text" references
|
||||||
*hl-LspReferenceRead*
|
*hl-LspReferenceRead*
|
||||||
|
@@ -1024,10 +1024,10 @@ do
|
|||||||
vim.fn.sign_define(name, properties)
|
vim.fn.sign_define(name, properties)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
define_default_sign('LspDiagnosticsErrorSign', {text='E', texthl='LspDiagnosticsError', linehl='', numhl=''})
|
define_default_sign('LspDiagnosticsErrorSign', {text='E', texthl='LspDiagnosticsErrorSign', linehl='', numhl=''})
|
||||||
define_default_sign('LspDiagnosticsWarningSign', {text='W', texthl='LspDiagnosticsWarning', linehl='', numhl=''})
|
define_default_sign('LspDiagnosticsWarningSign', {text='W', texthl='LspDiagnosticsWarningSign', linehl='', numhl=''})
|
||||||
define_default_sign('LspDiagnosticsInformationSign', {text='I', texthl='LspDiagnosticsInformation', linehl='', numhl=''})
|
define_default_sign('LspDiagnosticsInformationSign', {text='I', texthl='LspDiagnosticsInformationSign', linehl='', numhl=''})
|
||||||
define_default_sign('LspDiagnosticsHintSign', {text='H', texthl='LspDiagnosticsHint', linehl='', numhl=''})
|
define_default_sign('LspDiagnosticsHintSign', {text='H', texthl='LspDiagnosticsHintSign', linehl='', numhl=''})
|
||||||
end
|
end
|
||||||
|
|
||||||
return lsp
|
return lsp
|
||||||
|
@@ -672,6 +672,7 @@ do
|
|||||||
table.insert(cmd_parts, k.."="..v)
|
table.insert(cmd_parts, k.."="..v)
|
||||||
end
|
end
|
||||||
api.nvim_command(table.concat(cmd_parts, ' '))
|
api.nvim_command(table.concat(cmd_parts, ' '))
|
||||||
|
api.nvim_command('highlight link ' .. highlight_name .. 'Sign ' .. highlight_name)
|
||||||
severity_highlights[severity] = highlight_name
|
severity_highlights[severity] = highlight_name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@@ -754,14 +754,18 @@ describe('LSP', function()
|
|||||||
|
|
||||||
it('highlight groups', function()
|
it('highlight groups', function()
|
||||||
eq({'LspDiagnosticsError',
|
eq({'LspDiagnosticsError',
|
||||||
|
'LspDiagnosticsErrorSign',
|
||||||
'LspDiagnosticsHint',
|
'LspDiagnosticsHint',
|
||||||
|
'LspDiagnosticsHintSign',
|
||||||
'LspDiagnosticsInformation',
|
'LspDiagnosticsInformation',
|
||||||
|
'LspDiagnosticsInformationSign',
|
||||||
'LspDiagnosticsUnderline',
|
'LspDiagnosticsUnderline',
|
||||||
'LspDiagnosticsUnderlineError',
|
'LspDiagnosticsUnderlineError',
|
||||||
'LspDiagnosticsUnderlineHint',
|
'LspDiagnosticsUnderlineHint',
|
||||||
'LspDiagnosticsUnderlineInformation',
|
'LspDiagnosticsUnderlineInformation',
|
||||||
'LspDiagnosticsUnderlineWarning',
|
'LspDiagnosticsUnderlineWarning',
|
||||||
'LspDiagnosticsWarning',
|
'LspDiagnosticsWarning',
|
||||||
|
'LspDiagnosticsWarningSign',
|
||||||
},
|
},
|
||||||
exec_lua([[require'vim.lsp'; return vim.fn.getcompletion('Lsp', 'highlight')]]))
|
exec_lua([[require'vim.lsp'; return vim.fn.getcompletion('Lsp', 'highlight')]]))
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user