refactor(nvim): improve diag signs setup
Some checks failed
Check Formatting of Files / Check-Formatting (push) Has been cancelled

This commit is contained in:
Price Hiller 2024-06-13 15:36:21 -05:00
parent e65eeea36a
commit 235a0ff229
Signed by: Price
GPG Key ID: C3FADDE7A8534BEB
5 changed files with 37 additions and 34 deletions

View File

@ -1,18 +1,7 @@
local M = {} local M = {}
M.setup = function() M.setup = function()
local function lspSymbol(name, icon)
local hl = "DiagnosticSign" .. name
vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl })
end
lspSymbol("Error", "󰅙")
lspSymbol("Warn", "")
lspSymbol("Info", "󰋼")
lspSymbol("Hint", "")
vim.diagnostic.config({ vim.diagnostic.config({
virtual_text = false,
virtual_lines = true,
severity_sort = true, severity_sort = true,
underline = true, underline = true,
update_in_insert = false, update_in_insert = false,
@ -23,24 +12,15 @@ M.setup = function()
[vim.diagnostic.severity.INFO] = "󰋼", [vim.diagnostic.severity.INFO] = "󰋼",
[vim.diagnostic.severity.HINT] = "", [vim.diagnostic.severity.HINT] = "",
}, },
numhl = { linehl = {
[vim.diagnostic.severity.ERROR] = "", [vim.diagnostic.severity.ERROR] = "CustomErrorBg",
[vim.diagnostic.severity.WARN] = "",
[vim.diagnostic.severity.INFO] = "",
[vim.diagnostic.severity.HINT] = "",
}, },
}, },
float = { float = {
focusable = true, focusable = true,
style = "minimal", style = "minimal",
border = { border = "solid",
" ", source = "if_many",
" ",
" ",
" ",
},
source = "always",
header = "Diagnostic",
prefix = "", prefix = "",
}, },
}) })

View File

@ -11,6 +11,7 @@ return {
lsp_keymaps = false, lsp_keymaps = false,
dap_debug_keymap = false, dap_debug_keymap = false,
lsp_codelens = false, lsp_codelens = false,
diagnostic = false,
icons = false, icons = false,
run_in_floaterm = true, run_in_floaterm = true,
trouble = true, trouble = true,

View File

@ -612,10 +612,10 @@ return {
{ {
condition = conditions.has_diagnostics, condition = conditions.has_diagnostics,
static = { static = {
error_icon = vim.fn.sign_getdefined("DiagnosticSignError")[1].text, error_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.ERROR] .. " ",
warn_icon = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text, warn_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.WARN] .. " ",
info_icon = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text, info_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.INFO] .. " ",
hint_icon = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text, hint_icon = vim.diagnostic.config().signs.text[vim.diagnostic.severity.HINT] .. " ",
}, },
init = function(self) init = function(self)
self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })

View File

@ -44,12 +44,20 @@ return {
-- --
---@type { [1]: string, [2]: vim.api.keyset.highlight | fun(): vim.api.keyset.highlight | table<Highlight.Keys, fun(): string | integer> }[] ---@type { [1]: string, [2]: vim.api.keyset.highlight | fun(): vim.api.keyset.highlight | table<Highlight.Keys, fun(): string | integer> }[]
local extra_hls = { local extra_hls = {
-- For diagnostics
{ "CustomErrorBg", { bg = "#3d1b22" } },
-- Nvim notify
{ "NvimNotifyError", { fg = colors.samuraiRed } }, { "NvimNotifyError", { fg = colors.samuraiRed } },
{ "NvimNotifyWarn", { fg = colors.roninYellow } }, { "NvimNotifyWarn", { fg = colors.roninYellow } },
{ "NvimNotifyInfo", { fg = colors.springGreen } }, { "NvimNotifyInfo", { fg = colors.springGreen } },
{ "NvimNotifyDebug", { fg = colors.crystalBlue } }, { "NvimNotifyDebug", { fg = colors.crystalBlue } },
{ "NvimNotifyTrace", { fg = colors.oniViolet } }, { "NvimNotifyTrace", { fg = colors.oniViolet } },
-- Built-ins
{ "StatusLineNC", { bg = nil } }, { "StatusLineNC", { bg = nil } },
{ "menuSel", { bg = colors.sumiInk0, fg = "NONE" } },
{ "Pmenu", { fg = colors.fujiWhite, bg = colors.sumiInk2 } },
{ "WinBarNC", { bg = nil } }, { "WinBarNC", { bg = nil } },
{ "Visual", { bg = colors.sumiInk5 } }, { "Visual", { bg = colors.sumiInk5 } },
{ "CursorLine", { bg = colors.sumiInk4 } }, { "CursorLine", { bg = colors.sumiInk4 } },
@ -59,6 +67,18 @@ return {
{ "WinSeparator", { fg = colors.fujiGray } }, { "WinSeparator", { fg = colors.fujiGray } },
{ "StatusLine", { fg = colors.fujiWhite, bg = colors.sumiInk0 } }, { "StatusLine", { fg = colors.fujiWhite, bg = colors.sumiInk0 } },
{ "WinBar", { link = "StatusLine" } }, { "WinBar", { link = "StatusLine" } },
-- Gitsigns Colors
{ "GitSignsAdd", { fg = colors.autumnGreen } },
{ "GitSignsDelete", { fg = colors.autumnRed } },
{ "GitSignsChange", { fg = colors.autumnYellow } },
{ "GitSignsStagedAdd", { link = "GitSignsChangeAdd" } },
{ "GitSignsStagedDelete", { link = "GitSignsDelete" } },
{ "GitSignsStagedChangedelete", { link = "GitSignsDelete" } },
{ "GitSignsStagedChange", { link = "GitSignsChange" } },
{ "GitSignsUntracked", { link = "GitSignsChange" } },
-- Neogit
{ "NeogitCommandText", { fg = colors.oniViolet2 } }, { "NeogitCommandText", { fg = colors.oniViolet2 } },
{ "NeogitPopupSectionTitle", { fg = colors.crystalBlue } }, { "NeogitPopupSectionTitle", { fg = colors.crystalBlue } },
{ "NeogitPopupConfigEnabled", { fg = colors.springBlue, italic = true } }, { "NeogitPopupConfigEnabled", { fg = colors.springBlue, italic = true } },
@ -96,8 +116,8 @@ return {
{ "NeogitNotificationInfo", { fg = colors.springGreen, bold = true } }, { "NeogitNotificationInfo", { fg = colors.springGreen, bold = true } },
{ "NeogitNotificationWarning", { fg = colors.roninYellow, bold = true } }, { "NeogitNotificationWarning", { fg = colors.roninYellow, bold = true } },
{ "NeogitNotificationError", { fg = colors.samuraiRed, bold = true } }, { "NeogitNotificationError", { fg = colors.samuraiRed, bold = true } },
{ "menuSel", { bg = colors.sumiInk0, fg = "NONE" } },
{ "Pmenu", { fg = colors.fujiWhite, bg = colors.sumiInk2 } }, -- Cmp
{ "CmpGhostText", { fg = colors.boatYellow1, italic = true } }, { "CmpGhostText", { fg = colors.boatYellow1, italic = true } },
{ "CmpItemAbbrDeprecated", { fg = colors.fujiGray, bg = "NONE" } }, { "CmpItemAbbrDeprecated", { fg = colors.fujiGray, bg = "NONE" } },
{ "CmpItemAbbrMatch", { fg = colors.crystalBlue, bg = "NONE" } }, { "CmpItemAbbrMatch", { fg = colors.crystalBlue, bg = "NONE" } },
@ -145,6 +165,8 @@ return {
{ "CmpCustomSelectionCommit", { fg = colors.fujiWhite, bg = colors.peachRed } }, { "CmpCustomSelectionCommit", { fg = colors.fujiWhite, bg = colors.peachRed } },
{ "CmpCustomSelectionSnippet", { fg = colors.fujiWhite, bg = colors.peachRed } }, { "CmpCustomSelectionSnippet", { fg = colors.fujiWhite, bg = colors.peachRed } },
{ "CmpCustomSelectionLuaLatexSymbol", { fg = colors.fujiWhite, bg = colors.surimiOrange } }, { "CmpCustomSelectionLuaLatexSymbol", { fg = colors.fujiWhite, bg = colors.surimiOrange } },
-- Telescope
{ "TelescopeNormal", { bg = colors.sumiInk2 } }, { "TelescopeNormal", { bg = colors.sumiInk2 } },
{ "TelescopeBorder", { bg = colors.sumiInk2, fg = colors.sumiInk1 } }, { "TelescopeBorder", { bg = colors.sumiInk2, fg = colors.sumiInk1 } },
{ "TelescopePromptBorder", { bg = colors.sumiInk0, fg = colors.sumiInk0 } }, { "TelescopePromptBorder", { bg = colors.sumiInk0, fg = colors.sumiInk0 } },
@ -154,6 +176,7 @@ return {
{ "TelescopePreviewNormal", { bg = colors.sumiInk4 } }, { "TelescopePreviewNormal", { bg = colors.sumiInk4 } },
{ "TelescopePreviewBorder", { link = "TelescopePreviewNormal" } }, { "TelescopePreviewBorder", { link = "TelescopePreviewNormal" } },
{ "TelescopeResultsTitle", { fg = "NONE", bg = "NONE" } }, { "TelescopeResultsTitle", { fg = "NONE", bg = "NONE" } },
{ "IlluminatedWordText", { bg = colors.waveBlue2 } }, { "IlluminatedWordText", { bg = colors.waveBlue2 } },
{ "IlluminatedWordRead", { bg = colors.waveBlue2 } }, { "IlluminatedWordRead", { bg = colors.waveBlue2 } },
{ "IlluminatedWordWrite", { bg = colors.waveBlue2 } }, { "IlluminatedWordWrite", { bg = colors.waveBlue2 } },

View File

@ -252,22 +252,21 @@ return {
{ {
"<leader>ls", "<leader>ls",
function() function()
vim.diagnostic.open_float(nil, { focus = true, scope = "cursor" }) vim.diagnostic.open_float(nil, { focus = false, scope = "cursor" })
vim.cmd.vsplit()
end, end,
desc = "LSP: Diagnostic Open Float", desc = "LSP: Diagnostic Open Float",
}, },
{ {
"[l", "[l",
function() function()
vim.diagnostic.jump({ count = -1 }) vim.diagnostic.jump({ count = -1, float = true })
end, end,
desc = "LSP: Diagnostic Previous", desc = "LSP: Diagnostic Previous",
}, },
{ {
"]l", "]l",
function() function()
vim.diagnostic.jump({ count = 1 }) vim.diagnostic.jump({ count = 1, float = true })
end, end,
desc = "LSP: Diagnostic Next", desc = "LSP: Diagnostic Next",
}, },