volskaya / windovigation.nvim Goto Github PK
View Code? Open in Web Editor NEWNvim plugin that scopes buffers to window split, like VScode and Evil Emacs, instead of a global buffer list.
License: Apache License 2.0
Nvim plugin that scopes buffers to window split, like VScode and Evil Emacs, instead of a global buffer list.
License: Apache License 2.0
When I focus a terminal buffer, or a buffer opened via ssh (e.g. nvim scp://user@hostname
), for a second time after it's already been read (whether from the same window, different window, different tab, etc.) I receive the warning from the associated line in utils.lua:
windovigation.nvim/lua/windovigation/utils.lua
Lines 47 to 49 in af5845e
Here's an example output of vim.fn.expand('%')
for these situations:
term://~/.config/nvim//185059:/usr/bin/zsh
scp://user@hostname/.bashrc
Some relevant information is at :h terminal-start
and :h default-autocmds
and :h netrw
. (edit: my suggestion is that these type of files, and probably ftp files, should maybe count as absolute paths here)
Another terminal/ssh buffer issue comes up due to, I believe, the layout.handle_layout_change()
function and the utils.maybe_close_buffer_for_file()
function. Suppose you have a split window with a terminal/ssh buffer open (the only window that has that buffer), and you close that window. Then open a split window again, then open that same buffer, and finally close that window again. (imagine toggling a show/hide of that terminal buffer in a split window like the bottom-panel in VS Code).
On that second window-close command, this condition evaluates to true and deletes the terminal/ssh buffer:
windovigation.nvim/lua/windovigation/utils.lua
Lines 65 to 67 in af5845e
This evaluation isn't unique to terminal/ssh buffers. But if you were to reopen the terminal buffer expecting to see your previous work in that terminal, it would be gone, unlike a regular buffer, where so long as you saved your work before deletion, your work is still preserved. And since working over ssh isn't always zippy, re-opening a file over ssh is noticeably slower than browsing to it via the bufist.
(worth noting that even when a normal buffer is removed from the buffer list in this instance, this may be an issue for people who use e.g. Telescope buffers
to navigate or aren't expecting a BufDelete event for whatever reason)
Would adding a separate handler for the TermOpen
event or something similar help with these two issues (the warning and the terminal buffer deletion)? I'm hacking my way around it by adding a condition to ignore the file deletion if its buftype == terminal
in my fork, but I assume that will introduce unintended behavior at some point. Not sure what to do for files opened over ssh.
Hope this wasn't too verbose. I'm assuming this same issue applies to files over ftp. For what it's worth, my personal workflow doesn't actually use windovigation's commands in windows/tabs with terminal buffers. This is a great plugin! Thanks for sharing it.
Tested with this lazy.nvim config:
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
"nvim-lua/plenary.nvim",
{
"nvim-telescope/telescope.nvim",
lazy = false,
config = true,
keys = {
{
"<M-b>",
function()
require("telescope.builtin").buffers()
end,
desc = "Telescope: buffers",
},
{
"<M-f>",
function()
require("telescope.builtin").find_files()
end,
desc = "Telescope: Find Files (cwd)",
},
},
},
{
"volskaya/windovigation.nvim",
lazy = false,
config = true,
keys = {
{
"<BS>",
function()
require("windovigation.actions").move_to_previous_file()
end,
desc = "WinNav - Prev",
},
{
"<Del>",
function()
require("windovigation.actions").move_to_next_file()
end,
desc = "WinNav - Next",
},
},
},
}, {})
vim.keymap.set("n", "<C-q>", "<cmd>qa<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<M-down>", "<c-w>j", { desc = "Move to window below" })
vim.keymap.set("n", "<M-up>", "<c-w>k", { desc = "Move to window above" })
vim.keymap.set("n", "<M-left>", "<c-w>h", { desc = "Move to window left" })
vim.keymap.set("n", "<M-right>", "<c-w>l", { desc = "Move to window right" })
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.