🐛 fix(highlights): fix highlight autocommands
Make better use of autocommands for the various highlight configurations
This commit is contained in:
@@ -182,23 +182,51 @@ end
|
|||||||
function M.setup_autocommands()
|
function M.setup_autocommands()
|
||||||
local autogrp = vim.api.nvim_create_augroup
|
local autogrp = vim.api.nvim_create_augroup
|
||||||
local autocmd = vim.api.nvim_create_autocmd
|
local autocmd = vim.api.nvim_create_autocmd
|
||||||
-- Autocommand to trigger setup on InsertEnter
|
|
||||||
autogrp("IndentHighlight", { clear = true })
|
autogrp("IndentHighlight", { clear = true })
|
||||||
autocmd("InsertEnter", {
|
-- Autocommand to trigger setup on FileType
|
||||||
|
-- autocmd("FileType", {
|
||||||
|
-- pattern = "*",
|
||||||
|
-- group = "IndentHighlight",
|
||||||
|
-- callback = function()
|
||||||
|
-- M.setup_indent_highlight()
|
||||||
|
-- M.setup_dashboard_highlight()
|
||||||
|
-- end,
|
||||||
|
-- })
|
||||||
|
|
||||||
|
-- List of filetypes to exclude
|
||||||
|
local excluded_filetypes = {
|
||||||
|
"help",
|
||||||
|
"alpha",
|
||||||
|
"dashboard",
|
||||||
|
"neo-tree",
|
||||||
|
"Trouble",
|
||||||
|
"trouble",
|
||||||
|
"lazy",
|
||||||
|
"mason",
|
||||||
|
"notify",
|
||||||
|
"toggleterm",
|
||||||
|
"lazyterm",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Autocommand to trigger setup on FileType
|
||||||
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
group = "IndentHighlight",
|
group = "IndentHighlight",
|
||||||
callback = function()
|
callback = function()
|
||||||
M.setup_indent_highlight()
|
local filetype = vim.bo.filetype
|
||||||
|
if not vim.tbl_contains(excluded_filetypes, filetype) then
|
||||||
|
M.setup_indent_highlight()
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Autocommand to trigger setup on ColorScheme
|
-- Autocommand to trigger setup on ColorScheme
|
||||||
autocmd("ColorScheme", {
|
autocmd("ColorScheme", {
|
||||||
|
pattern = "*",
|
||||||
group = "IndentHighlight",
|
group = "IndentHighlight",
|
||||||
callback = function()
|
callback = function()
|
||||||
M.setup_indent_highlight()
|
M.setup_indent_highlight()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Autocommand to trigger setup on ModeChanged
|
-- Autocommand to trigger setup on ModeChanged
|
||||||
autogrp("ModeHighlighting", { clear = true })
|
autogrp("ModeHighlighting", { clear = true })
|
||||||
autocmd("ModeChanged", {
|
autocmd("ModeChanged", {
|
||||||
@@ -210,8 +238,9 @@ function M.setup_autocommands()
|
|||||||
|
|
||||||
-- Create a new augroup for the dashboard
|
-- Create a new augroup for the dashboard
|
||||||
local dashboardGroup = autogrp("DashboardColors", { clear = true })
|
local dashboardGroup = autogrp("DashboardColors", { clear = true })
|
||||||
-- Set the color for DashboardHeader when VimEnter event triggers
|
-- Autocommand to trigger setup on FileType
|
||||||
autocmd("CursorMoved", {
|
autocmd("FileType", {
|
||||||
|
pattern = "*",
|
||||||
group = dashboardGroup,
|
group = dashboardGroup,
|
||||||
callback = function()
|
callback = function()
|
||||||
M.setup_dashboard_highlight()
|
M.setup_dashboard_highlight()
|
||||||
|
|||||||
Reference in New Issue
Block a user