|
@@ -4,17 +4,30 @@ local M = {
|
|
|
dependencies = { "neovim/nvim-lspconfig" },
|
|
dependencies = { "neovim/nvim-lspconfig" },
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+local icons = {
|
|
|
|
|
+ Error = "",
|
|
|
|
|
+ Warning = "",
|
|
|
|
|
+ Information = "",
|
|
|
|
|
+ Hint = "",
|
|
|
|
|
+ Note = " ",
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+-- Map severity to icon
|
|
|
|
|
+local function get_icon(severity)
|
|
|
|
|
+ local severity_name = vim.diagnostic.severity[severity]
|
|
|
|
|
+ return icons[severity_name] or ""
|
|
|
|
|
+end
|
|
|
|
|
+
|
|
|
M.init = function()
|
|
M.init = function()
|
|
|
- for severity, icon in pairs({
|
|
|
|
|
- [vim.diagnostic.severity.ERROR] = icons.diagnostics.Error,
|
|
|
|
|
- [vim.diagnostic.severity.WARN] = icons.diagnostics.Warning,
|
|
|
|
|
- [vim.diagnostic.severity.INFO] = icons.diagnostics.Information,
|
|
|
|
|
- [vim.diagnostic.severity.HINT] = icons.diagnostics.Hint,
|
|
|
|
|
- }) do
|
|
|
|
|
- local name = "DiagnosticSign" .. vim.diagnostic.severity[severity]
|
|
|
|
|
- vim.fn.sign_define(name, { text = icon, texthl = name })
|
|
|
|
|
|
|
+ -- Define diagnostic signs
|
|
|
|
|
+ local severity_names = { "ERROR", "WARN", "INFO", "HINT" }
|
|
|
|
|
+ for _, name in ipairs(severity_names) do
|
|
|
|
|
+ local severity = vim.diagnostic.severity[name]
|
|
|
|
|
+ local sign_name = "DiagnosticSign" .. name
|
|
|
|
|
+ vim.fn.sign_define(sign_name, { text = get_icon(severity), texthl = sign_name })
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
|
|
+ -- Highlight diagnostic signs
|
|
|
vim.cmd([[
|
|
vim.cmd([[
|
|
|
highlight DiagnosticSignError guifg=#f7768e gui=bold
|
|
highlight DiagnosticSignError guifg=#f7768e gui=bold
|
|
|
highlight DiagnosticSignWarn guifg=#e0af68 gui=bold
|
|
highlight DiagnosticSignWarn guifg=#e0af68 gui=bold
|
|
@@ -24,26 +37,25 @@ M.init = function()
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
-- Cycle through quickfix items
|
|
-- Cycle through quickfix items
|
|
|
-local function cycle_qf(cmd)
|
|
|
|
|
|
|
+local function cycle_qf(direction)
|
|
|
local qf = vim.fn.getqflist({ size = 0, idx = 0 })
|
|
local qf = vim.fn.getqflist({ size = 0, idx = 0 })
|
|
|
if qf.size == 0 then
|
|
if qf.size == 0 then
|
|
|
return
|
|
return
|
|
|
end
|
|
end
|
|
|
- if cmd == "next" then
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if direction == "next" then
|
|
|
vim.cmd(qf.idx == qf.size and "cfirst" or "cnext")
|
|
vim.cmd(qf.idx == qf.size and "cfirst" or "cnext")
|
|
|
- elseif cmd == "prev" then
|
|
|
|
|
|
|
+ else
|
|
|
vim.cmd(qf.idx == 1 and "clast" or "cprev")
|
|
vim.cmd(qf.idx == 1 and "clast" or "cprev")
|
|
|
end
|
|
end
|
|
|
end
|
|
end
|
|
|
|
|
|
|
|
function M.config()
|
|
function M.config()
|
|
|
- -- Diagnostic configuration using _G.icons.diagnostics
|
|
|
|
|
- -- local icons = _G.icons.diagnostics
|
|
|
|
|
vim.diagnostic.config({
|
|
vim.diagnostic.config({
|
|
|
virtual_text = {
|
|
virtual_text = {
|
|
|
prefix = "●",
|
|
prefix = "●",
|
|
|
format = function(d)
|
|
format = function(d)
|
|
|
- return string.format("%s %s", icons[vim.diagnostic.severity[d.severity]], d.message)
|
|
|
|
|
|
|
+ return string.format("%s %s", get_icon(d.severity), d.message)
|
|
|
end,
|
|
end,
|
|
|
},
|
|
},
|
|
|
underline = true,
|
|
underline = true,
|
|
@@ -51,10 +63,10 @@ function M.config()
|
|
|
signs = {
|
|
signs = {
|
|
|
active = true,
|
|
active = true,
|
|
|
text = {
|
|
text = {
|
|
|
- [vim.diagnostic.severity.ERROR] = icons.diagnostics.Error,
|
|
|
|
|
- [vim.diagnostic.severity.WARN] = icons.diagnostics.Warning,
|
|
|
|
|
- [vim.diagnostic.severity.INFO] = icons.diagnostics.Information,
|
|
|
|
|
- [vim.diagnostic.severity.HINT] = icons.diagnostics.Hint,
|
|
|
|
|
|
|
+ [vim.diagnostic.severity.ERROR] = icons.Error,
|
|
|
|
|
+ [vim.diagnostic.severity.WARN] = icons.Warning,
|
|
|
|
|
+ [vim.diagnostic.severity.INFO] = icons.Information,
|
|
|
|
|
+ [vim.diagnostic.severity.HINT] = icons.Hint,
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
float = {
|
|
float = {
|
|
@@ -63,12 +75,8 @@ function M.config()
|
|
|
border = "rounded",
|
|
border = "rounded",
|
|
|
source = true,
|
|
source = true,
|
|
|
format = function(d)
|
|
format = function(d)
|
|
|
- return string.format(
|
|
|
|
|
- "%s %s: %s",
|
|
|
|
|
- icons[vim.diagnostic.severity[d.severity]],
|
|
|
|
|
- vim.diagnostic.severity[d.severity]:lower(),
|
|
|
|
|
- d.message
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ local severity_name = vim.diagnostic.severity[d.severity]
|
|
|
|
|
+ return string.format("%s %s: %s", get_icon(d.severity), severity_name:lower(), d.message)
|
|
|
end,
|
|
end,
|
|
|
},
|
|
},
|
|
|
severity_sort = true,
|
|
severity_sort = true,
|
|
@@ -93,19 +101,20 @@ function M.config()
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
type_icons = {
|
|
type_icons = {
|
|
|
- E = icons.diagnostics.Error .. " ",
|
|
|
|
|
- W = icons.diagnostics.Warning .. " ",
|
|
|
|
|
- I = icons.diagnostics.Information .. " ",
|
|
|
|
|
- N = icons.ui.Note .. " ",
|
|
|
|
|
- H = icons.diagnostics.Hint .. " ",
|
|
|
|
|
|
|
+ E = icons.Error .. " ",
|
|
|
|
|
+ W = icons.Warning .. " ",
|
|
|
|
|
+ I = icons.Information .. " ",
|
|
|
|
|
+ N = icons.Note,
|
|
|
|
|
+ H = icons.Hint .. " ",
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-- Quickfix navigation mappings
|
|
-- Quickfix navigation mappings
|
|
|
- vim.keymap.set("n", "<a-j>", function()
|
|
|
|
|
|
|
+ nmap("<a-j>", function()
|
|
|
cycle_qf("next")
|
|
cycle_qf("next")
|
|
|
end, { desc = "Next quickfix item (cycles)" })
|
|
end, { desc = "Next quickfix item (cycles)" })
|
|
|
- vim.keymap.set("n", "<a-k>", function()
|
|
|
|
|
|
|
+
|
|
|
|
|
+ nmap("<a-k>", function()
|
|
|
cycle_qf("prev")
|
|
cycle_qf("prev")
|
|
|
end, { desc = "Previous quickfix item (cycles)" })
|
|
end, { desc = "Previous quickfix item (cycles)" })
|
|
|
end
|
|
end
|