summaryrefslogtreecommitdiff
path: root/lua/blink/cmp/keymap/presets.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/keymap/presets.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/keymap/presets.lua')
-rw-r--r--lua/blink/cmp/keymap/presets.lua72
1 files changed, 72 insertions, 0 deletions
diff --git a/lua/blink/cmp/keymap/presets.lua b/lua/blink/cmp/keymap/presets.lua
new file mode 100644
index 0000000..1e7de16
--- /dev/null
+++ b/lua/blink/cmp/keymap/presets.lua
@@ -0,0 +1,72 @@
+local presets = {
+ none = {},
+
+ default = {
+ ['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
+ ['<C-e>'] = { 'cancel', 'fallback' },
+ ['<C-y>'] = { 'select_and_accept' },
+
+ ['<C-p>'] = { 'select_prev', 'fallback' },
+ ['<C-n>'] = { 'select_next', 'fallback' },
+
+ ['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
+ ['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
+
+ ['<Tab>'] = { 'snippet_forward', 'fallback' },
+ ['<S-Tab>'] = { 'snippet_backward', 'fallback' },
+ },
+
+ ['super-tab'] = {
+ ['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
+ ['<C-e>'] = { 'cancel', 'fallback' },
+
+ ['<Tab>'] = {
+ function(cmp)
+ if cmp.snippet_active() then
+ return cmp.accept()
+ else
+ return cmp.select_and_accept()
+ end
+ end,
+ 'snippet_forward',
+ 'fallback',
+ },
+ ['<S-Tab>'] = { 'snippet_backward', 'fallback' },
+
+ ['<Up>'] = { 'select_prev', 'fallback' },
+ ['<Down>'] = { 'select_next', 'fallback' },
+ ['<C-p>'] = { 'select_prev', 'fallback' },
+ ['<C-n>'] = { 'select_next', 'fallback' },
+
+ ['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
+ ['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
+ },
+
+ enter = {
+ ['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
+ ['<C-e>'] = { 'cancel', 'fallback' },
+ ['<CR>'] = { 'accept', 'fallback' },
+
+ ['<Tab>'] = { 'snippet_forward', 'fallback' },
+ ['<S-Tab>'] = { 'snippet_backward', 'fallback' },
+
+ ['<Up>'] = { 'select_prev', 'fallback' },
+ ['<Down>'] = { 'select_next', 'fallback' },
+ ['<C-p>'] = { 'select_prev', 'fallback' },
+ ['<C-n>'] = { 'select_next', 'fallback' },
+
+ ['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
+ ['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
+ },
+}
+
+--- Gets the preset keymap for the given preset name
+--- @param name string
+--- @return table<string, blink.cmp.KeymapCommand[]>
+function presets.get(name)
+ local preset = presets[name]
+ if preset == nil then error('Invalid blink.cmp keymap preset: ' .. name) end
+ return preset
+end
+
+return presets