Skip to content

Commit

Permalink
fix(tabout-nvim): make nvim-cmp optional and add support for `vim.s…
Browse files Browse the repository at this point in the history
…nippet`
  • Loading branch information
mehalter committed Sep 25, 2024
1 parent f4a19c4 commit 127ed67
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lua/astrocommunity/motion/tabout-nvim/init.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
return {
"abecodes/tabout.nvim",
event = "InsertEnter",
dependencies = {
"nvim-treesitter/nvim-treesitter",
dependencies = { "nvim-treesitter/nvim-treesitter" },
specs = {
{
"hrsh7th/nvim-cmp",
optional = true,
opts = function(_, opts)
local cmp = require "cmp"
local snippet_jumpable = function() return vim.snippet and vim.snippet.active { direction = 1 } end
local snippet_jump = vim.schedule_wrap(function() vim.snippet.jump(1) end)
local luasnip_avail, luasnip = pcall(require, "luasnip")
if luasnip_avail then
snippet_jumpable = luasnip.expand_or_jumpable
snippet_jump = luasnip.expand_or_jump
end
opts.mapping["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip_avail and luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif vim.api.nvim_get_mode() ~= "c" and snippet_jumpable() then
snippet_jump()
elseif not luasnip_avail and pcall(vim.snippet.active, { direction = 1 }) then
vim.snippet.jump(1)
else
Expand Down

0 comments on commit 127ed67

Please sign in to comment.