Closed marcelom97 closed 2 years ago
Feels out of scope for lualine. It's a statusline plugin not a buffer management plugin.
I agree that it's a statusline, but there is already a small functionality about buffers.
What about to add something more in order to be more complete?
I think that the buffer deletion functionality would fit perfectly.
I also want to work on implementing this, but first I want an approval about the feature!
Can you already do this by using bufpos2nr map ? It's exposed to the user.
Yes you can
Actually I have made the changes on a local branch.
Function
function M.buffer_delete(buf_pos, bang)
if buf_pos == '$' then
buf_pos = #M.bufpos2nr
else
buf_pos = tonumber(buf_pos)
end
if buf_pos < 1 or buf_pos > #M.bufpos2nr then
if bang ~= '!' then
error('Error: Unable to delete buffer position out of range')
else
return
end
end
vim.cmd(string.format('%s %d', "bd", M.bufpos2nr[buf_pos]))
end
Command
command! -nargs=1 -bang LualineBuffersDelete call v:lua.require'lualine.components.buffers'.buffer_delete(<f-args>, "<bang>")
If you know a better way of doing this, would be happy to hear that!
Actually I have made the changes on a local branch.
That's not what I meant this command can be created by user even if we don't provide it . Adding this to your config should work just fine
vim.api.nvim_create_user_command('LualineBuffersDelete', function (args)
local buffers = require'lualine.components.buffers'
local buf_pos = args.fargs[1] == '$' and #buffers.bufpos2nr or tonumber(args.fargs[1])
if buf_pos >= 1 and buf_pos <= #buffers.bufpos2nr then
vim.api.nvim_buf_delete(buffers.bufpos2nr[buf_pos], {force = true})
elseif not args.bang then
error('Error: Unable to delete buffer position out of range')
end
end, {desc='Delete buffer based on lualine-buffers index', force = true, nargs=1, bang=true})
Good to know that!!
Thanks!!
If you think that there is no need to add this to lualine, feel free to close this Issue.
Requested feature
As lualine has the
LualineBuffersJump
command, I find it very handy to also have aLualineBuffersDelete
command.This command will be very similar to
LualineBuffersJump
.bdelete
with the buffer numberMotivation
I think it will be very easy to map this command and delete buffers with the same easy way as jumping between them.