function! CloseFloatingWindowsByFileTypePattern(filetype_pattern) abort
let floating_windows = filter(nvim_list_wins(), "nvim_win_get_config(v:val)['relative'] !=# ''")
let close_windows = filter(floating_windows, "getbufvar(nvim_win_get_buf(v:val), '&filetype') =~# a:filetype_pattern")
call map(close_windows, 'nvim_win_close(v:val, v:false)')
endfunction
function! s:auto_close_floating_windows() abort
if nvim_win_get_config(0)['relative'] !=# ''
return
endif
call CloseFloatingWindowsByFileTypePattern('denite')
endfunction
au BufEnter * call s:auto_close_floating_windows()
References
- Neovim window api document(2020/9/1).