diff --git a/lua/care/core.lua b/lua/care/core.lua index b912992..f61a5c6 100644 --- a/lua/care/core.lua +++ b/lua/care/core.lua @@ -15,6 +15,7 @@ end function core:complete(reason) reason = reason or 2 local sources = require("care.sources").get_sources() + ---@type care.entry[] local entries = {} local remaining = #sources self.context.reason = reason @@ -35,6 +36,9 @@ function core:complete(reason) local filtered_items = vim.iter(items):filter(function(entry) return not entry.score or entry.score > 0 end) + if source.config.filter then + filtered_items:filter(source.config.filter) + end if source.config.max_entries then filtered_items:take(source.config.max_entries) end diff --git a/lua/care/types/config.lua b/lua/care/types/config.lua index d3a95bb..52563b0 100644 --- a/lua/care/types/config.lua +++ b/lua/care/types/config.lua @@ -51,6 +51,8 @@ ---@field max_entries integer? --- The priority of this source. Is more important than matching score ---@field priority integer? +--- Filter function for entries by the source +---@field filter fun(entry: care.entry): boolean --- Configuration of the completion menu of care.nvim ---@class care.config.ui.docs