Skip to content

Commit 603149d

Browse files
gelocraftrexfordessilfie
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <gelocraft@users.noreply.github.com>
1 parent 3cf8d3c commit 603149d

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
@@ -600,15 +600,34 @@ require('lazy').setup({
600600
end,
601601
})
602602

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

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

0 commit comments

Comments
 (0)