mirror of
https://github.com/neovim/neovim.git
synced 2025-12-12 01:22:41 +00:00
@@ -977,12 +977,12 @@ buf_diagnostics_virtual_text({bufnr}, {diagnostics})
|
|||||||
*vim.lsp.util.buf_diagnostics_signs()*
|
*vim.lsp.util.buf_diagnostics_signs()*
|
||||||
buf_diagnostics_signs({bufnr}, {diagnostics})
|
buf_diagnostics_signs({bufnr}, {diagnostics})
|
||||||
Place signs for each diagnostic in the sign column.
|
Place signs for each diagnostic in the sign column.
|
||||||
Sign characters can be customized with the following options:
|
Sign characters can be customized with the following commands:
|
||||||
>
|
>
|
||||||
let g:LspDiagnosticsErrorSign = 'E'
|
sign define LspDiagnosticsErrorSign text=E texthl=LspDiagnosticsError linehl= numhl=
|
||||||
let g:LspDiagnosticsWarningSign = 'W'
|
sign define LspDiagnosticsWarningSign text=W texthl=LspDiagnosticsWarning linehl= numhl=
|
||||||
let g:LspDiagnosticsInformationSign = 'I'
|
sign define LspDiagnosticsInformationSign text=I texthl=LspDiagnosticsInformation linehl= numhl=
|
||||||
let g:LspDiagnosticsHintSign = 'H'
|
sign define LspDiagnosticsHintSign text=H texthl=LspDiagnosticsHint linehl= numhl=
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1017,5 +1017,21 @@ function lsp.get_log_path()
|
|||||||
return log.get_filename()
|
return log.get_filename()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function define_default_sign(name, properties)
|
||||||
|
if not vim.fn.sign_getdefined(name) then
|
||||||
|
vim.fn.sign_define(name, properties)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Define the LspDiagnostics signs if they're not defined already.
|
||||||
|
local function define_default_lsp_diagnostics_signs()
|
||||||
|
define_default_sign('LspDiagnosticsErrorSign', {text='E', texthl='LspDiagnosticsError', linehl='', numhl=''})
|
||||||
|
define_default_sign('LspDiagnosticsWarningSign', {text='W', texthl='LspDiagnosticsWarning', linehl='', numhl=''})
|
||||||
|
define_default_sign('LspDiagnosticsInformationSign', {text='I', texthl='LspDiagnosticsInformation', linehl='', numhl=''})
|
||||||
|
define_default_sign('LspDiagnosticsHintSign', {text='H', texthl='LspDiagnosticsHint', linehl='', numhl=''})
|
||||||
|
end
|
||||||
|
|
||||||
|
define_default_lsp_diagnostics_signs()
|
||||||
|
|
||||||
return lsp
|
return lsp
|
||||||
-- vim:sw=2 ts=2 et
|
-- vim:sw=2 ts=2 et
|
||||||
|
|||||||
@@ -818,6 +818,7 @@ do
|
|||||||
api.nvim_buf_set_virtual_text(bufnr, diagnostic_ns, line, virt_texts, {})
|
api.nvim_buf_set_virtual_text(bufnr, diagnostic_ns, line, virt_texts, {})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.buf_diagnostics_count(kind)
|
function M.buf_diagnostics_count(kind)
|
||||||
local bufnr = vim.api.nvim_get_current_buf()
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
local diagnostics = M.diagnostics_by_buf[bufnr]
|
local diagnostics = M.diagnostics_by_buf[bufnr]
|
||||||
@@ -830,19 +831,16 @@ do
|
|||||||
end
|
end
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
function M.buf_diagnostics_signs(bufnr, diagnostics)
|
|
||||||
vim.fn.sign_define('LspDiagnosticsErrorSign', {text=vim.g['LspDiagnosticsErrorSign'] or 'E', texthl='LspDiagnosticsError', linehl='', numhl=''})
|
|
||||||
vim.fn.sign_define('LspDiagnosticsWarningSign', {text=vim.g['LspDiagnosticsWarningSign'] or 'W', texthl='LspDiagnosticsWarning', linehl='', numhl=''})
|
|
||||||
vim.fn.sign_define('LspDiagnosticsInformationSign', {text=vim.g['LspDiagnosticsInformationSign'] or 'I', texthl='LspDiagnosticsInformation', linehl='', numhl=''})
|
|
||||||
vim.fn.sign_define('LspDiagnosticsHintSign', {text=vim.g['LspDiagnosticsHintSign'] or 'H', texthl='LspDiagnosticsHint', linehl='', numhl=''})
|
|
||||||
|
|
||||||
for _, diagnostic in ipairs(diagnostics) do
|
|
||||||
local diagnostic_severity_map = {
|
local diagnostic_severity_map = {
|
||||||
[protocol.DiagnosticSeverity.Error] = "LspDiagnosticsErrorSign";
|
[protocol.DiagnosticSeverity.Error] = "LspDiagnosticsErrorSign";
|
||||||
[protocol.DiagnosticSeverity.Warning] = "LspDiagnosticsWarningSign";
|
[protocol.DiagnosticSeverity.Warning] = "LspDiagnosticsWarningSign";
|
||||||
[protocol.DiagnosticSeverity.Information] = "LspDiagnosticsInformationSign";
|
[protocol.DiagnosticSeverity.Information] = "LspDiagnosticsInformationSign";
|
||||||
[protocol.DiagnosticSeverity.Hint] = "LspDiagnosticsHintSign";
|
[protocol.DiagnosticSeverity.Hint] = "LspDiagnosticsHintSign";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function M.buf_diagnostics_signs(bufnr, diagnostics)
|
||||||
|
for _, diagnostic in ipairs(diagnostics) do
|
||||||
vim.fn.sign_place(0, sign_ns, diagnostic_severity_map[diagnostic.severity], bufnr, {lnum=(diagnostic.range.start.line+1)})
|
vim.fn.sign_place(0, sign_ns, diagnostic_severity_map[diagnostic.severity], bufnr, {lnum=(diagnostic.range.start.line+1)})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user