Skip to content

Commit c06af31

Browse files
gelocraftDavid Wiens
authored and
David Wiens
committed
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <gelocraft@users.noreply.github.com>
1 parent 31fa00c commit c06af31

File tree

1 file changed

+28
-9
lines changed

1 file changed

+28
-9
lines changed

init.lua

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -599,15 +599,34 @@ require('lazy').setup({
599599
end,
600600
})
601601

602-
-- Change diagnostic symbols in the sign column (gutter)
603-
-- if vim.g.have_nerd_font then
604-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
605-
-- local diagnostic_signs = {}
606-
-- for type, icon in pairs(signs) do
607-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
608-
-- end
609-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
610-
-- end
602+
-- Diagnostic Config
603+
-- See :help vim.diagnostic.Opts
604+
vim.diagnostic.config {
605+
severity_sort = true,
606+
float = { border = 'rounded', source = 'if_many' },
607+
underline = { severity = vim.diagnostic.severity.ERROR },
608+
signs = vim.g.have_nerd_font and {
609+
text = {
610+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
611+
[vim.diagnostic.severity.WARN] = '󰀪 ',
612+
[vim.diagnostic.severity.INFO] = '󰋽 ',
613+
[vim.diagnostic.severity.HINT] = '󰌶 ',
614+
},
615+
} or {},
616+
virtual_text = {
617+
source = 'if_many',
618+
spacing = 2,
619+
format = function(diagnostic)
620+
local diagnostic_message = {
621+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
622+
[vim.diagnostic.severity.WARN] = diagnostic.message,
623+
[vim.diagnostic.severity.INFO] = diagnostic.message,
624+
[vim.diagnostic.severity.HINT] = diagnostic.message,
625+
}
626+
return diagnostic_message[diagnostic.severity]
627+
end,
628+
},
629+
}
611630

612631
-- LSP servers and clients are able to communicate to each other what features they support.
613632
-- By default, Neovim doesn't support everything that is in the LSP specification.

0 commit comments

Comments
 (0)