mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 17:03:39 +02:00
fix(luasnips): better defaults for <tab> behavior
This commit is contained in:
parent
3a52c149c4
commit
41645fdb2f
1 changed files with 13 additions and 21 deletions
|
@ -9,6 +9,19 @@ return {
|
||||||
require("luasnip.loaders.from_vscode").lazy_load()
|
require("luasnip.loaders.from_vscode").lazy_load()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
config = {
|
||||||
|
history = true,
|
||||||
|
delete_check_events = "TextChanged",
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
|
local function jump(key, dir)
|
||||||
|
vim.keymap.set({ "i", "s" }, key, function()
|
||||||
|
return require("luasnip").jump(dir) or key
|
||||||
|
end, { expr = true })
|
||||||
|
end
|
||||||
|
jump("<tab>", 1)
|
||||||
|
jump("<s-tab>", -1)
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
-- auto completion
|
-- auto completion
|
||||||
|
@ -22,7 +35,6 @@ return {
|
||||||
"hrsh7th/cmp-emoji",
|
"hrsh7th/cmp-emoji",
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
},
|
},
|
||||||
|
|
||||||
config = function()
|
config = function()
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
|
@ -37,26 +49,6 @@ return {
|
||||||
["<C-Space>"] = cmp.mapping.complete(),
|
["<C-Space>"] = cmp.mapping.complete(),
|
||||||
["<C-e>"] = cmp.mapping.abort(),
|
["<C-e>"] = cmp.mapping.abort(),
|
||||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_next_item()
|
|
||||||
elseif luasnip.expand_or_jumpable() then
|
|
||||||
luasnip.expand_or_jump()
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
||||||
local luasnip = require("luasnip")
|
|
||||||
if cmp.visible() then
|
|
||||||
cmp.select_prev_item()
|
|
||||||
elseif luasnip.jumpable(-1) then
|
|
||||||
luasnip.jump(-1)
|
|
||||||
else
|
|
||||||
fallback()
|
|
||||||
end
|
|
||||||
end, { "i", "s" }),
|
|
||||||
}),
|
}),
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = "nvim_lsp" },
|
{ name = "nvim_lsp" },
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue