background opacity of terminal changes when nvim opens using kitty

This commit is contained in:
venus
2026-03-10 00:13:13 -05:00
parent 7c602e62bc
commit 99638caa52
5 changed files with 39 additions and 11 deletions

View File

@@ -29,6 +29,7 @@ require("lazy").setup({
"rktjmp/lush.nvim", -- better theme editing
'vyfor/cord.nvim', --discord rich presence
'RRethy/base16-nvim',
{ 'norcalli/nvim-colorizer.lua', config = function() require('colorizer').setup{"*"} end,}, -- preview colors
{'NMAC427/guess-indent.nvim', config = function() require('guess-indent').setup {} end,}, -- Detect tabstop and shiftwidth automatically
{ 'edluffy/hologram.nvim', auto_display = true,}, --image viewer
{ "denialofsandwich/sudo.nvim", dependencies = { "MunifTanjim/nui.nvim", },config = true, }, --write restricted files without restart
@@ -50,3 +51,4 @@ if theme_ok then
matugen.setup()
end
require('autocommands')

View File

@@ -25,6 +25,7 @@
"mini.pick": { "branch": "main", "commit": "8521fe21df86e08d9e4b3c3f3a7d50e47954e1af" },
"neogit": { "branch": "master", "commit": "8fd90675caf8b847280ca56f464b66030adad876" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-dap": { "branch": "master", "commit": "a9d8cb68ee7184111dc66156c4a2ebabfbe01bc5" },
"nvim-java": { "branch": "main", "commit": "602a5f7fa92f9c1d425a2159133ff9de86842f0a" },
"nvim-lspconfig": { "branch": "master", "commit": "d8bf4c47385340ab2029402201d4d7c9f99f437a" },

26
lua/autocommands.lua Normal file
View 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,
})

View File

@@ -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>')

View File

@@ -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