Skip to content

Commit d0613e3

Browse files
gelocraftkmha915
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <gelocraft@users.noreply.github.com>
1 parent fc3747e commit d0613e3

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
@@ -603,15 +603,34 @@ require('lazy').setup({
603603
end,
604604
})
605605

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

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

0 commit comments

Comments
 (0)