Skip to content

Commit 38a8d1e

Browse files
committed
feat(diagnostic): add diagnostic config
1 parent 5bdde24 commit 38a8d1e

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
@@ -589,15 +589,34 @@ require('lazy').setup({
589589
end,
590590
})
591591

592-
-- Change diagnostic symbols in the sign column (gutter)
593-
-- if vim.g.have_nerd_font then
594-
-- local signs = { ERROR = '', WARN = '', INFO = '', HINT = '' }
595-
-- local diagnostic_signs = {}
596-
-- for type, icon in pairs(signs) do
597-
-- diagnostic_signs[vim.diagnostic.severity[type]] = icon
598-
-- end
599-
-- vim.diagnostic.config { signs = { text = diagnostic_signs } }
600-
-- end
592+
-- Diagnostic Config
593+
-- See :help vim.diagnostic.Opts
594+
vim.diagnostic.config {
595+
severity_sort = true,
596+
float = { border = 'rounded', source = 'if_many' },
597+
underline = { severity = vim.diagnostic.severity.ERROR },
598+
signs = vim.g.have_nerd_font and {
599+
text = {
600+
[vim.diagnostic.severity.ERROR] = '󰅚 ',
601+
[vim.diagnostic.severity.WARN] = '󰀪 ',
602+
[vim.diagnostic.severity.INFO] = '󰋽 ',
603+
[vim.diagnostic.severity.HINT] = '󰌶 ',
604+
},
605+
} or {},
606+
virtual_text = {
607+
source = 'if_many',
608+
spacing = 2,
609+
format = function(diagnostic)
610+
local diagnostic_message = {
611+
[vim.diagnostic.severity.ERROR] = diagnostic.message,
612+
[vim.diagnostic.severity.WARN] = diagnostic.message,
613+
[vim.diagnostic.severity.INFO] = diagnostic.message,
614+
[vim.diagnostic.severity.HINT] = diagnostic.message,
615+
}
616+
return diagnostic_message[diagnostic.severity]
617+
end,
618+
},
619+
}
601620

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

0 commit comments

Comments
 (0)