local line_begin = require("luasnip.extras.expand_conditions").line_begin local helpers = require("luasnip-helper-funcs") local get_visual = helpers.get_visual local mkscbs = helpers.make_single_curly_bracket_snippets local mkss = helpers.make_scope_snippets -- mkscbs ("snippetType", "trig", "command", "desc") return -- https://github.com/L3MON4D3/LuaSnip/blob/master/DOC.md#lua -- First list of snippets (snippetType = "snippet") start { mkscbs("snippet", ";tt", "texttt", "teletypefont"), mkscbs("snippet", ";ti", "textit", "italic shape"), mkscbs("snippet", ";bf", "textbf", "bold"), mkscbs("snippet", ";em", "emph", "emphasis"), mkscbs("snippet", ";em", "emph", "emphasis"), mkscbs("snippet", ";sf", "sfont", "secondary font"), s( { trig = ";url", dscr = "The hyperref package's href{}{} command (for url links)" }, fmta("\\href{<>}{<>}", { d(1, get_visual, { 1 }, { user_args = { "url" } }), i(2, "display name"), }) ), s( -- https://en.wikibooks.org/wiki/LaTeX/Paragraph_Formatting#Verbatim_text { trig = ";vb", dscr = "Expands 'vb' into '\\verb++' (verbatim phrase, + as delimiters (can be changed))" }, fmta("\\verb<><><>", { i(1, "+"), d(2, get_visual, {}, { user_args = { "verbatim phrase" } }), rep(1) }) ), s( { trig = ";begin", dscr = "A LaTeX equation environment" }, fmta( [[ \begin{<>} <><> \end{<>} ]], -- The insert node is placed in the <> angle brackets { i(1), d(2, get_visual, {}, { user_args = { "Content here" } }), i(0), rep(1) } ), { condition = line_begin } -- set condition in the `opts` table ), s( { trig = ";ff", dscr = "Expands 'ff' into '\\frac{}{}'" }, fmt("\\fanc{<>}{<>}", { i(1), i(2) }, { delimiters = "<>" }) ), -- Example use of insert node placeholder text s({ trig = ";s", desc = "square bracket" }, fmta("\\<>[<>]", { i(1, "command"), d(2, get_visual) })), s({ trig = ";c", desc = "curly bracket" }, fmta("\\<>{<>}", { i(1, "command"), d(2, get_visual) })), s({ trig = ";cc", desc = "curly bracket + curly bracket" }, fmta("\\<>{<>}{<>}", { i(1, "command"), i(3), i(2) })), s({ trig = ";sc", desc = "square bracket + curly bracket" }, fmta("\\<>[<>]{<>}", { i(1, "command"), i(3), i(2) })), -- s( -- { trig = ";tt", dscr = "Expands 'tt' into '\\texttt{}' (teletypefont family)" }, -- fmta("\\texttt{<>}", { d(1, get_visual, {}, { user_args = { "teletypefont" } }) }) -- ), -- s( -- { trig = ";ti", dscr = "Expands 'ti' into '\\textit{}' (italic shape)" }, -- fmta("\\textit{<>}", { d(1, get_visual, {}, { user_args = { "italic shape" } }) }) -- ), -- s( -- { trig = ";bf", dscr = "Expands 'bf' into '\\textbf{}' (bold)" }, -- fmta("\\textbf{<>}", { d(1, get_visual, {}, { user_args = { "bold" } }) }) -- ), -- s( -- { trig = ";em", dscr = "Expands 'em' into '\\emph{}' (emphasis)" }, -- fmta("\\emph{<>}", { d(1, get_visual, {}, { user_args = { "emphasis" } }) }) -- ), }, -- First list of snippets (snippetType = "snippet") end -- Second list of snippets (snippetType = "autosnippet") start {} -- Second list of snippets (snippetType = "autosnippet") end