From 99638caa5299b5edd0be3a1e4d2003eede93650b Mon Sep 17 00:00:00 2001 From: venus Date: Tue, 10 Mar 2026 00:13:13 -0500 Subject: [PATCH] background opacity of terminal changes when nvim opens using kitty --- init.lua | 2 ++ lazy-lock.json | 1 + lua/autocommands.lua | 26 ++++++++++++++++++++++++++ lua/keybinds.lua | 9 +++++++++ lua/options.lua | 12 +----------- 5 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 lua/autocommands.lua diff --git a/init.lua b/init.lua index 0b1db28..b9f6691 100644 --- a/init.lua +++ b/init.lua @@ -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') diff --git a/lazy-lock.json b/lazy-lock.json index 4396cda..15f114c 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -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" }, diff --git a/lua/autocommands.lua b/lua/autocommands.lua new file mode 100644 index 0000000..cc5f73f --- /dev/null +++ b/lua/autocommands.lua @@ -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, +}) + diff --git a/lua/keybinds.lua b/lua/keybinds.lua index 6ec0abf..5802382 100644 --- a/lua/keybinds.lua +++ b/lua/keybinds.lua @@ -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', '', ':bnext') vim.keymap.set('n', '', ':bprev') vim.keymap.set('n', 'x', ':bdelete') diff --git a/lua/options.lua b/lua/options.lua index f75eb2f..dfb1400 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -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