feat(fugitive): replace git status tab with toggle in current
This commit is contained in:
@@ -1,10 +1,35 @@
|
|||||||
-- https://github.com/tpope/vim-fugitive
|
-- https://github.com/tpope/vim-fugitive
|
||||||
|
|
||||||
local function git_status_tab()
|
local function open_git_status()
|
||||||
vim.cmd.tabnew()
|
local previous_win = vim.api.nvim_get_current_win()
|
||||||
vim.cmd("leftabove vertical G")
|
vim.cmd("leftabove vertical G")
|
||||||
vim.cmd("vertical resize 50")
|
vim.api.nvim_win_set_width(0, 50)
|
||||||
vim.cmd.set("wfw")
|
vim.api.nvim_set_option_value("winfixwidth", true, { scope = "local" })
|
||||||
|
vim.api.nvim_set_current_win(previous_win)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function get_git_status_win()
|
||||||
|
local current_tabpage = vim.api.nvim_get_current_tabpage()
|
||||||
|
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(current_tabpage)) do
|
||||||
|
local buf = vim.api.nvim_win_get_buf(win)
|
||||||
|
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
|
||||||
|
if
|
||||||
|
buftype == "nowrite"
|
||||||
|
and vim.api.nvim_buf_get_name(buf):match("^fugitive://.*%.git//$")
|
||||||
|
then
|
||||||
|
return win
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function toggle_git_status()
|
||||||
|
local win = get_git_status_win()
|
||||||
|
if win then
|
||||||
|
vim.api.nvim_win_close(win, false)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
open_git_status()
|
||||||
end
|
end
|
||||||
|
|
||||||
---@type LazyPluginSpec
|
---@type LazyPluginSpec
|
||||||
|
|||||||
Reference in New Issue
Block a user