Use global window
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
local api = vim.api
|
local api = vim.api
|
||||||
local fn = vim.fn
|
local fn = vim.fn
|
||||||
|
|
||||||
|
local window
|
||||||
|
|
||||||
local OPTIONS = {
|
local OPTIONS = {
|
||||||
lazygit_floating_window_scaling_factor = 0.9,
|
lazygit_floating_window_scaling_factor = 0.9,
|
||||||
lazygit_floating_window_winblend = 0,
|
lazygit_floating_window_winblend = 0,
|
||||||
@@ -15,7 +17,6 @@ local function is_lazygit_available()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function open_floating_window()
|
function open_floating_window()
|
||||||
|
|
||||||
-- create a unlisted scratch buffer
|
-- create a unlisted scratch buffer
|
||||||
local buffer = api.nvim_create_buf(false, true)
|
local buffer = api.nvim_create_buf(false, true)
|
||||||
-- create a unlisted scratch buffer for the border
|
-- create a unlisted scratch buffer for the border
|
||||||
@@ -62,13 +63,12 @@ function open_floating_window()
|
|||||||
|
|
||||||
local border_window = api.nvim_open_win(border_buffer, true, border_opts)
|
local border_window = api.nvim_open_win(border_buffer, true, border_opts)
|
||||||
api.nvim_command('set winhl=Normal:Floating')
|
api.nvim_command('set winhl=Normal:Floating')
|
||||||
local window = api.nvim_open_win(buffer, true, opts)
|
window = api.nvim_open_win(buffer, true, opts)
|
||||||
|
|
||||||
api.nvim_command('set winblend=' .. OPTIONS.lazygit_floating_window_winblend)
|
api.nvim_command('set winblend=' .. OPTIONS.lazygit_floating_window_winblend)
|
||||||
|
|
||||||
-- use autocommand to ensure that the border_buffer closes at the same time as the main buffer
|
-- use autocommand to ensure that the border_buffer closes at the same time as the main buffer
|
||||||
api.nvim_command('au BufWipeout <buffer> execute "silent bwipeout!"' .. border_buffer)
|
api.nvim_command('au BufWipeout <buffer> execute "silent bwipeout!"' .. border_buffer)
|
||||||
return window
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function project_root_dir()
|
local function project_root_dir()
|
||||||
@@ -104,7 +104,7 @@ function lazygit()
|
|||||||
print("Please install lazygit. Check documentation for more information")
|
print("Please install lazygit. Check documentation for more information")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local window = open_floating_window()
|
open_floating_window()
|
||||||
exec_lazygit_command()
|
exec_lazygit_command()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user