Skip to content

Commit bcdb68b

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

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
@@ -646,15 +646,34 @@ require('lazy').setup({
646646
end,
647647
})
648648

649-
-- Change diagnostic symbols in the sign column (gutter)
650-
-- if vim.g.have_nerd_font then
651-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
652-
-- local diagnostic_signs = {}
653-
-- for type, icon in pairs(signs) do
654-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
655-
-- end
656-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
657-
-- end
649+
-- Diagnostic Config
650+
-- See :help vim.diagnostic.Opts
651+
vim.diagnostic.config {
652+
severity_sort = true,
653+
float = { border = 'rounded', source = 'if_many' },
654+
underline = { severity = vim.diagnostic.severity.ERROR },
655+
signs = vim.g.have_nerd_font and {
656+
text = {
657+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
658+
[vim.diagnostic.severity.WARN] = '󰀪 ',
659+
[vim.diagnostic.severity.INFO] = '󰋽 ',
660+
[vim.diagnostic.severity.HINT] = '󰌶 ',
661+
},
662+
} or {},
663+
virtual_text = {
664+
source = 'if_many',
665+
spacing = 2,
666+
format = function(diagnostic)
667+
local diagnostic_message = {
668+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
669+
[vim.diagnostic.severity.WARN] = diagnostic.message,
670+
[vim.diagnostic.severity.INFO] = diagnostic.message,
671+
[vim.diagnostic.severity.HINT] = diagnostic.message,
672+
}
673+
return diagnostic_message[diagnostic.severity]
674+
end,
675+
},
676+
}
658677

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

0 commit comments

Comments
 (0)