Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tabout-nvim): make nvim-cmp optional and add support for vim.snippet #1220

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading