Skip to content

Commit

Permalink
feat(groups): close and unpin (#698)
Browse files Browse the repository at this point in the history
add a command to allow a buffer to be both closed and unpinned so that it isn't autopinned on next re-opening it
  • Loading branch information
otavioschwanck committed Mar 30, 2023
1 parent 1fab34c commit d129e86
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions lua/bufferline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ local M = {
go_to_buffer = commands.go_to,
sort_buffers_by = commands.sort_by,
close_buffer_with_pick = commands.close_with_pick,
unpin_and_close = commands.unpin_and_close,
}
-----------------------------------------------------------------------------//
-- Helpers
Expand Down
8 changes: 8 additions & 0 deletions lua/bufferline/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@ function M.close_with_pick()
pick.choose_then(function(id) handle_close(id) end)
end

function M.unpin_and_close(id)
local win_id = id or vim.api.nvim_get_current_buf()

handle_close(win_id)

groups.remove_id_from_manual_groupings(win_id)
end

--- Open a element based on it's visible position in the list
--- unless absolute is specified in which case this will open it based on it place in the full list
--- this is significantly less helpful if you have a lot of elements open
Expand Down
5 changes: 5 additions & 0 deletions lua/bufferline/groups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ function M.remove_from_group(group_name, element)
end
end

---@param id number
function M.remove_id_from_manual_groupings(id)
state.manual_groupings[id] = nil
end

---@param id string
---@param value boolean
function M.set_hidden(id, value)
Expand Down

0 comments on commit d129e86

Please sign in to comment.