fixed supertab example (#117)
This commit is contained in:
14
README.md
14
README.md
@@ -459,15 +459,19 @@ local check_back_space = function()
|
|||||||
end
|
end
|
||||||
local luasnip = require("luasnip")
|
local luasnip = require("luasnip")
|
||||||
|
|
||||||
|
local t = function(str)
|
||||||
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||||
|
end
|
||||||
|
|
||||||
-- supertab-like mapping
|
-- supertab-like mapping
|
||||||
mapping = {
|
mapping = {
|
||||||
["<Tab>"] = cmp.mapping(function(fallback)
|
["<Tab>"] = cmp.mapping(function(fallback)
|
||||||
if vim.fn.pumvisible() == 1 then
|
if vim.fn.pumvisible() == 1 then
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-n>"), "n")
|
vim.fn.feedkeys(t("<C-n>"), "n")
|
||||||
elseif luasnip.expand_or_jumpable() then
|
elseif luasnip.expand_or_jumpable() then
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump"), "")
|
vim.fn.feedkeys(t("<Plug>luasnip-expand-or-jump"), "")
|
||||||
elseif check_back_space() then
|
elseif check_back_space() then
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Tab>"), "n")
|
vim.fn.feedkeys(t("<Tab>"), "n")
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
@@ -477,9 +481,9 @@ mapping = {
|
|||||||
}),
|
}),
|
||||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||||
if vim.fn.pumvisible() == 1 then
|
if vim.fn.pumvisible() == 1 then
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-p>"), "n")
|
vim.fn.feedkeys(t("<C-p>"), "n")
|
||||||
elseif luasnip.jumpable(-1) then
|
elseif luasnip.jumpable(-1) then
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev"), "")
|
vim.fn.feedkeys(t("<Plug>luasnip-jump-prev"), "")
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user