Get snippets running
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
local cmp = require('cmp')
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
@@ -45,26 +46,28 @@ cmp.setup {
|
||||
}),
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
if vim.fn["UltiSnips#CanExpandSnippet"]() == 1 or
|
||||
vim.fn["UltiSnips#CanJumpForwards"]() == 1 then
|
||||
return vim.fn.feedkeys(t(
|
||||
"<C-R>=UltiSnips#ExpandSnippetOrJump()<CR>"))
|
||||
end
|
||||
|
||||
vim.fn.feedkeys(t("<C-n>"), "n")
|
||||
elseif check_back_space() then
|
||||
vim.fn.feedkeys(t("<tab>"), "n")
|
||||
vim.api.nvim_feedkeys(t("<C-n>"), "n", true)
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
vim.api.nvim_feedkeys(t("<Plug>luasnip-expand-or-jump"), "", true)
|
||||
else
|
||||
fallback()
|
||||
fallback()
|
||||
end
|
||||
end, {"i", "s"}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if vim.fn.pumvisible() == 1 then
|
||||
vim.fn.feedkeys(t("<C-p>"), "n")
|
||||
vim.api.nvim_feedkeys(t("<C-p>"), "n", true)
|
||||
elseif luasnip.jumpable(-1) then
|
||||
vim.api.nvim_feedkeys(t("<Plug>luasnip-jump-prev"), "", true)
|
||||
else
|
||||
fallback()
|
||||
fallback()
|
||||
end
|
||||
end, {"i", "s"})
|
||||
end, {
|
||||
"i",
|
||||
"s",
|
||||
}),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
|
||||
Reference in New Issue
Block a user