Skip to content

Commit

Permalink
feat(functions): allow filtering by functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hinell committed Oct 19, 2023
1 parent 5d3a59f commit cf3a2a9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lua/legendary/filters.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ local M = {}
---@return LegendaryItemFilter
function M.mode(mode)
return function(item)
-- include everything that isn't a keymap since they aren't tied to a mode
if not Toolbox.is_keymap(item) then
-- allow only keymaps and functions
-- TODO: include commands
if not (Toolbox.is_keymap(item) or Toolbox.is_function(item)) then
return true
end

Expand All @@ -26,9 +27,9 @@ function M.mode(mode)
end

-- filter where any filter_modes match any item:modes()
return #vim.tbl_filter(function(keymap_mode)
return #vim.tbl_filter(function(item_mode)
return #vim.tbl_filter(function(filter_mode)
return filter_mode == keymap_mode
return filter_mode == item_mode
end, filter_modes) > 0
end, item:modes()) > 0
end
Expand Down

0 comments on commit cf3a2a9

Please sign in to comment.