Comments (17)
I have something for neovim
Since you can define the command to create the window for peekabo
function! CreateCenteredFloatingWindow()
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 top = "╭" . repeat("─", width - 2) . "╮"
let mid = "│" . repeat(" ", width - 2) . "│"
let bot = "╰" . repeat("─", width - 2) . "╯"
let lines = [top] + repeat([mid], height - 2) + [bot]
let s:buf = nvim_create_buf(v:false, v:true)
call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines)
call nvim_open_win(s:buf, v:true, opts)
set winhl=Normal:Floating
let opts.row += 1
let opts.height -= 2
let opts.col += 2
let opts.width -= 4
call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts)
au BufWipeout <buffer> exe 'bw '.s:buf
endfunction
That function I just use to create centered windows, found it a while ago in reddit and it works with peekabo
then just
let g:peekaboo_window="call CreateCenteredFloatingWindow()"
I don't have somethinglike this for vim8 though, hope it helps
from vim-peekaboo.
I have something for neovim
Since you can define the command to create the window for peekabo
function! CreateCenteredFloatingWindow() 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 top = "╭" . repeat("─", width - 2) . "╮" let mid = "│" . repeat(" ", width - 2) . "│" let bot = "╰" . repeat("─", width - 2) . "╯" let lines = [top] + repeat([mid], height - 2) + [bot] let s:buf = nvim_create_buf(v:false, v:true) call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines) call nvim_open_win(s:buf, v:true, opts) set winhl=Normal:Floating let opts.row += 1 let opts.height -= 2 let opts.col += 2 let opts.width -= 4 call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts) au BufWipeout <buffer> exe 'bw '.s:buf endfunction
That function I just use to create centered windows, found it a while ago in reddit and it works with peekabo
then just
let g:peekaboo_window="call CreateCenteredFloatingWindow()"
I don't have somethinglike this for vim8 though, hope it helps
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.
from vim-peekaboo.
Replying to @mroavi's comment: #68 (comment), quoted:
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.
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:
from vim-peekaboo.
It would be cool if we can use fzf function to display the floating window since it support both neovim & vim8
from vim-peekaboo.
Cool, thanks for the reference! 🙏
So this issue could be closed with maybe a hint/example in the doc file? 🤔
from vim-peekaboo.
+1
from vim-peekaboo.
@mxdevmanuel works perfectly, this is awesome. thanks!
from vim-peekaboo.
@mxdevmanuel how do you close the outer window with the buffer for the borders?
For me it always remains open. I tried to add a WinClosed
autocmd to the inner
buffer to close the outer window. Fails atm. I'm sure I can fix that, but how
does it work for you?
from vim-peekaboo.
@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
from vim-peekaboo.
Funny. How should Peekabo know about the outer window? ^^
Anyways no worries. It works fine without fancy borders for now and does not
"destroy" the window partition anymore.
from vim-peekaboo.
@weilbith Funny indeed, in theory the au BufWipeout <buffer> exe 'bw '.s:buf
should take care of that but who knows, something people do, as mentioned in here setting a different background color allows to differentiate from the underlying window, maybe that can help
EDIT: I tried it and it works
from vim-peekaboo.
Will this work for vim8?
from vim-peekaboo.
Ah no, of course not. This is using the nvim
specific API.
from vim-peekaboo.
It would be cool if we can use fzf function to display the floating window since it support both neovim & vim8
+1
from vim-peekaboo.
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 :)
from vim-peekaboo.
Ah no, of course not. This is using the
nvim
specific API.
Since it's NOT fixed for Vim, please do not close it.
from vim-peekaboo.
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:
from vim-peekaboo.
Related Issues (20)
- Window is being resized when pasting in insert mode HOT 2
- Plugin regularly (but unpredictably) crashes neovim HOT 5
- when this plugin be loaded lazy will occur some problem HOT 1
- screencapture tool used in README?
- Can it support redir @?
- Can it display the type of register?
- Blank window in visual mode HOT 1
- Not working in Command mode HOT 1
- cmd height changed to maximum HOT 5
- Breaks Ex mode if used
- Peekaboo window does not show leading whitespaces
- [Feature Request] foldcolumn independent window HOT 1
- [Feature Request] show special key combinations instead of bytes: <Esc> instead of ^[ HOT 1
- [bug] conflict with startify
- vim-peekaboo sets cmdheight to max, meaning I can only see 1 line of my window output HOT 5
- Feature Request: change (or disable) default maps HOT 3
- change location of sidebar? HOT 2
- Ctrl-R Insert Mode places register one char before last
- Peekaboo makes it impossible to paste in telescope HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-peekaboo.