|
1 |
| ---- @class blink.cmp.KeymapConfig |
2 |
| ---- @field show? string | string[] |
3 |
| ---- @field accept? string | string[] |
4 |
| ---- @field select_prev? string | string[] |
5 |
| ---- @field select_next? string | string[] |
6 |
| ---- @field show_documentation? string | string[] |
7 |
| ---- @field hide_documentation? string | string[] |
8 |
| ---- @field scroll_documentation_up? string | string[] |
9 |
| ---- @field scroll_documentation_down? string | string[] |
10 |
| ---- @field snippet_forward? string | string[] |
11 |
| ---- @field snippet_backward? string | string[] |
| 1 | +--- @alias blink.cmp.KeymapCommand |
| 2 | +--- | 'fallback' Fallback to the built-in behavior |
| 3 | +--- | 'show' Show the completion window |
| 4 | +--- | 'hide' Hide the completion window |
| 5 | +--- | 'accept' Accept the current completion item |
| 6 | +--- | 'select_and_accept' Select the current completion item and accept it |
| 7 | +--- | 'select_prev' Select the previous completion item |
| 8 | +--- | 'select_next' Select the next completion item |
| 9 | +--- | 'show_documentation' Show the documentation window |
| 10 | +--- | 'hide_documentation' Hide the documentation window |
| 11 | +--- | 'scroll_documentation_up' Scroll the documentation window up |
| 12 | +--- | 'scroll_documentation_down' Scroll the documentation window down |
| 13 | +--- | 'snippet_forward' Move the cursor forward to the next snippet placeholder |
| 14 | +--- | 'snippet_backward' Move the cursor backward to the previous snippet placeholder |
| 15 | +--- | (fun(cmp: table): boolean?) Custom function where returning true will prevent the next command from running |
| 16 | +--- |
| 17 | +--- @alias blink.cmp.KeymapConfig |
| 18 | +--- | table<string, blink.cmp.KeymapCommand[]> Table of keys => commands[] |
| 19 | +--- | 'default' mappings similar to built-in completion |
| 20 | +--- | 'super-tab' mappings similar to vscode (tab to accept, arrow keys to navigate) |
12 | 21 |
|
13 | 22 | --- @class blink.cmp.AcceptConfig
|
14 | 23 | --- @field create_undo_point? boolean Create an undo point when accepting a completion item
|
|
142 | 151 | --- @field enabled? boolean
|
143 | 152 |
|
144 | 153 | --- @class blink.cmp.Config
|
145 |
| ---- @field keymap? blink.cmp.KeymapConfig |
| 154 | +--- @field keymap? blink.cmp.KeymapConfig | 'default' | 'super-tab' |
146 | 155 | --- @field accept? blink.cmp.AcceptConfig
|
147 | 156 | --- @field trigger? blink.cmp.TriggerConfig
|
148 | 157 | --- @field fuzzy? blink.cmp.FuzzyConfig
|
|
155 | 164 |
|
156 | 165 | --- @type blink.cmp.Config
|
157 | 166 | local config = {
|
158 |
| - -- for keymap, all values may be string | string[] |
159 |
| - -- use an empty table to disable a keymap |
160 |
| - keymap = { |
161 |
| - show = '<C-space>', |
162 |
| - hide = '<C-e>', |
163 |
| - accept = '<Tab>', |
164 |
| - select_and_accept = {}, |
165 |
| - select_prev = { '<Up>', '<C-p>' }, |
166 |
| - select_next = { '<Down>', '<C-n>' }, |
167 |
| - |
168 |
| - show_documentation = '<C-space>', |
169 |
| - hide_documentation = '<C-space>', |
170 |
| - scroll_documentation_up = '<C-b>', |
171 |
| - scroll_documentation_down = '<C-f>', |
172 |
| - |
173 |
| - snippet_forward = '<Tab>', |
174 |
| - snippet_backward = '<S-Tab>', |
175 |
| - }, |
| 167 | + -- the keymap may be a preset ('default' | 'super-tab') or a table of keys => command[] |
| 168 | + -- additionally, you may pass a function in the command array where returning true |
| 169 | + -- will prevent the next command from running |
| 170 | + -- |
| 171 | + -- "default" keymap |
| 172 | + -- ['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' }, |
| 173 | + -- ['<C-e>'] = { 'hide' }, |
| 174 | + -- ['<C-y>'] = { 'accept' }, |
| 175 | + -- |
| 176 | + -- ['<C-p>'] = { 'select_prev', 'fallback' }, |
| 177 | + -- ['<C-n>'] = { 'select_next', 'fallback' }, |
| 178 | + -- |
| 179 | + -- ['<C-b>'] = { 'scroll_documentation_up', 'fallback' }, |
| 180 | + -- ['<C-f>'] = { 'scroll_documentation_down', 'fallback' }, |
| 181 | + -- |
| 182 | + -- ['<Tab>'] = { 'snippet_forward', 'fallback' }, |
| 183 | + -- ['<S-Tab>'] = { 'snippet_backward', 'fallback' }, |
| 184 | + -- |
| 185 | + -- "super-tab" keymap |
| 186 | + -- you may want to set `trigger.show_in_snippet = false` when using "super-tab" |
| 187 | + -- or use `window.autocomplete.selection = "manual" | "auto_insert"` |
| 188 | + -- |
| 189 | + -- ['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' }, |
| 190 | + -- ['<C-e>'] = { 'hide' }, |
| 191 | + -- |
| 192 | + -- ['<Tab>'] = { |
| 193 | + -- function(cmp) |
| 194 | + -- if cmp.is_in_snippet() then return cmp.accept() |
| 195 | + -- else return cmp.select_and_accept() end |
| 196 | + -- end, |
| 197 | + -- 'snippet_forward', |
| 198 | + -- 'fallback' |
| 199 | + -- }, |
| 200 | + -- ['<S-Tab>'] = { 'snippet_backward', 'fallback' }, |
| 201 | + -- |
| 202 | + -- ['<Up>'] = { 'select_prev', 'fallback' }, |
| 203 | + -- ['<Down>'] = { 'select_next', 'fallback' }, |
| 204 | + -- ['<C-p>'] = { 'select_prev', 'fallback' }, |
| 205 | + -- ['<C-n>'] = { 'select_next', 'fallback' }, |
| 206 | + -- |
| 207 | + -- ['<C-b>'] = { 'scroll_documentation_up', 'fallback' }, |
| 208 | + -- ['<C-f>'] = { 'scroll_documentation_down', 'fallback' }, |
| 209 | + -- |
| 210 | + -- available commands: |
| 211 | + -- show, hide, accept, select_and_accept, select_prev, select_next, show_documentation, hide_documentation, |
| 212 | + -- scroll_documentation_up, scroll_documentation_down, snippet_forward, snippet_backward, fallback |
| 213 | + keymap = 'default', |
176 | 214 |
|
177 | 215 | accept = {
|
178 | 216 | create_undo_point = true,
|
|
0 commit comments