From e58f6efffee06f46caf10c52d298044105a1b620 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Sat, 1 Feb 2025 14:20:52 -0800 Subject: [PATCH] feat: fennelize kitty-padding --- fnl/scripts/kitty-padding.fnl | 37 ++++++++++++++++++ lua/scripts/kitty-padding.lua | 71 +++++++++++++++-------------------- 2 files changed, 67 insertions(+), 41 deletions(-) create mode 100644 fnl/scripts/kitty-padding.fnl diff --git a/fnl/scripts/kitty-padding.fnl b/fnl/scripts/kitty-padding.fnl new file mode 100644 index 0000000..3a18d7a --- /dev/null +++ b/fnl/scripts/kitty-padding.fnl @@ -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 diff --git a/lua/scripts/kitty-padding.lua b/lua/scripts/kitty-padding.lua index cc1d24a..55138db 100644 --- a/lua/scripts/kitty-padding.lua +++ b/lua/scripts/kitty-padding.lua @@ -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 fn = vim.fn +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 function no_padding(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 - vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG) - end - end, - }) + local function _1_(_, d, _0) + if (#d > 1) then + return vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG) + else + return nil + end + end + return ___fn___.jobstart(command, {on_stderr = _1_}) else - fn.system(command) + return ___fn___.system(command) end end - -local restore_padding = function(sync) +local function restore_padding(sync) local command = "kitty @ set-spacing padding=default" if not sync then - fn.jobstart(command, { - on_stderr = function(_, d, _) - if #d > 1 then - vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG) - end - end, - }) + local function _4_(_, d, _0) + if (#d > 1) then + return vim.notify("Error setting window padding. Make sure kitty remote control is turned on.", vim.log.levels.DEBUG) + else + return nil + end + end + return ___fn___.jobstart(command, {on_stderr = _4_}) else - fn.system(command) + return ___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 }), - }) + local function _7_() + return no_padding() + end + autocmd({"VimResume", "VimEnter"}, {callback = _7_, group = autogroup("SpacingRemove", {clear = true}), pattern = "*"}) + local function _8_() + return restore_padding(true) + end + return autocmd({"VimLeavePre", "VimSuspend"}, {callback = _8_, group = autogroup("SpacingRestore", {clear = true})}) end - return M