Skip to content

Commit 356b757

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

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
@@ -671,15 +671,34 @@ require('lazy').setup({
671671
end,
672672
})
673673

674-
-- Change diagnostic symbols in the sign column (gutter)
675-
-- if vim.g.have_nerd_font then
676-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
677-
-- local diagnostic_signs = {}
678-
-- for type, icon in pairs(signs) do
679-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
680-
-- end
681-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
682-
-- end
674+
-- Diagnostic Config
675+
-- See :help vim.diagnostic.Opts
676+
vim.diagnostic.config {
677+
severity_sort = true,
678+
float = { border = 'rounded', source = 'if_many' },
679+
underline = { severity = vim.diagnostic.severity.ERROR },
680+
signs = vim.g.have_nerd_font and {
681+
text = {
682+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
683+
[vim.diagnostic.severity.WARN] = '󰀪 ',
684+
[vim.diagnostic.severity.INFO] = '󰋽 ',
685+
[vim.diagnostic.severity.HINT] = '󰌶 ',
686+
},
687+
} or {},
688+
virtual_text = {
689+
source = 'if_many',
690+
spacing = 2,
691+
format = function(diagnostic)
692+
local diagnostic_message = {
693+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
694+
[vim.diagnostic.severity.WARN] = diagnostic.message,
695+
[vim.diagnostic.severity.INFO] = diagnostic.message,
696+
[vim.diagnostic.severity.HINT] = diagnostic.message,
697+
}
698+
return diagnostic_message[diagnostic.severity]
699+
end,
700+
},
701+
}
683702

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

0 commit comments

Comments
 (0)