♻️ refactor(nvim): use function for zenmode plugin commands and change keybiding to activate the mode

This commit is contained in:
Sergio Laín 2024-01-20 18:24:19 +01:00
parent 7ec13bd1dc
commit 3d1264b171
No known key found for this signature in database
GPG key ID: 14C9B8080681777B

View file

@ -1,51 +1,40 @@
local Util = require("lazyvim.util") local Util = require("lazyvim.util")
local executeCommandIfExists = function(command)
if vim.fn.exists(command) ~= 0 then
vim.cmd(command)
end
end
return { return {
{ {
"folke/zen-mode.nvim", "folke/zen-mode.nvim",
cmd = "ZenMode", cmd = "ZenMode",
keys = { { "<leader>uz", "<cmd>ZenMode<cr>", desc = "Toggle Zen Mode" } }, keys = { { "<leader>z", "<cmd>ZenMode<cr>", desc = "Zen Mode" } },
opts = { opts = {
on_open = function(_) on_open = function(_)
vim.opt.laststatus = 0 vim.opt.laststatus = 0
if vim.fn.exists(":SatelliteDisable") ~= 0 then executeCommandIfExists(":SatelliteDisable")
vim.cmd("SatelliteDisable") executeCommandIfExists(":ScrollViewDisable")
end executeCommandIfExists(":LspLensOff")
if vim.fn.exists(":ScrollViewDisable") ~= 0 then executeCommandIfExists(":NvimContextVtDisable")
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
Util.toggle.inlay_hints() Util.toggle.inlay_hints()
vim.cmd("Gitsigns toggle_current_line_blame") executeCommandIfExists(":Gitsigns toggle_current_line_blame")
end, end,
on_close = function() on_close = function()
vim.opt.laststatus = 3 vim.opt.laststatus = 3
if vim.fn.exists(":SatelliteEnable") ~= 0 then executeCommandIfExists(":SatelliteEnable")
vim.cmd("SatelliteEnable") executeCommandIfExists(":ScrollViewEnable")
end executeCommandIfExists(":LspLensOn")
if vim.fn.exists(":ScrollViewEnable") ~= 0 then executeCommandIfExists(":NvimContextVtEnable")
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
Util.toggle.inlay_hints() Util.toggle.inlay_hints()
vim.cmd("Gitsigns toggle_current_line_blame") executeCommandIfExists(":Gitsigns toggle_current_line_blame")
end, end,
}, },
}, },
{ {
"folke/twilight.nvim", "folke/twilight.nvim",
cmd = "Twilight", cmd = "Twilight",
keys = { { "<leader>uZ", "<cmd>Twilight<cr>", desc = "Toggle Twilight" } }, keys = { { "<leader>Z", "<cmd>Twilight<cr>", desc = "Zen Twilight" } },
opts = {}, opts = {},
}, },
} }