about summary refs log tree commit diff stats
path: root/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua
blob: ef4539733001a51dbb283afd23c65a64cb7d0836 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local get_visual = function(args, parent)
  if #parent.snippet.env.SELECT_RAW > 0 then
    return sn(nil, i(1, parent.snippet.env.SELECT_RAW))
  else
    return sn(nil, i(1, ""))
  end
end

local translation_table = { ["("] = ")", ["{"] = "}", ["["] = "]" }

-- Return snippet tables
return {
  -- LEFT/RIGHT ALL BRACES
  s(
    {
      trig = "([^%a])l([%(%[%{])",
      regTrig = true,
      wordTrig = false,
      snippetType = "autosnippet",
    },
    fmta("<>\\left<><>\\right<>", {
      f(function(_, snip) return snip.captures[1] end),
      f(function(_, snip) return snip.captures[2] end),
      d(1, get_visual),
      f(function(_, snip) return translation_table[snip.captures[2]] end),
    })
  ),
}