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
-
I think this plugin gives pretty good capabilities to add custom snippets |
Beta Was this translation helpful? Give feedback.
Answered by
iurimateus
Nov 21, 2022
Replies: 1 comment 6 replies
-
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 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.
ls.add_snippets("tex", { snip }, {
type = "autosnippets",
}) Do you have an interface in mind? |
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
daniilrozanov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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$$