background opacity of terminal changes when nvim opens using kitty
This commit is contained in:
26
lua/autocommands.lua
Normal file
26
lua/autocommands.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- [[dynamicallt 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,
|
||||
})
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
-- [[ Basic Autocommands ]]
|
||||
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,
|
||||
})
|
||||
-- move betwwen buffer easier
|
||||
vim.keymap.set('n', '<Tab>', ':bnext<CR>')
|
||||
vim.keymap.set('n', '<S-Tab>', ':bprev<CR>')
|
||||
vim.keymap.set('n', '<leader>x', ':bdelete<CR>')
|
||||
|
||||
@@ -52,16 +52,6 @@ vim.o.scrolloff = 25
|
||||
-- instead raise a dialog asking if you wish to save the current file(s)
|
||||
-- See `:help 'confirm'`
|
||||
vim.o.confirm = true
|
||||
-- [[Keybinds]]
|
||||
-- See `:help vim.keymap.set()`
|
||||
-- See `:help hlsearch`
|
||||
|
||||
-- [[ Basic Autocommands ]]
|
||||
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,
|
||||
})
|
||||
vim.opt.termguicolors = true -- required for colorizer
|
||||
|
||||
|
||||
Reference in New Issue
Block a user