51 lines
1.6 KiB
Lua
51 lines
1.6 KiB
Lua
-- lua/autocommands.lua
|
|
-- Defines autocommands to run on certain events happening
|
|
-- TODO clean this with functions
|
|
|
|
-- [[dynamically change kitty window opacity when opening and closing]]
|
|
-- Define the target opacities
|
|
local nvim_opacity = "0.85"
|
|
local default_opacity = "0.6"
|
|
-- Function to talk to Kitty
|
|
local function set_kitty_opacity(opacity)
|
|
-- print("Attempting to set opacity to: " .. opacity)
|
|
os.execute("kitty @ set-background-opacity " .. opacity)
|
|
end
|
|
-- Set up the autocommands
|
|
local kitty_group = vim.api.nvim_create_augroup("KittyOpacity", { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd("VimEnter", {
|
|
group = kitty_group,
|
|
callback = function()
|
|
set_kitty_opacity(nvim_opacity)
|
|
end,
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd("VimLeave", {
|
|
group = kitty_group,
|
|
callback = function()
|
|
set_kitty_opacity(default_opacity)
|
|
end,
|
|
})
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
desc = 'Highlight when yanking (copying) text',
|
|
group = vim.api.nvim_create_augroup('kickstart-highlight-yank', { clear = true }),
|
|
callback = function()
|
|
vim.hl.on_yank()
|
|
end,
|
|
})
|
|
|
|
-- Create an augroup to manage our spellcheck autocommands
|
|
local spell_group = vim.api.nvim_create_augroup("EnableSpellcheck", { clear = true })
|
|
|
|
vim.api.nvim_create_autocmd("FileType", {
|
|
group = spell_group,
|
|
-- List the filetypes you want to enable spellcheck for
|
|
pattern = { "markdown", "text", "gitcommit", "latex", "plaintex" },
|
|
callback = function()
|
|
vim.opt_local.spell = true
|
|
vim.opt_local.spelllang = "en_us" -- Optional: set your preferred language
|
|
vim.opt_local.spelloptions = "camel"
|
|
end,
|
|
})
|