feat: fennelize kitty-padding
This commit is contained in:
parent
7cce5e4204
commit
e58f6efffe
2 changed files with 67 additions and 41 deletions
37
fnl/scripts/kitty-padding.fnl
Normal file
37
fnl/scripts/kitty-padding.fnl
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
;; 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)
|
||||||
|
(fn no-padding [sync]
|
||||||
|
(let [command "kitty @ set-spacing padding-h=0 padding-bottom=0"]
|
||||||
|
(if (not sync)
|
||||||
|
(___fn___.jobstart command
|
||||||
|
{:on_stderr (fn [_ d _]
|
||||||
|
(when (> (length d) 1)
|
||||||
|
(vim.notify "Error setting window padding. Make sure kitty remote control is turned on."
|
||||||
|
vim.log.levels.DEBUG)))})
|
||||||
|
(___fn___.system command))))
|
||||||
|
|
||||||
|
(fn restore-padding [sync]
|
||||||
|
(let [command "kitty @ set-spacing padding=default"]
|
||||||
|
(if (not sync)
|
||||||
|
(___fn___.jobstart command
|
||||||
|
{:on_stderr (fn [_ d _]
|
||||||
|
(when (> (length d) 1)
|
||||||
|
(vim.notify "Error setting window padding. Make sure kitty remote control is turned on."
|
||||||
|
vim.log.levels.DEBUG)))})
|
||||||
|
(___fn___.system command))))
|
||||||
|
|
||||||
|
(fn M.setup []
|
||||||
|
(autocmd [:VimResume :VimEnter]
|
||||||
|
{:callback (fn [] (no-padding))
|
||||||
|
:group (autogroup :SpacingRemove {:clear true})
|
||||||
|
:pattern "*"})
|
||||||
|
(autocmd [:VimLeavePre :VimSuspend]
|
||||||
|
{:callback (fn [] (restore-padding true))
|
||||||
|
:group (autogroup :SpacingRestore {:clear true})}))
|
||||||
|
|
||||||
|
M
|
71
lua/scripts/kitty-padding.lua
generated
71
lua/scripts/kitty-padding.lua
generated
|
@ -1,58 +1,47 @@
|
||||||
-- remove padding from kitty terminal when entering vim
|
-- [nfnl] Compiled from ./fnl/scripts/kitty-padding.fnl by https://github.com/Olical/nfnl, do not edit.
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
local ___fn___ = vim.fn
|
||||||
local fn = vim.fn
|
|
||||||
local api = vim.api
|
local api = vim.api
|
||||||
|
|
||||||
local autocmd = api.nvim_create_autocmd
|
local autocmd = api.nvim_create_autocmd
|
||||||
local autogroup = api.nvim_create_augroup
|
local autogroup = api.nvim_create_augroup
|
||||||
|
local function no_padding(sync)
|
||||||
local no_padding = function(sync)
|
|
||||||
local command = "kitty @ set-spacing padding-h=0 padding-bottom=0"
|
local command = "kitty @ set-spacing padding-h=0 padding-bottom=0"
|
||||||
if not sync then
|
if not sync then
|
||||||
fn.jobstart(command, {
|
local function _1_(_, d, _0)
|
||||||
on_stderr = function(_, d, _)
|
if (#d > 1) then
|
||||||
if #d > 1 then
|
return vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG)
|
||||||
vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG)
|
else
|
||||||
end
|
return nil
|
||||||
end,
|
end
|
||||||
})
|
end
|
||||||
|
return ___fn___.jobstart(command, {on_stderr = _1_})
|
||||||
else
|
else
|
||||||
fn.system(command)
|
return ___fn___.system(command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local function restore_padding(sync)
|
||||||
local restore_padding = function(sync)
|
|
||||||
local command = "kitty @ set-spacing padding=default"
|
local command = "kitty @ set-spacing padding=default"
|
||||||
if not sync then
|
if not sync then
|
||||||
fn.jobstart(command, {
|
local function _4_(_, d, _0)
|
||||||
on_stderr = function(_, d, _)
|
if (#d > 1) then
|
||||||
if #d > 1 then
|
return vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG)
|
||||||
vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG)
|
else
|
||||||
end
|
return nil
|
||||||
end,
|
end
|
||||||
})
|
end
|
||||||
|
return ___fn___.jobstart(command, {on_stderr = _4_})
|
||||||
else
|
else
|
||||||
fn.system(command)
|
return ___fn___.system(command)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M.setup = function()
|
M.setup = function()
|
||||||
autocmd({ "VimResume", "VimEnter" }, {
|
local function _7_()
|
||||||
pattern = "*",
|
return no_padding()
|
||||||
callback = function()
|
end
|
||||||
no_padding()
|
autocmd({"VimResume", "VimEnter"}, {callback = _7_, group = autogroup("SpacingRemove", {clear = true}), pattern = "*"})
|
||||||
end,
|
local function _8_()
|
||||||
group = autogroup("SpacingRemove", { clear = true }),
|
return restore_padding(true)
|
||||||
})
|
end
|
||||||
|
return autocmd({"VimLeavePre", "VimSuspend"}, {callback = _8_, group = autogroup("SpacingRestore", {clear = true})})
|
||||||
autocmd({ "VimLeavePre", "VimSuspend" }, {
|
|
||||||
callback = function()
|
|
||||||
restore_padding(true)
|
|
||||||
end,
|
|
||||||
group = autogroup("SpacingRestore", { clear = true }),
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in a new issue