Remove ToggleFullscreen
This commit is contained in:
parent
575eaf9ec3
commit
5b3f0a99bb
@ -2,10 +2,6 @@
|
|||||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||||
-- Add any additional keymaps here
|
-- Add any additional keymaps here
|
||||||
|
|
||||||
local max_height = vim.o.lines
|
|
||||||
local max_width = vim.o.columns
|
|
||||||
local fullscreen_inset = 2
|
|
||||||
|
|
||||||
function ToggleBackground()
|
function ToggleBackground()
|
||||||
if vim.opt.background:get() == "dark" then
|
if vim.opt.background:get() == "dark" then
|
||||||
vim.opt.background = "light"
|
vim.opt.background = "light"
|
||||||
@ -14,46 +10,9 @@ function ToggleBackground()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ToggleFullscreen()
|
|
||||||
local bufid = vim.api.nvim_get_current_buf()
|
|
||||||
local winid = vim.api.nvim_get_current_win()
|
|
||||||
|
|
||||||
local fullscreen_win = vim.w.fullscreen_win
|
|
||||||
if fullscreen_win then
|
|
||||||
vim.api.nvim_win_close(winid, false)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, id in ipairs(vim.api.nvim_list_wins()) do
|
|
||||||
local res
|
|
||||||
res, fullscreen_win = pcall(function()
|
|
||||||
return vim.api.nvim_win_get_var(id, "fullscreen_win")
|
|
||||||
end)
|
|
||||||
if res and fullscreen_win then
|
|
||||||
vim.api.nvim_set_current_win(id)
|
|
||||||
vim.print(true)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
winid = vim.api.nvim_open_win(bufid, true, {
|
|
||||||
relative = "editor",
|
|
||||||
border = "rounded",
|
|
||||||
row = fullscreen_inset,
|
|
||||||
col = fullscreen_inset,
|
|
||||||
width = max_width - fullscreen_inset - fullscreen_inset,
|
|
||||||
height = max_height - fullscreen_inset - fullscreen_inset - 1,
|
|
||||||
title = "Fullscreen (" .. vim.api.nvim_buf_get_name(bufid) .. ")",
|
|
||||||
title_pos = "center",
|
|
||||||
})
|
|
||||||
vim.api.nvim_win_set_var(winid, "fullscreen_win", true)
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set(
|
vim.keymap.set(
|
||||||
"n",
|
"n",
|
||||||
"<F5>",
|
"<F5>",
|
||||||
"<cmd>lua ToggleBackground()<cr>",
|
"<cmd>lua ToggleBackground()<cr>",
|
||||||
{ desc = "Switch between dark and light themes", noremap = true }
|
{ desc = "Switch between dark and light themes", noremap = true }
|
||||||
)
|
)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>m", ToggleFullscreen, { desc = "Maximize window", noremap = true })
|
|
||||||
|
Loading…
Reference in New Issue
Block a user