Skip to content

Is there some manual way to add my own snippets to your plugin, or now I need to clone it and edit by hands? #3

Answered by iurimateus
daniilrozanov asked this question in Q&A
Discussion options

You must be logged in to vote

To remove a snippet, you can use the luasnip API. I think you might be able to mutate the tables that are required on init.lua, but it's a bit hacky.

You can override a snippet by adding another with the same trigger, but with a higher priority. Most have default prio of 0.

Example, overriding mk to $$

local ls = require("luasnip")
local conds = require("luasnip.extras.expand_conditions")
 
local utils = require("luasnip-latex-snippets.util.utils")

local not_math = utils.not_math() -- pass true if using Treesitter

local snip = ls.parser.parse_snippet({ trig = "mk", name = "Math" }, "$ ${1:${TM_SELECTED_TEXT}} $$0")

snip.condition = not_math
snip.priority = 10 -- anything greater than 0.

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@kiryph
Comment options

@kiryph
Comment options

@iurimateus
Comment options

@kiryph
Comment options

@iurimateus
Comment options

Answer selected by daniilrozanov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants