feat: add filter option to sources (#1067)

* feat: add `source.filter` config

This allows the user to specify a `filter` function for each source,
like this:

```lua
-- don't show entries with kind "Text" from the "nvim_lsp" source

sources = {
{
  name = "nvim_lsp",
  filter = function(entry, ctx)
    local kind = types.lsp.CompletionItemKind[entry:get_kind()]

    if kind == "Text" then
      return true
    end
  },
}
```

By utilizing the `ctx` parameter, the user can also ignore certain
entries in certain contexts.

* fixup! feat: add `source.filter` config

* fixup! feat: add `source.filter` config
This commit is contained in:
Jonatan Branting
2022-09-08 05:48:27 +02:00
committed by GitHub
parent b16e5bcf1d
commit 913eb85998
3 changed files with 42 additions and 1 deletions

View File

@@ -152,6 +152,7 @@ cmp.ItemField = {
---@field public keyword_length integer|nil
---@field public max_item_count integer|nil
---@field public group_index integer|nil
---@field public entry_filter nil|function(entry: cmp.Entry, ctx: cmp.Context): boolean
---@class cmp.ViewConfig
---@field public entries cmp.EntriesConfig