summaryrefslogtreecommitdiff
path: root/lua/blink/cmp/config/completion/keyword.lua
diff options
context:
space:
mode:
authorMike Vink <mike@pionative.com>2025-01-19 13:52:52 +0100
committerMike Vink <mike@pionative.com>2025-01-19 13:52:52 +0100
commitb77413ff8f59f380612074f0c9bd49093d8db695 (patch)
tree32c39a811ba96ed4ab0a1c81cce9f8d518ed7e31 /lua/blink/cmp/config/completion/keyword.lua
Squashed 'mut/neovim/pack/plugins/start/blink.cmp/' content from commit 1cc3b1a
git-subtree-dir: mut/neovim/pack/plugins/start/blink.cmp git-subtree-split: 1cc3b1a908fbcfd15451c4772759549724f38524
Diffstat (limited to 'lua/blink/cmp/config/completion/keyword.lua')
-rw-r--r--lua/blink/cmp/config/completion/keyword.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/lua/blink/cmp/config/completion/keyword.lua b/lua/blink/cmp/config/completion/keyword.lua
new file mode 100644
index 0000000..a922ac4
--- /dev/null
+++ b/lua/blink/cmp/config/completion/keyword.lua
@@ -0,0 +1,27 @@
+--- @class (exact) blink.cmp.CompletionKeywordConfig
+--- 'prefix' will fuzzy match on the text before the cursor
+--- 'full' will fuzzy match on the text before *and* after the cursor
+--- example: 'foo_|_bar' will match 'foo_' for 'prefix' and 'foo__bar' for 'full'
+--- @field range blink.cmp.CompletionKeywordRange
+---
+--- @alias blink.cmp.CompletionKeywordRange
+--- | 'prefix' Fuzzy match on the text before the cursor (example: 'foo_|bar' will match 'foo_')
+--- | 'full' Fuzzy match on the text before *and* after the cursor (example: 'foo_|_bar' will match 'foo__bar')
+
+local validate = require('blink.cmp.config.utils').validate
+local keyword = {
+ --- @type blink.cmp.CompletionKeywordConfig
+ default = { range = 'prefix' },
+}
+
+function keyword.validate(config)
+ validate('completion.keyword', {
+ range = {
+ config.range,
+ function(range) return vim.tbl_contains({ 'prefix', 'full' }, range) end,
+ 'one of: prefix, full',
+ },
+ }, config)
+end
+
+return keyword