From 3d1264b171d6c576a25b65b370e2223928f46d52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sat, 20 Jan 2024 18:24:19 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(nvim):=20use=20fu?= =?UTF-8?q?nction=20for=20zenmode=20plugin=20commands=20and=20change=20key?= =?UTF-8?q?biding=20to=20activate=20the=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../nvim/lua/plugins/extras/ui/zen-mode.lua | 45 +++++++------------ 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/.config/nvim/lua/plugins/extras/ui/zen-mode.lua b/.config/nvim/lua/plugins/extras/ui/zen-mode.lua index ca834c36..9405c863 100644 --- a/.config/nvim/lua/plugins/extras/ui/zen-mode.lua +++ b/.config/nvim/lua/plugins/extras/ui/zen-mode.lua @@ -1,51 +1,40 @@ local Util = require("lazyvim.util") +local executeCommandIfExists = function(command) + if vim.fn.exists(command) ~= 0 then + vim.cmd(command) + end +end return { { "folke/zen-mode.nvim", cmd = "ZenMode", - keys = { { "uz", "ZenMode", desc = "Toggle Zen Mode" } }, + keys = { { "z", "ZenMode", desc = "Zen Mode" } }, opts = { on_open = function(_) vim.opt.laststatus = 0 - if vim.fn.exists(":SatelliteDisable") ~= 0 then - vim.cmd("SatelliteDisable") - end - if vim.fn.exists(":ScrollViewDisable") ~= 0 then - vim.cmd("ScrollViewDisable") - end - if vim.fn.exists(":LspLensOff") ~= 0 then - vim.cmd("LspLensOff") - end - if vim.fn.exists(":NvimContextVtToggle") ~= 0 then - vim.cmd("NvimContextVtToggle") - end + executeCommandIfExists(":SatelliteDisable") + executeCommandIfExists(":ScrollViewDisable") + executeCommandIfExists(":LspLensOff") + executeCommandIfExists(":NvimContextVtDisable") Util.toggle.inlay_hints() - vim.cmd("Gitsigns toggle_current_line_blame") + executeCommandIfExists(":Gitsigns toggle_current_line_blame") end, on_close = function() vim.opt.laststatus = 3 - if vim.fn.exists(":SatelliteEnable") ~= 0 then - vim.cmd("SatelliteEnable") - end - if vim.fn.exists(":ScrollViewEnable") ~= 0 then - vim.cmd("ScrollViewEnable") - end - if vim.fn.exists(":LspLensOn") ~= 0 then - vim.cmd("LspLensOn") - end - if vim.fn.exists(":NvimContextVtToggle") ~= 0 then - vim.cmd("NvimContextVtToggle") - end + executeCommandIfExists(":SatelliteEnable") + executeCommandIfExists(":ScrollViewEnable") + executeCommandIfExists(":LspLensOn") + executeCommandIfExists(":NvimContextVtEnable") Util.toggle.inlay_hints() - vim.cmd("Gitsigns toggle_current_line_blame") + executeCommandIfExists(":Gitsigns toggle_current_line_blame") end, }, }, { "folke/twilight.nvim", cmd = "Twilight", - keys = { { "uZ", "Twilight", desc = "Toggle Twilight" } }, + keys = { { "Z", "Twilight", desc = "Zen Twilight" } }, opts = {}, }, }