Closed kevinhwang91 closed 3 weeks ago
It's so weird. The numhl works as expect by using call timer_start(0, { -> execute('VimadeDisable')})
instead of execute 'VimadeDisable'
. Maybe casued by invoking VimadeDisable
inside WinEnter
event?
unfadeAll needed a few updates to support signs and basegroups, it should work as expected now without the timer_start
This sounds like a nice feature and we should be able to include it
I found that in the floating window, no matter VimadeEnable
or VimadeDisable
will change the last window (Running wincmd p
in multiple windows in a tabpage will produce different behavior than before running VimadeEnable
or VimadeDisable
).
I solve this issue by these code:
function s:toggle_vimade(enable) abort
let cur_win = nvim_get_current_win()
noautocmd wincmd p
let last_win = nvim_get_current_win()
noautocmd wincmd p
if a:enable
execute 'VimadeEnable'
else
execute 'VimadeDisable'
endif
noautocmd call nvim_set_current_win(last_win)
noautocmd call nvim_set_current_win(cur_win)
endfunction
function s:fade_except_floating() abort
if empty(nvim_win_get_config(0)['relative'])
if exists('g:vimade_running') && g:vimade_running != 0
call s:toggle_vimade(0)
endif
else
if !exists('g:vimade_running') || g:vimade_running == 0
call s:toggle_vimade(1)
endif
endif
endfunction
Sounds like a bug, if you can send me steps to reproduce I'll take a look. Still have it in my mind to add a config option for your modal behavior
You can reproduce by this script:
cat reproduce.vim
call plug#begin('~/.config/nvim/plugged')
Plug 'TaDaa/vimade'
call plug#end()
function CreateFloating() abort
let buf_handle = nvim_create_buf(v:false, v:true)
return nvim_open_win(buf_handle, v:true, {
\'relative': 'editor',
\'height': float2nr(0.5* &lines),
\'width': float2nr(0.5 * &columns),
\'col': float2nr(0.25 * &columns),
\'row': float2nr(0.25 * &lines)})
endfunction
function Reproduce(vimade_enable) abort
execute 'VimadeDisable'
split
split
wincmd w
echom 'current win before openning floating window: ' . nvim_get_current_win()
call CreateFloating()
if a:vimade_enable
execute 'VimadeEnable'
" comment out VimadeDisable have the same result
" Only show my code logic
execute 'VimadeDisable'
endif
close
echom 'current win after closing floating window: ' . nvim_get_current_win()
endfunction
You can compare the difference between nvim -u reproduce.vim +'call Reproduce(0)'
and nvim -u reproduce.vim +'call Reproduce(1)'
.
This only popup functionality is now officially supported - thank you the request and contributing! This will end up going in the docs somewhere
The only_behind_float_windows
is just an arbitrary rule name. Using default
as the rule name will override the default
rule found in globals.lua
Lua:
require('vimade').setup({
blocklist = {
only_behind_float_windows = function (win, current)
-- current can be nil
if (win.win_config.relative == '') and (current and current.win_config.relative ~= '') then
return false
end
return true
end
}
})
Python:
from vimade import vimade
def only_behind_float_windows (win, current):
if (win.win_config['relative'] == '') and (current and current.win_config['relative'] != ''):
return False
return True
vimade.setup(blocklist = {
'only_behind_float_windows': only_behind_float_windows,
})
The secondary issue here with inconsistent window-id appears to be fixed as well (the plugin has mostly been rewritten so probably got fixed along the way)
I make a trick for achieving this feature.
Is anyone interested?