The title pretty much says all.
I have the following custom script (which resizes windows for me):
" CUSTOM WINDOW SPACE MANAGEMENT ************************************
function! s:special_cols_width()
let numberwidth = max([&numberwidth, strlen(line('$'))+1])
let numwidth = (&number || &relativenumber)? numberwidth : 0
let foldwidth = &foldcolumn
if &signcolumn == 'yes'
let signwidth = 2
elseif &signcolumn == 'auto'
let signs = execute(printf('sign place buffer=%d', bufnr('')))
let signs = split(signs, "\n")
let signwidth = len(signs)>2? 2: 0
else
let signwidth = 0
endif
return numwidth + foldwidth + signwidth
endfunction
function! s:optimize_win_width()
let s:buf_name = expand('%:t')
let s:longest_line_length = max(map(range(1, line('$')), "col([v:val, '$'])"))
let s:special_cols_width = s:special_cols_width()
let s:used_win_width = s:special_cols_width + s:longest_line_length
let s:total_win_width=winwidth(0)
let s:current_split_width = winwidth('%')
let s:resize_to = s:used_win_width - 1
let s:whole_vim_width = &columns
let s:max_single_window_width_percent = 0.5
let w:width_optimized_to = s:resize_to
" RETURN IF RUNNING FROM FLOATING WIN
if ?????
return
end
" Skip resizing if window would be resized over allowed threshold
let s:max_allowed_win_width = s:whole_vim_width * s:max_single_window_width_percent
if (s:resize_to > s:max_allowed_win_width)
let s:resize_to = float2nr(s:max_allowed_win_width)
endif
if (s:used_win_width != s:total_win_width)
execute "vertical resize " . s:resize_to
endif
endfunction
autocmd WinEnter * call s:optimize_win_width()
autocmd WinNew * call s:optimize_win_width()
autocmd BufReadPost * call s:optimize_win_width()
" <!!!!!!!!**************!!!!!!!!>
But I'd like to skip it from running in any floating window.
I left the following pseudocode in the snippet above:
" RETURN IF RUNNING FROM FLOATING WIN
if ?????
return
end
My question is. How to write condition checking if the current window is floating? I want to prevent the execution of the script in any floating window.
Using the following nvim version:
NVIM v0.5.0-dev
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -g -O2 -fdebug-prefix-map=/build/neovim-VDvMwQ/neovim-0.5.0+ubuntu2+git202106100025-fd7e77b22-d569569c9=. -fstack-protector-strong -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim-VDvMwQ/neovim-0.5.0+ubuntu2+git202106100025-fd7e77b22-d569569c9/build/config -I/build/neovim-VDvMwQ/neovim-0.5.0+ubuntu2+git202106100025-fd7e77b22-d569569c9/src -I/build/neovim-VDvMwQ/neovim-0.5.0+ubuntu2+git202106100025-fd7e77b22-d569569c9/.deps/usr/include -I/usr/include -I/build/neovim-VDvMwQ/neovim-0.5.0+ubuntu2+git202106100025-fd7e77b22-d569569c9/build/src/nvim/auto -I/build/neovim-VDvMwQ/neovim-0.5.0+ubuntu2+git202106100025-fd7e77b22-d569569c9/build/include
Skompilowany przez buildd@lgw01-amd64-024
Features: +acl +iconv +tui
See ":help feature-compile"
vimrc systemu: "$VIM/sysinit.vim"
odwet dla $VIM-a: "/usr/share/nvim"
Run :checkhealth for more info