aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/util.lua
diff options
context:
space:
mode:
authorfrancisco souza <108725+fsouza@users.noreply.github.com>2020-06-18 08:04:49 -0400
committerGitHub <noreply@github.com>2020-06-18 08:04:49 -0400
commit70d4b31b834395fe36f4886e43b63fd4dc62ded1 (patch)
tree3f97e447c549b59a771e73a0cfa36a8d5dd52c40 /runtime/lua/vim/lsp/util.lua
parent25aa2969f25a1a6554e7ecd48692c60852d74101 (diff)
downloadrneovim-70d4b31b834395fe36f4886e43b63fd4dc62ded1.tar.gz
rneovim-70d4b31b834395fe36f4886e43b63fd4dc62ded1.tar.bz2
rneovim-70d4b31b834395fe36f4886e43b63fd4dc62ded1.zip
lsp: Add new highlight groups used in show_line_diagnostics (#12473)
* lsp: support custom hl groups in show_line_diagnostics Closes #12472. * runtime: add docs for the new lsp highlight groups Co-authored-by: francisco souza <fsouza@users.noreply.github.com>
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r--runtime/lua/vim/lsp/util.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index 4c3c4fa6cb..71ca1048e1 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -859,6 +859,8 @@ do
local severity_highlights = {}
+ local severity_floating_highlights = {}
+
local default_severity_highlight = {
[protocol.DiagnosticSeverity.Error] = { guifg = "Red" };
[protocol.DiagnosticSeverity.Warning] = { guifg = "Orange" };
@@ -870,6 +872,7 @@ do
for severity, hi_info in pairs(default_severity_highlight) do
local severity_name = protocol.DiagnosticSeverity[severity]
local highlight_name = "LspDiagnostics"..severity_name
+ local floating_highlight_name = highlight_name.."Floating"
-- Try to fill in the foreground color with a sane default.
local cmd_parts = {"highlight", "default", highlight_name}
for k, v in pairs(hi_info) do
@@ -877,7 +880,9 @@ do
end
api.nvim_command(table.concat(cmd_parts, ' '))
api.nvim_command('highlight link ' .. highlight_name .. 'Sign ' .. highlight_name)
+ api.nvim_command('highlight link ' .. highlight_name .. 'Floating ' .. highlight_name)
severity_highlights[severity] = highlight_name
+ severity_floating_highlights[severity] = floating_highlight_name
end
function M.buf_clear_diagnostics(bufnr)
@@ -926,7 +931,7 @@ do
-- TODO(ashkan) make format configurable?
local prefix = string.format("%d. ", i)
- local hiname = severity_highlights[diagnostic.severity]
+ local hiname = severity_floating_highlights[diagnostic.severity]
assert(hiname, 'unknown severity: ' .. tostring(diagnostic.severity))
local message_lines = split_lines(diagnostic.message)
table.insert(lines, prefix..message_lines[1])