feat: remove padding from kitty terminal on startup
This commit is contained in:
parent
0aca102f57
commit
474c38a272
2 changed files with 59 additions and 0 deletions
1
init.lua
1
init.lua
|
@ -29,6 +29,7 @@ vim.opt.scrolloff = 10
|
|||
|
||||
if os.getenv("TERM") == "xterm-kitty" then
|
||||
require("scripts.chameleon").setup()
|
||||
require("scripts.kitty-padding").setup()
|
||||
end
|
||||
|
||||
vim.cmd.colorscheme("rose-pine")
|
||||
|
|
58
lua/scripts/kitty-padding.lua
Normal file
58
lua/scripts/kitty-padding.lua
Normal file
|
@ -0,0 +1,58 @@
|
|||
-- remove padding from kitty terminal when entering vim
|
||||
|
||||
local M = {}
|
||||
|
||||
local fn = vim.fn
|
||||
local api = vim.api
|
||||
|
||||
local autocmd = api.nvim_create_autocmd
|
||||
local autogroup = api.nvim_create_augroup
|
||||
|
||||
local no_padding = function(sync)
|
||||
local command = "kitty @ set-spacing padding-h=0 padding-bottom=0"
|
||||
if not sync then
|
||||
fn.jobstart(command, {
|
||||
on_stderr = function(_, d, _)
|
||||
if #d > 1 then
|
||||
api.nvim_err_writeln("Error setting window padding. Make sure kitty remote control is turned on.")
|
||||
end
|
||||
end,
|
||||
})
|
||||
else
|
||||
fn.system(command)
|
||||
end
|
||||
end
|
||||
|
||||
local restore_padding = function(sync)
|
||||
local command = "kitty @ set-spacing padding=default"
|
||||
if not sync then
|
||||
fn.jobstart(command, {
|
||||
on_stderr = function(_, d, _)
|
||||
if #d > 1 then
|
||||
api.nvim_err_writeln("Error setting window padding. Make sure kitty remote control is turned on.")
|
||||
end
|
||||
end,
|
||||
})
|
||||
else
|
||||
fn.system(command)
|
||||
end
|
||||
end
|
||||
|
||||
M.setup = function()
|
||||
autocmd({ "VimResume", "VimEnter" }, {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
no_padding()
|
||||
end,
|
||||
group = autogroup("SpacingRemove", { clear = true }),
|
||||
})
|
||||
|
||||
autocmd({ "VimLeavePre", "VimSuspend" }, {
|
||||
callback = function()
|
||||
restore_padding(true)
|
||||
end,
|
||||
group = autogroup("SpacingRestore", { clear = true }),
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
Loading…
Reference in a new issue