diff --git a/README.md b/README.md index 35db8b1..1320563 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,12 @@ let g:space_before_virtual_text = 5 let g:diagnostic_show_sign = 0 ``` +- The default priority of the diagnostic sign is 20. You can customize it by + +```vim +let g:diagnostic_sign_priority = 20 +``` + - Make sure to use the latest branch of Neovim which has sign support. - If you want to change the symbols of sign, use `sign_define` to change it diff --git a/lua/diagnostic.lua b/lua/diagnostic.lua index 2565704..99995ae 100644 --- a/lua/diagnostic.lua +++ b/lua/diagnostic.lua @@ -77,7 +77,7 @@ function M.publish_diagnostics(bufnr) util.buf_diagnostics_save_positions(bufnr, result.diagnostics) vim.lsp.util.buf_diagnostics_underline(bufnr, result.diagnostics) if vim.api.nvim_get_var('diagnostic_show_sign') == 1 then - vim.lsp.util.buf_diagnostics_signs(bufnr, result.diagnostics) + util.buf_diagnostics_signs(bufnr, result.diagnostics) end if vim.api.nvim_get_var('diagnostic_enable_virtual_text') == 1 then util.buf_diagnostics_virtual_text(bufnr, result.diagnostics) diff --git a/lua/diagnostic/util.lua b/lua/diagnostic/util.lua index ac180ef..977efdc 100644 --- a/lua/diagnostic/util.lua +++ b/lua/diagnostic/util.lua @@ -103,11 +103,6 @@ function M.buf_diagnostics_virtual_text(bufnr, diagnostics) 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 = { [protocol.DiagnosticSeverity.Error] = "LspDiagnosticsErrorSign"; @@ -115,7 +110,7 @@ function M.buf_diagnostics_signs(bufnr, diagnostics) [protocol.DiagnosticSeverity.Information] = "LspDiagnosticsInformationSign"; [protocol.DiagnosticSeverity.Hint] = "LspDiagnosticsHintSign"; } - vim.fn.sign_place(0, sign_ns, diagnostic_severity_map[diagnostic.severity], bufnr, {lnum=(diagnostic.range.start.line+1), priority=50}) + vim.fn.sign_place(0, sign_ns, diagnostic_severity_map[diagnostic.severity], bufnr, {lnum=(diagnostic.range.start.line+1), priority=vim.g.diagnostic_sign_priority}) end end diff --git a/plugin/diagnostic.vim b/plugin/diagnostic.vim index 0a69b8f..68776b0 100644 --- a/plugin/diagnostic.vim +++ b/plugin/diagnostic.vim @@ -31,6 +31,10 @@ if ! exists('g:diagnostic_show_sign') let g:diagnostic_show_sign = 1 endif +if ! exists('g:diagnostic_sign_priority') + let g:diagnostic_sign_priority = 20 +endif + if ! exists('g:diagnostic_insert_delay') let g:diagnostic_insert_delay = 0 endif