axkirillov / hbac.nvim Goto Github PK
View Code? Open in Web Editor NEWHeuristic buffer auto-close
License: MIT License
Heuristic buffer auto-close
License: MIT License
Trying to get this to work well with early-retirement.nvim... Is there a way to hook pinning a buffer so that I can set vim.b.ignore_early_retirement = true
on the buffer as well and make early-retirement.nvim also ignore pinned buffers?
I like my Telescope <CR>
action to be select_drop
as opposed to just select
, but this plugin currently does not give me a way to specify that. Ideally there'd be a way to just add custom mappings somewhere, but for my purpose just a way to select the <CR>
action would be sufficient.
I'll currently work around this by hijacking attach_mappings
to inject my own mappings, but I recognize that this is wildly fragile and would like to not need to do that.
Given that the customization for actions in this plugin is somewhat different from what I'm used to (i.e., there's a set of functions you assign mappings to, as opposed to assigning functions to mappings), I don't really know how (and if) you'd like to do this, but I can take a crack at a PR if a direction for how a user would specify this in the config is suggested.
I've set a pretty small threshold(7) so I can always navigate with tabs across buffers. However, when I edit many files in one go, I simply can't open buffers till I close ones.
My proposition is to add an option to close edited buffers if they are saved and there is no place for opening a new buffer.
I can try implementing the feature, but first say pls, if there is any alternative already presented already..
First of all - thank you for the plugin. It will bring sanity to my buffer-apocalypse I sometimes have ๐
One of my biggest problems (in general) is the unnamed empty buffers. I tend to have a lot of them open because VIM likes to spam them on many occasions (i.e., when going to netrw).
Is it possible to prioritize removing the empty buffers when the threshold is met?
Thank you!
Odd issue, can't quite track it down, but I get the following error if I open the telescope extension a second time and press i anywhere in the buffer name I am searching for... Has anyone seen similar?
E5108: Error executing lua: ...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:269: attempt to call upvalue 'key_func' (a table value)
stack traceback:
...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:269: in function <...hare/nvim/lazy/telescope.nvim/lua/telescope/mappings.lua:268>
When I have a lot of files open, I usually end up navigating exclusively through Hbac Telescope
. I don't know how feasible it is, but I would love to be able to see the results in it sorted by most recently viewed.
I don't know if nvim has some concept of when a buffer was last open and visibile, and I'm sure it would get a little complicated like if you have splits with multiple files open... https://github.com/nvim-telescope/telescope-frecency.nvim is something in that space, but it has to use a sqlite database to do it.
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({
"axkirillov/hbac.nvim",
"olimorris/persisted.nvim",
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
}, {})
require("persisted").setup({ autoload = true })
require("hbac").setup({ })
[persisted.nvim]: Error loading the session! vim/_editor.lua:0: VimEnter Autocommands for "*"..script nvim_exec2() called at Vi
mEnter Autocommands for "*":0../home/martins3/.local/share/nvim/sessions/%home%martins3%core%linux@@main.vim, line 93: Vim(bwip
eout):E517: No buffers were wiped out: bwipe 1
Press ENTER or type command to continue
If require("hbac").setup({ })
is commented, the error message disappeared.
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1693350652
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/nix/store/4wq4i3zfc9g0g5b0d94rm36d9pfa4fqz-neovim-unwrapped-0.9.4/share/nvim
As @ditsuke and @technicalpickles have mentioned, the Telescope picker isn't implementing opts that a user might expect from a buffer picker, which is more or less the picker we were trying to imitate. This is my fault for not looking back at the buffer picker as a model towards the end of the PR.
Here's the structure of the builtin buffer picker (link)
pickers
.new(opts, {
prompt_title = "Buffers",
finder = finders.new_table {
results = buffers,
entry_maker = opts.entry_maker or make_entry.gen_from_buffer(opts),
},
previewer = conf.grep_previewer(opts),
sorter = conf.generic_sorter(opts),
default_selection_index = default_selection_idx,
})
:find()
and here's the hbac 'pin' picker as of release v1.2.0 (link)
M.pin_picker = function(opts)
local attach_mappings = require("hbac.telescope.attach_mappings")
local make_finder = require("hbac.telescope.make_finder").make_finder
opts = opts or {}
pickers
.new(opts, {
prompt_title = "Hbac Pin States",
finder = make_finder(),
sorter = telescope_conf.generic_sorter(opts),
attach_mappings = attach_mappings.attach_mappings,
previewer = telescope_conf.file_previewer(opts),
})
:find()
end
My oversight was not giving make_finder()
the opts
table and checking for the relevant builtin buffer picker opts in the function that builds the finder results (get_entries()
). Since the sorter and the previewer functions are called straight from Telescope, I just stopped thinking about the opts.
So, we need to pass the opts table to the function that builds the finder. The function that checks the opts and filters the buffer list is unexposed in the Telescope code unfortunately. The blunt thing to do would be to just copy that code into the make_finder function and make any relevant changes (this is what I'm trying on my local repo). (EDIT: since we're refreshing the picker after most actions, this make_finder call needs the opts too)
The builtin buffer picker also has the default_selection_index
key which is needed for setting the row position correctly if sort_lastused
is true and ignore_current_buffer
is false, so we would need to access that after its value is updated.
Sorry for the oversight, I hope the indication to the code is useful.
Is it possible to persist the list of pinned buffers using a plugin like auto-session
?
This is probably a stretch, but I would love to be able to show when buffers are pinned when using Telescope buffers
.
I was looking at the source for it, but I think it'd basically involve re-implementing it: https://github.com/nvim-telescope/telescope.nvim/blob/40c31fdde93bcd85aeb3447bb3e2a3208395a868/lua/telescope/builtin/__internal.lua#L868-L938C1
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.