mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
feat(dashboard): allow items to be hidden, but still create the keymaps etc
This commit is contained in:
parent
0043fa9ee1
commit
7a47eb76df
1 changed files with 8 additions and 5 deletions
|
@ -23,6 +23,7 @@ math.randomseed(os.time())
|
|||
---@field section? string the name of a section to include. See `Snacks.dashboard.sections`
|
||||
---@field [string] any section options
|
||||
---@field key? string shortcut key
|
||||
---@field hidden? boolean when `true`, the item will not be shown, but the key will still be assigned
|
||||
---@field autokey? boolean automatically assign a numerical key
|
||||
---@field label? string
|
||||
---@field desc? string
|
||||
|
@ -526,7 +527,7 @@ function D:find(pos, from)
|
|||
|
||||
local ret ---@type snacks.dashboard.Item?
|
||||
for _, item in ipairs(self.items) do
|
||||
if item._.pane == pane and item.action then
|
||||
if item._ and item._.pane == pane and item.action then
|
||||
if ret and pos[1] < from[1] and item._.row > pos[1] then
|
||||
break
|
||||
end
|
||||
|
@ -545,10 +546,12 @@ function D:layout()
|
|||
math.max(1, math.floor((self._size.width + self.opts.pane_gap) / (self.opts.width + self.opts.pane_gap)))
|
||||
self.panes = {} ---@type snacks.dashboard.Item[][]
|
||||
for _, item in ipairs(self.items) do
|
||||
local pane = item.pane or 1
|
||||
pane = math.fmod(pane - 1, max_panes) + 1 -- distribute panes evenly
|
||||
self.panes[pane] = self.panes[pane] or {}
|
||||
table.insert(self.panes[pane], item)
|
||||
if not item.hidden then
|
||||
local pane = item.pane or 1
|
||||
pane = math.fmod(pane - 1, max_panes) + 1 -- distribute panes evenly
|
||||
self.panes[pane] = self.panes[pane] or {}
|
||||
table.insert(self.panes[pane], item)
|
||||
end
|
||||
end
|
||||
for p = 1, math.max(unpack(vim.tbl_keys(self.panes))) or 1 do
|
||||
self.panes[p] = self.panes[p] or {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue