Skip to content

Commit

Permalink
feat: add open_groups_by_key api function
Browse files Browse the repository at this point in the history
  • Loading branch information
lucobellic committed Sep 19, 2024
1 parent f0121ba commit 9bdecf7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ https://github.com/lucobellic/edgy-group.nvim/assets/6067072/6bee2762-9cc7-46d8-
- [Bufferline](#bufferline)
- [Lualine](#lualine)
- [Heirline](#heirline)
- [Tabby](#tabby)
- [Picking](#picking)
<!--toc:end-->

Expand Down Expand Up @@ -130,12 +131,15 @@ Groups without pick_key will be assigned to the first available key in alphabeti
- **EdgyGroupSelect** select group to open with **vim.ui.select**.
- **EdgyGroupNext position** open next group at given position.
- **EdgyGroupPrev position** open previous group at given position.
- **require('edgy-group').open_group_offset(position, offset)**
- **require('edgy-group').open_group_offset(position, offset)**
open group with offset relative to the current group.
- **require('edgy-group').open_group_index(position, index)**
- **require('edgy-group').open_group_index(position, index)**
open group with index relative to the current position.
- **require('edgy-group.stl').get_statusline(position)** get a list of string
in statusline format for each group icons with optional highlight and click support.
- **require('edgy-group').open_groups_by_key(key, toggle?)**
open one or multiple groups with this key, with an optional toggle option.
- **require('edgy-group.stl').get_statusline(position)**
get a list of string in statusline format for each group icons with optional
highlight and click support.
- **require('edgy-group.stl').pick(callback)**
enable picking mode to select group from statusline.

Expand Down
10 changes: 10 additions & 0 deletions lua/edgy-group/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,16 @@ function M.open_group_offset(pos, offset)
if g then M.open_group_index(pos, g:get_offset_index(offset)) end
end

-- Open groups by key, this might open on or multiple groups sharing the same key
---@param key string
---@param toggle? boolean whether to toggle an already opened group or not
function M.open_groups_by_key(key, toggle)
local toggle_group = toggle == nil and M.toggle or toggle
vim.iter(M.get_groups_by_key(key)):each(function(group)
pcall(M.open_group_index, group.position, group.index, toggle_group)
end)
end

-- Get the currently selected group for the given position
---@param pos Edgy.Pos
---@return EdgyGroup?
Expand Down

0 comments on commit 9bdecf7

Please sign in to comment.