Add option to set winblend

This commit is contained in:
Dheepak Krishnamurthy
2020-04-05 18:07:04 -06:00
parent d9b871a807
commit 3e33c08d7d
3 changed files with 21 additions and 4 deletions

View File

@@ -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 <silent> <leader>lg :LazyGit<CR>
```

View File

@@ -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 <buffer> execute "silent bwipeout!"' .. border_buffer)
api.nvim_command('au BufLeave <buffer> 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,
}

View File

@@ -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('<sfile>:h:r') . '/../lua/'
exe "lua package.path = package.path .. ';". s:lazygit_lua_loc."?/init.lua'"