Skip to content

Commit f9be521

Browse files
gelocraftcharamzic
authored andcommitted
feat(diagnostic): add diagnostic config (nvim-lua#1335)
Co-authored-by: gelocraft <[email protected]>
1 parent e65ef3b commit f9be521

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
@@ -636,15 +636,34 @@ require('lazy').setup({
636636
end,
637637
})
638638

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

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

0 commit comments

Comments
 (0)