File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ override nvim-cmp and add cmp-emoji
25
25
26
26
Use ` <tab> ` for completion and snippets (supertab).
27
27
28
+ ### Without luasnip
29
+
28
30
``` lua
29
31
{
30
32
" hrsh7th/nvim-cmp" ,
@@ -69,6 +71,43 @@ Use `<tab>` for completion and snippets (supertab).
69
71
}
70
72
```
71
73
74
+ ### With luasnip
75
+
76
+ If the ` Luasnip ` extra is enabled you should use the following configuration instead:
77
+
78
+ ``` lua
79
+ {
80
+ " hrsh7th/nvim-cmp" ,
81
+ optional = true ,
82
+ -- See https://www.lazyvim.org/configuration/recipes#supertab
83
+ -- See https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
84
+ --- @param opts cmp.ConfigSchema
85
+ opts = function (_ , opts )
86
+ local cmp = require (" cmp" )
87
+ local luasnip = require (" luasnip" )
88
+ opts .mapping = vim .tbl_extend (" force" , opts .mapping , {
89
+ [" <Tab>" ] = cmp .mapping (function (fallback )
90
+ if cmp .visible () then
91
+ -- You could replace select_next_item() with confirm({ select = true }) to get VS Code autocompletion behavior
92
+ cmp .select_next_item ()
93
+ elseif luasnip .locally_jumpable (1 ) then
94
+ luasnip .jump (1 )
95
+ else
96
+ fallback ()
97
+ end
98
+ end , { " i" , " s" }),
99
+ [" <S-Tab>" ] = cmp .mapping (function (fallback )
100
+ if cmp .visible () then
101
+ cmp .select_prev_item ()
102
+ elseif luasnip .locally_jumpable (- 1 ) then
103
+ luasnip .jump (- 1 )
104
+ else
105
+ fallback ()
106
+ end
107
+ end , { " i" , " s" }),
108
+ })
109
+ end ,
110
+ }
72
111
## Change surround mappings
73
112
74
113
` ` ` lua
You can’t perform that action at this time.
0 commit comments