Skip to content

Commit 237c689

Browse files
authored
fix(tabout-nvim): make nvim-cmp optional and add support for vim.snippet (#1220)
1 parent 554bb1d commit 237c689

File tree

1 file changed

+11
-4
lines changed
  • lua/astrocommunity/motion/tabout-nvim

1 file changed

+11
-4
lines changed

lua/astrocommunity/motion/tabout-nvim/init.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
return {
22
"abecodes/tabout.nvim",
33
event = "InsertEnter",
4-
dependencies = {
5-
"nvim-treesitter/nvim-treesitter",
4+
dependencies = { "nvim-treesitter/nvim-treesitter" },
5+
specs = {
66
{
77
"hrsh7th/nvim-cmp",
8+
optional = true,
89
opts = function(_, opts)
910
local cmp = require "cmp"
11+
local snippet_jumpable = function() return vim.snippet and vim.snippet.active { direction = 1 } end
12+
local snippet_jump = vim.schedule_wrap(function() vim.snippet.jump(1) end)
1013
local luasnip_avail, luasnip = pcall(require, "luasnip")
14+
if luasnip_avail then
15+
snippet_jumpable = luasnip.expand_or_jumpable
16+
snippet_jump = luasnip.expand_or_jump
17+
end
1118
opts.mapping["<Tab>"] = cmp.mapping(function(fallback)
1219
if cmp.visible() then
1320
cmp.select_next_item()
14-
elseif luasnip_avail and luasnip.expand_or_jumpable() then
15-
luasnip.expand_or_jump()
21+
elseif vim.api.nvim_get_mode() ~= "c" and snippet_jumpable() then
22+
snippet_jump()
1623
elseif not luasnip_avail and pcall(vim.snippet.active, { direction = 1 }) then
1724
vim.snippet.jump(1)
1825
else

0 commit comments

Comments
 (0)