Offload sticky buffer logic to stickybuf.nvim

This commit is contained in:
Steven Arcangeli 2021-07-07 13:27:00 -07:00
parent ba8b030aaf
commit 404054ad54
2 changed files with 7 additions and 9 deletions

View file

@ -243,3 +243,9 @@ hi AerialFunctionIcon guifg=#cb4b16 guibg=NONE guisp=NONE gui=NONE cterm=NONE
" There's also this group for the cursor position
hi link AerialLine QuickFixLine
```
## FAQ
**Q: I accidentally opened a file into the aerial window and it looks bad. How can I prevent this from happening?**
Try installing [stickybuf](https://github.com/stevearc/stickybuf.nvim). It was designed to prevent exactly this problem.

View file

@ -24,19 +24,11 @@ local function close_orphans()
end
M.on_enter_buffer = function()
local mybuf = vim.api.nvim_get_current_buf()
if util.is_floating_win() then
return
end
-- If the user tried to open a non-aerial buffer inside the aerial window,
-- close the window and re-open the buffer.
mybuf = vim.api.nvim_get_current_buf()
if vim.w.is_aerial_win and not util.is_aerial_buffer(mybuf) then
vim.api.nvim_win_close(0, false)
vim.api.nvim_set_current_buf(mybuf)
end
local mybuf = vim.api.nvim_get_current_buf()
if not util.is_aerial_buffer(mybuf) then
if config.close_behavior == "close" then
close_orphans()