Skip to content

Commit

Permalink
docs(recipes): add tab completion instructions for luasnip users
Browse files Browse the repository at this point in the history
  • Loading branch information
murar8 authored Oct 24, 2024
1 parent f65087d commit ae36c8c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions docs/configuration/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ override nvim-cmp and add cmp-emoji

Use `<tab>` for completion and snippets (supertab).

### Without luasnip

```lua
{
"hrsh7th/nvim-cmp",
Expand Down Expand Up @@ -69,6 +71,45 @@ Use `<tab>` for completion and snippets (supertab).
}
```

### With luasnip enabled

If the `Luasnip` extra is enabled you should use the following configuration instead:


```lua
-- See https://www.lazyvim.org/configuration/recipes#supertab
-- See https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#luasnip
return {
"hrsh7th/nvim-cmp",
optional = true,
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local cmp = require("cmp")
local luasnip = require("luasnip")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.locally_jumpable(1) then
luasnip.jump(1)
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
})
end,
}
```

## Change surround mappings

```lua
Expand Down

0 comments on commit ae36c8c

Please sign in to comment.