File tree 1 file changed +38
-0
lines changed
1 file changed +38
-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,42 @@ 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
+ -- See https://www.lazyvim.org/configuration/recipes#supertab
80
+ -- See https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
81
+ return {
82
+ " hrsh7th/nvim-cmp" ,
83
+ optional = true ,
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
+ cmp .select_next_item ()
92
+ elseif luasnip .locally_jumpable (1 ) then
93
+ luasnip .jump (1 )
94
+ else
95
+ fallback ()
96
+ end
97
+ end , { " i" , " s" }),
98
+ [" <S-Tab>" ] = cmp .mapping (function (fallback )
99
+ if cmp .visible () then
100
+ cmp .select_prev_item ()
101
+ elseif luasnip .locally_jumpable (- 1 ) then
102
+ luasnip .jump (- 1 )
103
+ else
104
+ fallback ()
105
+ end
106
+ end , { " i" , " s" }),
107
+ })
108
+ end ,
109
+ }
72
110
## Change surround mappings
73
111
74
112
` ` ` lua
You can’t perform that action at this time.
0 commit comments