Skip to content

Instantly share code, notes, and snippets.

@tjdevries
Created May 20, 2024 20:10
Show Gist options
  • Save tjdevries/cd030fa1f9ee8a8d8885e74dfa2324eb to your computer and use it in GitHub Desktop.
Save tjdevries/cd030fa1f9ee8a8d8885e74dfa2324eb to your computer and use it in GitHub Desktop.
local ls = require "luasnip"
vim.snippet.expand = ls.lsp_expand
---@diagnostic disable-next-line: duplicate-set-field
vim.snippet.active = function(filter)
filter = filter or {}
filter.direction = filter.direction or 1
if filter.direction == 1 then
return ls.expand_or_jumpable()
else
return ls.jumpable(filter.direction)
end
end
---@diagnostic disable-next-line: duplicate-set-field
vim.snippet.jump = function(direction)
if direction == 1 then
if ls.expandable() then
return ls.expand_or_jump()
else
return ls.jumpable(1) and ls.jump(1)
end
else
return ls.jumpable(-1) and ls.jump(-1)
end
end
vim.snippet.stop = ls.unlink_current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment