diff --git a/README.md b/README.md index b75c6a7..f8c85e4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,10 @@ Plugin 'kdheepak/lazygit.vim' ### Usage ```vim -" lazygit + +let g:lazygit_floating_window_winblend = 5 " transparency of floating window + +" setup mapping to call :LazyGit nnoremap lg :LazyGit ``` diff --git a/lua/lazygit.lua b/lua/lazygit.lua index 4c0dd02..d2752ac 100644 --- a/lua/lazygit.lua +++ b/lua/lazygit.lua @@ -1,6 +1,8 @@ local api = vim.api local fn = vim.fn +local OPTIONS = {} + local function echom(message) api.nvim_command('echom "' .. tostring(message) .. '"') end @@ -16,7 +18,7 @@ function open_floating_window() -- create a unlisted scratch buffer for the border local border_buffer = api.nvim_create_buf(false, true) - api.nvim_buf_set_option(buffer, 'bufhidden', 'hide') + api.nvim_buf_set_option(buffer, 'bufhidden', 'wipe') api.nvim_buf_set_option(buffer, 'filetype', 'lazygit') local columns = api.nvim_get_option("columns") @@ -58,10 +60,11 @@ function open_floating_window() local border_window = api.nvim_open_win(border_buffer, true, border_opts) api.nvim_command('set winhl=Normal:Floating') local window = api.nvim_open_win(buffer, true, opts) - api.nvim_command('set winhl=Normal:Floating') + + 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 api.nvim_command('au BufWipeout execute "silent bwipeout!"' .. border_buffer) - api.nvim_command('au BufLeave hide') return window end @@ -102,6 +105,11 @@ function lazygit() exec_lazygit_command() end +function setup() + OPTIONS.lazygit_floating_window_winblend = api.nvim_get_var("lazygit_floating_window_winblend") +end + return { + setup = setup, lazygit = lazygit, } diff --git a/plugin/lazygit.vim b/plugin/lazygit.vim index ca206ae..c42d471 100644 --- a/plugin/lazygit.vim +++ b/plugin/lazygit.vim @@ -7,6 +7,12 @@ set cpoptions&vim """""""""""""""""""""""""""""""""""""""""""""""""""""" +if !exists('g:lazygit_floating_window_winblend') + let g:lazygit_floating_window_winblend = 5 +endif + +lua require 'lazygit'.setup() + let s:lazygit_lua_loc = expand(':h:r') . '/../lua/' exe "lua package.path = package.path .. ';". s:lazygit_lua_loc."?/init.lua'"