Fix jump behaviour
This commit is contained in:
parent
0186df077c
commit
90087512e4
@ -20,6 +20,10 @@ return {
|
||||
-- loads vscode style snippets from installed plugins (e.g. friendly-snippets)
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_vscode").load({paths = { "~/.config/nvim/my_snippets" }})
|
||||
luasnip.setup({
|
||||
region_check_events = { "CursorMoved" },
|
||||
delete_check_events = { "TextChanged" },
|
||||
})
|
||||
|
||||
-- luasnip.filetype_extend("htmldjango", { "html" })
|
||||
|
||||
@ -49,22 +53,29 @@ return {
|
||||
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
|
||||
["<C-q>"] = cmp.mapping.abort(), -- close completion window
|
||||
["<CR>"] = cmp.mapping.confirm({ select = false }), -- autocomplete if selected
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })
|
||||
elseif require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
-- Mapping for Tab key
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })
|
||||
elseif require("luasnip").expandable() then
|
||||
-- Expands snippet if possible
|
||||
require("luasnip").expand()
|
||||
else
|
||||
-- Otherwise, fallback (insert a tab character)
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
|
||||
-- Mapping for jumping in snippets)
|
||||
["<C-p>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").jumpable() then
|
||||
-- Jump backwards if inside a snippet
|
||||
require("luasnip").jump()
|
||||
else
|
||||
-- Otherwise, fallback (insert a tab character)
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" })
|
||||
}),
|
||||
|
||||
-- sources for autocompletion
|
||||
|
@ -1,8 +1,12 @@
|
||||
return {
|
||||
'L3MON4D3/LuaSnip',
|
||||
config = function()
|
||||
local luasnip = require('luasnip')
|
||||
|
||||
require("luasnip.loaders.from_vscode").load({paths = "~/.config/nvim/my_snippets"})
|
||||
end
|
||||
-- config = function()
|
||||
-- local luasnip = require('luasnip')
|
||||
-- -- luasnip.setup({
|
||||
-- -- region_check_events = "CursorMoved",
|
||||
-- -- delete_check_events = "TextChanged",
|
||||
-- -- })
|
||||
--
|
||||
-- require("luasnip.loaders.from_vscode").load({paths = "~/.config/nvim/my_snippets"})
|
||||
-- end
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user