Skip to content

Commit

Permalink
Merge pull request #165 from savq/query
Browse files Browse the repository at this point in the history
  • Loading branch information
saccarosium committed Feb 12, 2024
2 parents b2643f7 + 7b20e59 commit 8aded97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
9 changes: 9 additions & 0 deletions doc/paq-nvim.txt
Expand Up @@ -213,6 +213,15 @@ imported as `paq`, the functions are:
}


|paq.query| *paq-query*

Queries paq's packages storage with predefined
filters by passing one of the following strings:
- "installed"
- "to_install"
- "to_update"


==============================================================================
PACKAGE OPTIONS *paq-options*

Expand Down
14 changes: 14 additions & 0 deletions lua/paq.lua
Expand Up @@ -537,6 +537,20 @@ function paq:setup(opts)
return self
end

---Queries paq's packages storage with predefined
---filters by passing one of the following strings:
--- - "installed"
--- - "to_install"
--- - "to_update"
---@param filter string
function paq.query(filter)
vim.validate({ filter = { filter, { 'string' } } })
if not Filter[filter] then
error(string.format("No filter with name: %q", filter))
end
return vim.deepcopy(vim.tbl_filter(Filter[filter], Packages))
end

function paq.list()
local installed = vim.tbl_filter(Filter.installed, Lock)
local removed = vim.tbl_filter(Filter.removed, Lock)
Expand Down

0 comments on commit 8aded97

Please sign in to comment.