Skip to content

Commit 40a69bc

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

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

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

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

0 commit comments

Comments
 (0)