added error highlighting.
This commit is contained in:
46
init.lua
46
init.lua
@@ -54,17 +54,59 @@ opt.mouse = ""
|
||||
opt.shortmess:append("atI")
|
||||
opt.hidden = true
|
||||
opt.termguicolors = true -- Important for modern LSPs/UI
|
||||
opt.updatetime = 300 -- Faster response for diagnostics
|
||||
|
||||
-- =============================================================================
|
||||
-- 4. DIAGNOSTICS (Error display)
|
||||
-- =============================================================================
|
||||
vim.diagnostic.config({
|
||||
virtual_text = false, -- No text noise in the line
|
||||
virtual_text = {
|
||||
prefix = "●", -- Subtle dot for error messages
|
||||
},
|
||||
underline = true, -- Errors are underlined
|
||||
signs = false, -- No icons on the edge (less noise)
|
||||
signs = true, -- Enable icons in the gutter
|
||||
update_in_insert = false,
|
||||
severity_sort = true,
|
||||
})
|
||||
|
||||
-- Show error message in a floating window on hover
|
||||
vim.api.nvim_create_autocmd("CursorHold", {
|
||||
callback = function()
|
||||
vim.diagnostic.open_float(nil, { focusable = false, border = "rounded" })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Custom icons for diagnostics
|
||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||
for type, icon in pairs(signs) do
|
||||
local hl = "DiagnosticSign" .. type
|
||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
|
||||
end
|
||||
|
||||
-- =============================================================================
|
||||
-- 4.5 TREESITTER (Syntax & Error Highlighting)
|
||||
-- =============================================================================
|
||||
vim.schedule(function()
|
||||
local ok_ts, ts = pcall(require, "nvim-treesitter.configs")
|
||||
if ok_ts then
|
||||
ts.setup({
|
||||
ensure_installed = { "lua", "python", "rust" },
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
})
|
||||
end
|
||||
end)
|
||||
|
||||
-- =============================================================================
|
||||
-- 4.6 HIGHLIGHTS (Visibility)
|
||||
-- =============================================================================
|
||||
vim.api.nvim_set_hl(0, "DiagnosticUnderlineError", { undercurl = true, sp = "red", bold = true })
|
||||
vim.api.nvim_set_hl(0, "DiagnosticUnderlineWarn", { undercurl = true, sp = "orange" })
|
||||
vim.api.nvim_set_hl(0, "DiagnosticError", { fg = "red" })
|
||||
vim.api.nvim_set_hl(0, "DiagnosticWarn", { fg = "orange" })
|
||||
|
||||
-- =============================================================================
|
||||
-- 5. KEYMAPS (Leader: Space)
|
||||
-- =============================================================================
|
||||
|
||||
Reference in New Issue
Block a user