-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Use floating window instead of split #68
Comments
+1 |
I have something for neovim Since you can define the command to create the window for peekabo
That function I just use to create centered windows, found it a while ago in reddit and it works with peekabo then just |
@mxdevmanuel works perfectly, this is awesome. thanks! |
@mxdevmanuel how do you close the outer window with the buffer for the borders? |
@weilbith with peekabo it just works, however when I use this for other purposes I see this behavior you get, but never have gotten around it, sorry, best luck with that |
Funny. How should Peekabo know about the outer window? ^^ |
Cool, thanks for the reference! 🙏 So this issue could be closed with maybe a hint/example in the doc file? 🤔 |
Will this work for vim8? |
Ah no, of course not. This is using the |
It would be cool if we can use fzf function to display the floating window since it support both neovim & vim8 |
+1 |
Is there a way to adapt this to work in visual mode? I get a blank floating window when I trigger peekaboo in visual mode. |
I'm having this issue for a long time now, and I just kind of learned to live with it.. :( Linux work-x1c-arch 5.11.2-arch1-1 #1 SMP PREEMPT Fri, 26 Feb 2021 18:26:41 +0000 x86_64 GNU/Linux NVIM v0.4.4
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.4.4/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser
Features: +acl +iconv +tui Also I see people complaining at #72. For me, removing the snippet to popup the window fixes the issue, but I kind of wanna have them both :) |
Since it's NOT fixed for Vim, please do not close it. |
Replying to @mroavi's comment: #68 (comment), quoted:
Yeah! I've hacked that script you quoted (link: #68 (comment)) so that it works with peekaboo in visual mode, but it loses the borders around the floating window (still very usable for me). Here's the new function: function! CreateCenteredFloatingWindow() abort
if(!has('nvim'))
split
new
else
let width = float2nr(&columns * 0.6)
let height = float2nr(&lines * 0.6)
let top = ((&lines - height) / 2) - 1
let left = (&columns - width) / 2
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}
let s:buf = nvim_create_buf(v:false, v:true)
call nvim_open_win(s:buf, v:true, opts)
endif
endfunction As mentioned, you have to add a setting to use it when peekaboo is triggered: let g:peekaboo_window="call CreateCenteredFloatingWindow()" Here's what it looks like to me: |
A Lua version of the above: function utils.create_centered_floating_window()
local width = math.floor(vim.o.columns * 0.8)
local height = math.floor(vim.o.lines * 0.8)
local opts = {
relative = "editor",
width = width,
height = height,
col = math.floor((vim.o.columns - width) / 2),
row = math.floor((vim.o.lines - height) / 2) - 1,
style = "minimal",
}
local top = "╭" .. string.rep("─", width - 2) .. "╮"
local mid = "│" .. string.rep(" ", width - 2) .. "│"
local bot = "╰" .. string.rep("─", width - 2) .. "╯"
local lines = { top }
for i = 2, height - 1 do
lines[i] = mid
end
lines[height] = bot
local buf = api.nvim_create_buf(false, true)
api.nvim_buf_set_lines(buf, 0, -1, true, lines)
api.nvim_open_win(buf, true, opts)
api.nvim_set_option("winhl", "Normal:Floating")
local opts_new = {
relative = opts.relative,
width = opts.width - 4,
height = opts.height - 2,
col = opts.col + 2,
row = opts.row + 1,
style = opts.style,
}
api.nvim_open_win(api.nvim_create_buf(false, true), true, opts_new)
vim.cmd("au BufWipeout <buffer> execute 'bw " .. tostring(buf) .. "'")
end That said, there are some alternative plugins for Neovim users: |
junegunn/vim-peekaboo#68 (comment) There are alternative plugins for Neovim users: https://github.com/tversteeg/registers.nvim https://github.com/gennaro-tedesco/nvim-peekup
I'm a big fan of vim peekaboo. However sometimes the split window destroys my current workspace (when using multiple splits). Therefore I want to ask if it would be possible to use the new vim 8 popup or neovim floating windows for showing the buffer contents.
The text was updated successfully, but these errors were encountered: