[
  {
    "path": ".luacheckrc",
    "content": "-- vim: ft=lua tw=80\n\nstds.nvim = {\n  globals = {\n    vim = { fields = { \"g\" } },\n  },\n  read_globals = {\n    \"vim\",\n  },\n}\nstd = \"lua51+nvim\"\n\n-- Don't report unused self arguments of methods.\nself = false\n\nignore = {\n  \"631\", -- max_line_length\n  \"212/_.*\", -- unused argument, for vars with \"_\" prefix\n}\n"
  },
  {
    "path": ".stylua.toml",
    "content": "column_width = 100\nindent_type = \"Spaces\"\nindent_width = 2\nquote_style = \"AutoPreferDouble\"\nno_call_parentheses = false\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "README.md",
    "content": "# luasnip-latex-snippets\n\nA port of [Gilles Castel's](https://github.com/gillescastel/latex-snippets)\nsnippets for the [LuaSnip Engine](https://github.com/L3MON4D3/LuaSnip).\n\n## Why?\n\nUltiSnips felt unbearably slow. See\n<https://github.com/neovim/neovim/issues/7063> and\n<https://github.com/SirVer/ultisnips/issues?q=label%3A%22neovim+only%22+is%3Aclosed>.\n\n## Installation\n\nDepends on [vimtex](https://github.com/lervag/vimtex) to determine if the\ncursor is within math mode. Alternatively, you can use\n[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) (experimental) by passing `{ use_treesitter = true }` to the setup call.\n\nIt's necessary to enable `autosnippets` in luasnip: `require(\"luasnip\").config.setup { enable_autosnippets = true }`.\n\nCan be installed like any neovim plugin. If using\n[wbthomason/packer.nvim](https://github.com/wbthomason/packer.nvim):\n\n```lua\nuse {\n  \"iurimateus/luasnip-latex-snippets.nvim\",\n  -- vimtex isn't required if using treesitter\n  requires = { \"L3MON4D3/LuaSnip\", \"lervag/vimtex\" },\n  config = function()\n    require'luasnip-latex-snippets'.setup()\n    -- or setup({ use_treesitter = true })\n    require(\"luasnip\").config.setup { enable_autosnippets = true }\n  end,\n}\n```\n\n## Configuration\n\n```\n{\n  use_treesitter = false, -- whether to use treesitter to determine if cursor is in math mode; if false, vimtex is used\n  allow_on_markdown = true, -- whether to add snippets to markdown filetype\n}\n```\n\n## Misc\n\nThe following convention, from\n[SirVer/ultisnips](https://github.com/SirVer/ultisnips), is used for naming lua\ntables and respective files:\n\n```\nA: Automatic snippet expansion - snippets will activate as soon as their trigger\nmatches.\n\nw: Word boundary - With this option the snippet trigger will match when the\ntrigger is a word boundary character. This is the default behavior.\n\nb: Beginning of line expansion - A snippet with this option is expanded only if\nthe trigger is the first word on the line (i.e., only whitespace precedes the\ntrigger).\n```\n\nNote that the _regex_ term used in LuaSnip is misleading: it is not a POSIX\nregexp. What's actually being used is Lua pattern matching, which has some\nlimitations. In particular, it lacks positive lookbehind and alternation `|`.\nThe first which is used in postfix completions (e.g. match `delta`, but not\n`\\delta`) and can be handled with simple functions. The second was solved by\nsplitting and/or partially rewriting the expressions.\n\n### Adding your own snippets / overrides\n\nSee discussion https://github.com/iurimateus/luasnip-latex-snippets.nvim/discussions/3#discussioncomment-11348745\n\n```lua\nlocal ls = require(\"luasnip\")\nlocal utils = require(\"luasnip-latex-snippets.util.utils\")\nlocal not_math = utils.not_math() -- pass true if using Treesitter\n\n-- set a higher priority (defaults to 0 for most snippets)\nlocal snip = ls.parser.parse_snippet(\n  { trig = \"mk\", name = \"Math\", condition = not_math, priority = 10 },\n  \"$ ${1:${TM_SELECTED_TEXT}} $$0\"\n)\n\nls.add_snippets(\"tex\", { snip }, {\n  type = \"autosnippets\",\n})\n```\n\n## Roadmap\n\n- [ ] Tests\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/bwA.lua",
    "content": "local ls = require(\"luasnip\")\nlocal t = ls.text_node\nlocal i = ls.insert_node\n\nlocal M = {}\n\nfunction M.retrieve(not_math)\n  local utils = require(\"luasnip-latex-snippets.util.utils\")\n  local pipe = utils.pipe\n\n  local conds = require(\"luasnip.extras.expand_conditions\")\n  local condition = pipe({ conds.line_begin, not_math })\n\n  local parse_snippet = ls.extend_decorator.apply(ls.parser.parse_snippet, {\n    condition = condition,\n  }) --[[@as function]]\n\n  local s = ls.extend_decorator.apply(ls.snippet, {\n    condition = condition,\n  }) --[[@as function]]\n\n  return {\n    s(\n      { trig = \"ali\", name = \"Align\" },\n      { t({ \"\\\\begin{align*}\", \"\\t\" }), i(1), t({ \"\", \"\\\\end{align*}\" }) }\n    ),\n\n    parse_snippet({ trig = \"beg\", name = \"begin{} / end{}\" }, \"\\\\begin{$1}\\n\\t$0\\n\\\\end{$1}\"),\n\n    s({ trig = \"bigfun\", name = \"Big function\" }, {\n      t({ \"\\\\begin{align*}\", \"\\t\" }),\n      i(1),\n      t(\":\"),\n      t(\" \"),\n      i(2),\n      t(\"&\\\\longrightarrow \"),\n      i(3),\n      t({ \" \\\\\", \"\\t\" }),\n      i(4),\n      t(\"&\\\\longmapsto \"),\n      i(1),\n      t(\"(\"),\n      i(4),\n      t(\")\"),\n      t(\" = \"),\n      i(0),\n      t({ \"\", \"\\\\end{align*}\" }),\n    }),\n  }\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/init.lua",
    "content": "local M = {}\n\nlocal default_opts = {\n  use_treesitter = false,\n  allow_on_markdown = true,\n}\n\nM.setup = function(opts)\n  opts = vim.tbl_deep_extend(\"force\", default_opts, opts or {})\n\n  local augroup = vim.api.nvim_create_augroup(\"luasnip-latex-snippets\", {})\n  vim.api.nvim_create_autocmd(\"FileType\", {\n    pattern = \"tex\",\n    group = augroup,\n    once = true,\n    callback = function()\n      local utils = require(\"luasnip-latex-snippets.util.utils\")\n      local is_math = utils.with_opts(utils.is_math, opts.use_treesitter)\n      local not_math = utils.with_opts(utils.not_math, opts.use_treesitter)\n      M.setup_tex(is_math, not_math)\n    end,\n  })\n\n  if opts.allow_on_markdown then\n    vim.api.nvim_create_autocmd(\"FileType\", {\n      pattern = { \"markdown\", \"quarto\" },\n      group = augroup,\n      once = true,\n      callback = function()\n        M.setup_markdown()\n      end,\n    })\n  end\nend\n\nlocal _autosnippets = function(is_math, not_math)\n  local autosnippets = {}\n\n  for _, s in ipairs({\n    \"math_wRA_no_backslash\",\n    \"math_rA_no_backslash\",\n    \"math_wA_no_backslash\",\n    \"math_iA_no_backslash\",\n    \"math_iA\",\n    \"math_wrA\",\n  }) do\n    vim.list_extend(\n      autosnippets,\n      require((\"luasnip-latex-snippets.%s\"):format(s)).retrieve(is_math)\n    )\n  end\n\n  for _, s in ipairs({\n    \"wA\",\n    \"bwA\",\n  }) do\n    vim.list_extend(\n      autosnippets,\n      require((\"luasnip-latex-snippets.%s\"):format(s)).retrieve(not_math)\n    )\n  end\n\n  return autosnippets\nend\n\nM.setup_tex = function(is_math, not_math)\n  local ls = require(\"luasnip\")\n  ls.add_snippets(\"tex\", {\n    ls.parser.parse_snippet(\n      { trig = \"pac\", name = \"Package\" },\n      \"\\\\usepackage[${1:options}]{${2:package}}$0\"\n    ),\n\n    -- ls.parser.parse_snippet({ trig = \"nn\", name = \"Tikz node\" }, {\n    --   \"$0\",\n    --   -- \"\\\\node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$};\",\n    --   \"\\\\node[$5] (${1}${2}) ${3:at (${4:0,0}) }{$${1}$};\",\n    -- }),\n  })\n\n  local math_i = require(\"luasnip-latex-snippets/math_i\").retrieve(is_math)\n\n  ls.add_snippets(\"tex\", math_i, { default_priority = 0 })\n\n  ls.add_snippets(\"tex\", _autosnippets(is_math, not_math), {\n    type = \"autosnippets\",\n    default_priority = 0,\n  })\nend\n\nM.setup_markdown = function()\n  local ls = require(\"luasnip\")\n  local utils = require(\"luasnip-latex-snippets.util.utils\")\n  local pipe = utils.pipe\n\n  local is_math = utils.with_opts(utils.is_math, true)\n  local not_math = utils.with_opts(utils.not_math, true)\n\n  local math_i = require(\"luasnip-latex-snippets/math_i\").retrieve(is_math)\n  ls.add_snippets(\"markdown\", math_i, { default_priority = 0 })\n\n  local autosnippets = _autosnippets(is_math, not_math)\n  local trigger_of_snip = function(s)\n    return s.trigger\n  end\n\n  local to_filter = {}\n  for _, str in ipairs({\n    \"wA\",\n    \"bwA\",\n  }) do\n    local t = require((\"luasnip-latex-snippets.%s\"):format(str)).retrieve(not_math)\n    vim.list_extend(to_filter, vim.tbl_map(trigger_of_snip, t))\n  end\n\n  local filtered = vim.tbl_filter(function(s)\n    return not vim.tbl_contains(to_filter, s.trigger)\n  end, autosnippets)\n\n  local parse_snippet = ls.extend_decorator.apply(ls.parser.parse_snippet, {\n    condition = pipe({ not_math }),\n  }) --[[@as function]]\n\n  -- tex delimiters\n  local normal_wA_tex = {\n    parse_snippet({ trig = \"mk\", name = \"Math\" }, \"$${1:${TM_SELECTED_TEXT}}$\"),\n    parse_snippet({ trig = \"dm\", name = \"Block Math\" }, \"$$\\n\\t${1:${TM_SELECTED_TEXT}}\\n$$\"),\n  }\n  vim.list_extend(filtered, normal_wA_tex)\n\n  ls.add_snippets(\"markdown\", filtered, {\n    type = \"autosnippets\",\n    default_priority = 0,\n  })\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/math_i.lua",
    "content": "local M = {}\n\nlocal ls = require(\"luasnip\")\nlocal utils = require(\"luasnip-latex-snippets.util.utils\")\nlocal pipe = utils.pipe\n\nfunction M.retrieve(is_math)\n  local parse_snippet = ls.extend_decorator.apply(ls.parser.parse_snippet, {\n    wordTrig = false,\n    condition = pipe({ is_math }),\n    show_condition = is_math,\n  }) --[[@as function]]\n\n  return {\n    parse_snippet({ trig = \"sum\", name = \"sum\" }, \"\\\\sum_{n=${1:1}}^{${2:\\\\infty}} ${3:a_n z^n}\"),\n\n    parse_snippet(\n      { trig = \"taylor\", name = \"taylor\" },\n      \"\\\\sum_{${1:k}=${2:0}}^{${3:\\\\infty}} ${4:c_$1} (x-a)^$1 $0\"\n    ),\n\n    parse_snippet({ trig = \"lim\", name = \"limit\" }, \"\\\\lim_{${1:n} \\\\to ${2:\\\\infty}} \"),\n    parse_snippet({ trig = \"limsup\", name = \"limsup\" }, \"\\\\limsup_{${1:n} \\\\to ${2:\\\\infty}} \"),\n\n    parse_snippet(\n      { trig = \"prod\", name = \"product\" },\n      \"\\\\prod_{${1:n=${2:1}}}^{${3:\\\\infty}} ${4:${TM_SELECTED_TEXT}} $0\"\n    ),\n\n    parse_snippet(\n      { trig = \"part\", name = \"d/dx\" },\n      \"\\\\frac{\\\\partial ${1:V}}{\\\\partial ${2:x}} $0\"\n    ),\n    parse_snippet(\n      { trig = \"ddx\", name = \"d/dx\" },\n      \"\\\\frac{\\\\mathrm{d${1:V}}}{\\\\mathrm{d${2:x}}} $0\"\n    ),\n\n    parse_snippet({ trig = \"pmat\", name = \"pmat\" }, \"\\\\begin{pmatrix} $1 \\\\end{pmatrix} $0\"),\n\n    parse_snippet(\n      { trig = \"lr\", name = \"left( right)\" },\n      \"\\\\left( ${1:${TM_SELECTED_TEXT}} \\\\right) $0\"\n    ),\n    parse_snippet(\n      { trig = \"lr(\", name = \"left( right)\" },\n      \"\\\\left( ${1:${TM_SELECTED_TEXT}} \\\\right) $0\"\n    ),\n    parse_snippet(\n      { trig = \"lr|\", name = \"left| right|\" },\n      \"\\\\left| ${1:${TM_SELECTED_TEXT}} \\\\right| $0\"\n    ),\n    parse_snippet(\n      { trig = \"lr{\", name = \"left{ right}\" },\n      \"\\\\left\\\\{ ${1:${TM_SELECTED_TEXT}} \\\\right\\\\\\\\} $0\"\n    ),\n    parse_snippet(\n      { trig = \"lr[\", name = \"left[ right]\" },\n      \"\\\\left[ ${1:${TM_SELECTED_TEXT}} \\\\right] $0\"\n    ),\n    parse_snippet(\n      { trig = \"lra\", name = \"leftangle rightangle\" },\n      \"\\\\left< ${1:${TM_SELECTED_TEXT}} \\\\right>$0\"\n    ),\n\n    parse_snippet(\n      { trig = \"lrb\", name = \"left\\\\{ right\\\\}\" },\n      \"\\\\left\\\\{ ${1:${TM_SELECTED_TEXT}} \\\\right\\\\\\\\} $0\"\n    ),\n\n    parse_snippet(\n      { trig = \"sequence\", name = \"Sequence indexed by n, from m to infinity\" },\n      \"(${1:a}_${2:n})_{${2:n}=${3:m}}^{${4:\\\\infty}}\"\n    ),\n  }\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/math_iA.lua",
    "content": "local M = {}\n\nlocal ls = require(\"luasnip\")\nlocal f = ls.function_node\n\nfunction M.retrieve(is_math)\n  local utils = require(\"luasnip-latex-snippets.util.utils\")\n  local pipe, no_backslash = utils.pipe, utils.no_backslash\n\n  local decorator = {\n    wordTrig = false,\n    condition = pipe({ is_math, no_backslash }),\n  }\n\n  local parse_snippet = ls.extend_decorator.apply(ls.parser.parse_snippet, decorator) --[[@as function]]\n  local s = ls.extend_decorator.apply(ls.snippet, decorator) --[[@as function]]\n\n  return {\n    s(\n      {\n        trig = \"(%a+)bar\",\n        wordTrig = false,\n        regTrig = true,\n        name = \"bar\",\n        priority = 100,\n      },\n      f(function(_, snip)\n        return string.format(\"\\\\overline{%s}\", snip.captures[1])\n      end, {})\n    ),\n    s(\n      {\n        trig = \"(%a+)und\",\n        wordTrig = false,\n        regTrig = true,\n        name = \"underline\",\n        priority = 100,\n      },\n      f(function(_, snip)\n        return string.format(\"\\\\underline{%s}\", snip.captures[1])\n      end, {})\n    ),\n    s(\n      {\n        trig = \"(%a)dot\",\n        wordTrig = false,\n        regTrig = true,\n        name = \"dot\",\n        priority = 100,\n      },\n      f(function(_, snip)\n        return string.format(\"\\\\dot{%s}\", snip.captures[1])\n      end, {})\n    ),\n\n    s(\n      {\n        trig = \"(%a+)hat\",\n        wordTrig = false,\n        regTrig = true,\n        name = \"hat\",\n        priority = 100,\n      },\n      f(function(_, snip)\n        return string.format(\"\\\\hat{%s}\", snip.captures[1])\n      end, {})\n    ),\n    s(\n      {\n        trig = \"(%a+)ora\",\n        wordTrig = false,\n        regTrig = true,\n        name = \"ora\",\n        priority = 100,\n      },\n      f(function(_, snip)\n        return string.format(\"\\\\overrightarrow{%s}\", snip.captures[1])\n      end, {})\n    ),\n    s(\n      {\n        trig = \"(%a+)ola\",\n        wordTrig = false,\n        regTrig = true,\n        name = \"ola\",\n        priority = 100,\n      },\n      f(function(_, snip)\n        return string.format(\"\\\\overleftarrow{%s}\", snip.captures[1])\n      end, {})\n    ),\n\n    parse_snippet({ trig = \"td\", name = \"to the ... power ^{}\" }, \"^{$1}$0 \"),\n    parse_snippet({ trig = \"rd\", name = \"to the ... power ^{()}\" }, \"^{($1)}$0 \"),\n    parse_snippet({ trig = \"cb\", name = \"Cube ^3\" }, \"^3 \"),\n    parse_snippet({ trig = \"sr\", name = \"Square ^2\" }, \"^2\"),\n\n    parse_snippet({ trig = \"EE\", name = \"exists\" }, \"\\\\exists \"),\n    parse_snippet({ trig = \"AA\", name = \"forall\" }, \"\\\\forall \"),\n    parse_snippet({ trig = \"xnn\", name = \"xn\" }, \"x_{n}\"),\n    parse_snippet({ trig = \"ynn\", name = \"yn\" }, \"y_{n}\"),\n    parse_snippet({ trig = \"xii\", name = \"xi\" }, \"x_{i}\"),\n    parse_snippet({ trig = \"yii\", name = \"yi\" }, \"y_{i}\"),\n    parse_snippet({ trig = \"xjj\", name = \"xj\" }, \"x_{j}\"),\n    parse_snippet({ trig = \"yjj\", name = \"yj\" }, \"y_{j}\"),\n    parse_snippet({ trig = \"xp1\", name = \"x\" }, \"x_{n+1}\"),\n    parse_snippet({ trig = \"xmm\", name = \"x\" }, \"x_{m}\"),\n    parse_snippet({ trig = \"R0+\", name = \"R0+\" }, \"\\\\mathbb{R}_0^+\"),\n\n    parse_snippet({ trig = \"notin\", name = \"not in \" }, \"\\\\not\\\\in \"),\n\n    parse_snippet({ trig = \"cc\", name = \"subset\" }, \"\\\\subset \"),\n\n    parse_snippet({ trig = \"<->\", name = \"leftrightarrow\", priority = 200 }, \"\\\\leftrightarrow\"),\n    parse_snippet({ trig = \"...\", name = \"ldots\", priority = 100 }, \"\\\\ldots \"),\n    parse_snippet({ trig = \"!>\", name = \"mapsto\" }, \"\\\\mapsto \"),\n    parse_snippet({ trig = \"iff\", name = \"iff\" }, \"\\\\iff\"),\n    parse_snippet({ trig = \"siff\", name = \"short iff\", priority = 100}, \"\\\\Leftrightarrow\"),\n    parse_snippet({ trig = \"ooo\", name = \"\\\\infty\" }, \"\\\\infty\"),\n    parse_snippet({ trig = \"rij\", name = \"mrij\" }, \"(${1:x}_${2:n})_{${3:$2}\\\\in${4:\\\\N}}$0\"),\n    parse_snippet({ trig = \"nabl\", name = \"nabla\" }, \"\\\\nabla \"),\n    parse_snippet({ trig = \"<!\", name = \"normal\" }, \"\\\\triangleleft \"),\n    parse_snippet({ trig = \"floor\", name = \"floor\" }, \"\\\\left\\\\lfloor $1 \\\\right\\\\rfloor$0\"),\n    parse_snippet({ trig = \"mcal\", name = \"mathcal\" }, \"\\\\mathcal{$1}$0\"),\n    parse_snippet({ trig = \"//\", name = \"Fraction\" }, \"\\\\frac{$1}{$2}$0\"),\n    parse_snippet({ trig = \"\\\\\\\\\\\\\", name = \"setminus\" }, \"\\\\setminus\"),\n    parse_snippet({ trig = \"->\", name = \"to\", priority = 100 }, \"\\\\to \"),\n    parse_snippet({ trig = \"-->\", name = \"long to\", priority = 200 }, \"\\\\longrightarrow \"),\n\n    parse_snippet({ trig = \"letw\", name = \"let omega\" }, \"Let $\\\\Omega \\\\subset \\\\C$ be open.\"),\n    parse_snippet({ trig = \"nnn\", name = \"bigcap\" }, \"\\\\bigcap_{${1:i \\\\in ${2: I}}} $0\"),\n    parse_snippet({ trig = \"norm\", name = \"norm\" }, \"\\\\|$1\\\\|$0\"),\n    parse_snippet({ trig = \"<>\", name = \"hokje\" }, \"\\\\diamond \"),\n    parse_snippet({ trig = \">>\", name = \">>\" }, \"\\\\gg\"),\n    parse_snippet({ trig = \"<<\", name = \"<<\" }, \"\\\\ll\"),\n\n    parse_snippet({ trig = \"stt\", name = \"text subscript\" }, \"_\\\\text{$1} $0\"),\n    parse_snippet({ trig = \"tt\", name = \"text\" }, \"\\\\text{$1}$0\"),\n\n    parse_snippet({ trig = \"xx\", name = \"cross\" }, \"\\\\times \"),\n\n    parse_snippet({ trig = \"**\", name = \"cdot\", priority = 100 }, \"\\\\cdot \"),\n\n    parse_snippet({ trig = \":=\", name = \"colon equals (lhs defined as rhs)\" }, \"\\\\coloneqq \"),\n\n    parse_snippet(\n      { trig = \"cvec\", name = \"column vector\" },\n      \"\\\\begin{pmatrix} ${1:x}_${2:1}\\\\\\\\ \\\\vdots\\\\\\\\ $1_${2:n} \\\\end{pmatrix}\"\n    ),\n    parse_snippet({ trig = \"ceil\", name = \"ceil\" }, \"\\\\left\\\\lceil $1 \\\\right\\\\rceil $0\"),\n    parse_snippet({ trig = \"OO\", name = \"emptyset\" }, \"\\\\O\"),\n    parse_snippet({ trig = \"RR\", name = \"R\" }, \"\\\\mathbb{R}\"),\n    parse_snippet({ trig = \"QQ\", name = \"Q\" }, \"\\\\mathbb{Q}\"),\n    parse_snippet({ trig = \"ZZ\", name = \"Z\" }, \"\\\\mathbb{Z}\"),\n    parse_snippet({ trig = \"UU\", name = \"cup\" }, \"\\\\cup \"),\n    parse_snippet({ trig = \"NN\", name = \"n\" }, \"\\\\mathbb{N}\"),\n    parse_snippet({ trig = \"||\", name = \"mid\" }, \" \\\\mid \"),\n    parse_snippet({ trig = \"Nn\", name = \"cap\" }, \"\\\\cap \"),\n    parse_snippet({ trig = \"bmat\", name = \"bmat\" }, \"\\\\begin{bmatrix} $1 \\\\end{bmatrix} $0\"),\n    parse_snippet({ trig = \"uuu\", name = \"bigcup\" }, \"\\\\bigcup_{${1:i \\\\in ${2: I}}} $0\"),\n    parse_snippet({ trig = \"DD\", name = \"D\" }, \"\\\\mathbb{D}\"),\n    parse_snippet({ trig = \"HH\", name = \"H\" }, \"\\\\mathbb{H}\"),\n    parse_snippet({ trig = \"lll\", name = \"l\" }, \"\\\\ell\"),\n    parse_snippet(\n      { trig = \"dint\", name = \"integral\", priority = 300 },\n      \"\\\\int_{${1:-\\\\infty}}^{${2:\\\\infty}} ${3:${TM_SELECTED_TEXT}} $0\"\n    ),\n\n    parse_snippet({ trig = \"==\", name = \"equals\" }, [[&= $1 \\\\\\\\]]),\n    parse_snippet({ trig = \"!=\", name = \"not equals\" }, \"\\\\neq \"),\n    parse_snippet({ trig = \"compl\", name = \"complement\" }, \"^{c}\"),\n    parse_snippet({ trig = \"__\", name = \"subscript\" }, \"_{$1}$0\"),\n    parse_snippet({ trig = \"=>\", name = \"implies\" }, \"\\\\implies\"),\n    parse_snippet({ trig = \"simp\", name = \"short implies\" }, \"\\\\Rightarrow\"),\n    parse_snippet({ trig = \"=<\", name = \"implied by\" }, \"\\\\impliedby\"),\n    parse_snippet({ trig = \"<<\", name = \"<<\" }, \"\\\\ll\"),\n\n    parse_snippet({ trig = \"<=\", name = \"leq\" }, \"\\\\le \"),\n    parse_snippet({ trig = \">=\", name = \"geq\" }, \"\\\\ge \"),\n    parse_snippet({ trig = \"invs\", name = \"inverse\" }, \"^{-1}\"),\n    parse_snippet({ trig = \"~~\", name = \"~\" }, \"\\\\sim \"),\n    parse_snippet({ trig = \"conj\", name = \"conjugate\" }, \"\\\\overline{$1}$0\"),\n  }\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/math_iA_no_backslash.lua",
    "content": "local M = {}\n\nlocal ls = require(\"luasnip\")\n\nfunction M.retrieve(is_math)\n  local utils = require(\"luasnip-latex-snippets.util.utils\")\n  local pipe, no_backslash = utils.pipe, utils.no_backslash\n\n  local parse_snippet = ls.extend_decorator.apply(ls.parser.parse_snippet, {\n    wordTrig = false,\n    condition = pipe({ is_math, no_backslash }),\n  }) --[[@as function]]\n\n  local with_priority = ls.extend_decorator.apply(parse_snippet, {\n    priority = 10,\n  }) --[[@as function]]\n\n  return {\n    parse_snippet({ trig = \"sq\", name = \"\\\\sqrt{}\" }, \"\\\\sqrt{${1:${TM_SELECTED_TEXT}}} $0\"),\n    parse_snippet({ trig = \"case\", name = \"cases\" }, \"\\\\begin{cases}\\n\\t$1\\n\\\\end{cases}\"),\n\n    with_priority({ trig = \"hat\", name = \"hat\" }, \"\\\\hat{$1}$0 \"),\n    with_priority({ trig = \"bar\", name = \"bar\" }, \"\\\\overline{$1}$0 \"),\n\n    parse_snippet({ trig = \"inf\", name = \"\\\\infty\" }, \"\\\\infty\"),\n    parse_snippet({ trig = \"inn\", name = \"in \" }, \"\\\\in \"),\n    parse_snippet({ trig = \"SI\", name = \"SI\" }, \"\\\\SI{$1}{$2}\"),\n  }\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/math_rA_no_backslash.lua",
    "content": "local ls = require(\"luasnip\")\nlocal s = ls.snippet\nlocal f = ls.function_node\n\nlocal M = {}\n\nM.decorator = {}\n\nlocal postfix_trig = function(match)\n  return string.format(\"(%s)\", match)\nend\n\nlocal postfix_node = f(function(_, snip)\n  return string.format(\"\\\\%s \", snip.captures[1])\nend, {})\n\nlocal build_snippet = function(trig, node, match, priority, name)\n  return s({\n    name = name and name(match) or match,\n    trig = trig(match),\n    priority = priority,\n  }, vim.deepcopy(node))\nend\n\nlocal build_with_priority = function(trig, node, priority, name)\n  return function(match)\n    return build_snippet(trig, node, match, priority, name)\n  end\nend\n\nlocal vargreek_postfix_completions = function()\n  local re = \"varepsilon|varphi|varrho|vartheta\"\n\n  local build = build_with_priority(postfix_trig, postfix_node, 200)\n  return vim.tbl_map(build, vim.split(re, \"|\"))\nend\n\nlocal greek_postfix_completions = function()\n  local re =\n    \"[aA]lpha|[bB]eta|[cC]hi|[dD]elta|[eE]psilon|[gG]amma|[iI]ota|[kK]appa|[lL]ambda|[mM]u|[nN]u|[oO]mega|[pP]hi|[pP]i|[pP]si|[rR]ho|[sS]igma|[tT]au|[tT]heta|[zZ]eta|[eE]ta\"\n\n  local build = build_with_priority(postfix_trig, postfix_node, 200)\n  return vim.tbl_map(build, vim.split(re, \"|\"))\nend\n\nlocal postfix_completions = function()\n  local re = \"sin|cos|tan|csc|sec|cot|ln|log|exp|star|perp|int\"\n\n  local build = build_with_priority(postfix_trig, postfix_node)\n  return vim.tbl_map(build, vim.split(re, \"|\"))\nend\n\nlocal snippets = {}\n\nfunction M.retrieve(is_math)\n  local utils = require(\"luasnip-latex-snippets.util.utils\")\n  local pipe = utils.pipe\n  local no_backslash = utils.no_backslash\n\n  M.decorator = {\n    wordTrig = true,\n    trigEngine = \"pattern\",\n    condition = pipe({ is_math, no_backslash }),\n  }\n\n  s = ls.extend_decorator.apply(ls.snippet, M.decorator) --[[@as function]]\n\n  vim.list_extend(snippets, vargreek_postfix_completions())\n  vim.list_extend(snippets, greek_postfix_completions())\n  vim.list_extend(snippets, postfix_completions())\n  vim.list_extend(snippets, { build_snippet(postfix_trig, postfix_node, \"q?quad\", 200) })\n\n  return snippets\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/math_wA_no_backslash.lua",
    "content": "local ls = require(\"luasnip\")\n\nlocal utils = require(\"luasnip-latex-snippets.util.utils\")\nlocal pipe = utils.pipe\nlocal no_backslash = utils.no_backslash\n\nlocal M = {}\n\nfunction M.retrieve(is_math)\n  local parse_snippet = ls.extend_decorator.apply(ls.parser.parse_snippet, {\n    condition = pipe({ is_math, no_backslash }),\n  }) --[[@as function]]\n\n  local with_priority = ls.extend_decorator.apply(parse_snippet, {\n    priority = 10,\n  }) --[[@as function]]\n\n  return {\n    with_priority({ trig = \"arcsin\", name = \"arcsin\" }, \"\\\\arcsin \"),\n    with_priority({ trig = \"arctan\", name = \"arctan\" }, \"\\\\arctan \"),\n    with_priority({ trig = \"arcsec\", name = \"arcsec\" }, \"\\\\arcsec \"),\n    with_priority({ trig = \"asin\", name = \"asin\" }, \"\\\\arcsin\"),\n    with_priority({ trig = \"atan\", name = \"atan\" }, \"\\\\arctan\"),\n    with_priority({ trig = \"asec\", name = \"asec\" }, \"\\\\arcsec\"),\n\n    parse_snippet({ trig = \"set\", name = \"set\" }, [[ \\\\{$1\\\\} $0 ]]),\n    parse_snippet({ trig = \"fun\", name = \"function map\" }, \"f \\\\colon $1 \\\\R \\\\to \\\\R \\\\colon $0\"),\n\n    parse_snippet(\n      { trig = \"abs\", name = \"absolute value \\\\abs{}\" },\n      \"\\\\abs{${1:${TM_SELECTED_TEXT}}}$0\"\n    ),\n  }\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/math_wRA_no_backslash.lua",
    "content": "local ls = require(\"luasnip\")\nlocal f = ls.function_node\n\nlocal M = {}\n\nlocal vec_node = {\n  f(function(_, snip)\n    return string.format(\"\\\\vec{%s} \", snip.captures[1])\n  end, {}),\n}\n\nM.math_wrA_no_backslash = {\n  { \"([%a][%a])(%.,)\", vec_node },\n  { \"([%a][%a])(,%.)\", vec_node },\n  { \"([%a])(%.,)\", vec_node },\n  { \"([%a])(,%.)\", vec_node },\n}\n\nM.decorator = {}\n\nfunction M.retrieve(is_math)\n  local utils = require(\"luasnip-latex-snippets.util.utils\")\n  local pipe = utils.pipe\n  local no_backslash = utils.no_backslash\n\n  M.decorator = {\n    wordTrig = true,\n    trigEngine = \"pattern\",\n    condition = pipe({ is_math, no_backslash }),\n  }\n\n  local s = ls.extend_decorator.apply(ls.snippet, M.decorator) --[[@as function]]\n\n  return vim.tbl_map(function(x)\n    local trig, node = unpack(x)\n    return s({ trig = trig }, vim.deepcopy(node))\n  end, M.math_wrA_no_backslash)\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/math_wrA.lua",
    "content": "local M = {}\n\nlocal ls = require(\"luasnip\")\nlocal f = ls.function_node\nlocal i = ls.insert_node\nlocal t = ls.text_node\n\nlocal frac_no_parens = {\n  f(function(_, snip)\n    return string.format(\"\\\\frac{%s}\", snip.captures[1])\n  end, {}),\n  t(\"{\"),\n  i(1),\n  t(\"}\"),\n  i(0),\n}\n\nlocal frac_node = {\n  f(function(_, snip)\n    local match = snip.trigger\n    local stripped = match:sub(1, #match - 1)\n\n    i = #stripped\n    local depth = 0\n    while i >= 0 do\n      if stripped:sub(i, i) == \")\" then\n        depth = depth + 1\n      end\n      if stripped:sub(i, i) == \"(\" then\n        depth = depth - 1\n      end\n      if depth == 0 then\n        break\n      end\n      i = i - 1\n    end\n\n    if depth ~= 0 then\n      return string.format(\"%s\\\\frac{}\", stripped)\n    else\n      return string.format(\"%s\\\\frac{%s}\", stripped:sub(1, i - 1), stripped:sub(i + 1, #stripped - 1))\n    end\n  end, {}),\n  t(\"{\"),\n  i(1),\n  t(\"}\"),\n  i(0),\n}\n\nlocal subscript_node = {\n  f(function(_, snip)\n    return string.format(\"%s_{%s}\", snip.captures[1], snip.captures[2])\n  end, {}),\n  i(0),\n}\n\nlocal frac_no_parens_triggers = {\n  \"(\\\\?[%w]+\\\\?^%w)/\",\n  \"(\\\\?[%w]+\\\\?_%w)/\",\n  \"(\\\\?[%w]+\\\\?^{%w*})/\",\n  \"(\\\\?[%w]+\\\\?_{%w*})/\",\n  \"(\\\\?%w+)/\",\n}\n\nfunction M.retrieve(is_math)\n  local utils = require(\"luasnip-latex-snippets.util.utils\")\n  local pipe = utils.pipe\n\n  local s = ls.extend_decorator.apply(ls.snippet, {\n    wordTrig = false,\n    trigEngine = \"pattern\",\n    condition = pipe({ is_math }),\n  }) --[[@as function]]\n\n  local snippets = {\n    s({\n      trig = \"([%a])(%d)\",\n      name = \"auto subscript\",\n    }, vim.deepcopy(subscript_node)),\n\n    s({\n      trig = \"([%a])_(%d%d)\",\n      name = \"auto subscript 2\",\n    }, vim.deepcopy(subscript_node)),\n\n    s({\n      priority = 1000,\n      trig = \".*%)/\",\n      name = \"() frac\",\n      wordTrig = true,\n    }, vim.deepcopy(frac_node)),\n  }\n\n  for _, trig in pairs(frac_no_parens_triggers) do\n    snippets[#snippets + 1] = s({\n      name = \"Fraction no ()\",\n      trig = trig,\n    }, vim.deepcopy(frac_no_parens))\n  end\n\n  return snippets\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/util/ts_utils.lua",
    "content": "local M = {}\n\nlocal MATH_NODES = {\n    displayed_equation = true,\n    inline_formula = true,\n    math_environment = true,\n}\n\nlocal TEXT_NODES = {\n    text_mode = true,\n    label_definition = true,\n    label_reference = true,\n}\n\nlocal CODE_BLOCK_NODES = { -- Add this to define code block node types\n    fenced_code_block = true,\n    indented_code_block = true, -- Optional: include indented code blocks as well if needed\n}\n\nfunction M.in_text(check_parent)\n    local node = vim.treesitter.get_node({ ignore_injections = false })\n    \n    -- Check for code blocks in any filetype\n    local block_node = node\n    while block_node do\n        if CODE_BLOCK_NODES[block_node:type()] then\n            return true -- If in a code block, always consider it text\n        end\n        block_node = block_node:parent()\n    end\n\n    while node do\n        if node:type() == \"text_mode\" then\n            if check_parent then\n                -- For \\text{}\n                local parent = node:parent()\n                if parent and MATH_NODES[parent:type()] then\n                    return false\n                end\n            end\n            return true\n        elseif MATH_NODES[node:type()] then\n            return false\n        end\n        node = node:parent()\n    end\n    return true\nend\n\nfunction M.in_mathzone()\n    local node = vim.treesitter.get_node({ ignore_injections = false })\n    local current_filetype = vim.bo.filetype\n\n    -- Check if we are in a markdown file and inside a code block\n    if current_filetype == \"markdown\" or current_filetype == \"quarto\" then\n        local block_node = node\n        while block_node do\n            if CODE_BLOCK_NODES[block_node:type()] then\n                return false -- If in a code block in markdown, never consider it math zone\n            end\n            block_node = block_node:parent()\n        end\n    end\n\n    while node do\n        if TEXT_NODES[node:type()] then\n            return false\n        elseif MATH_NODES[node:type()] then\n            return true\n        end\n        node = node:parent()\n    end\n    return false\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/util/utils.lua",
    "content": "local M = {}\n\n-- local s = ls.snippet\n-- local sn = ls.snippet_node\n-- local isn = ls.indent_snippet_node\n-- local t = ls.text_node\n-- local i = ls.insert_node\n-- local f = ls.function_node\n-- local c = ls.choice_node\n-- local d = ls.dynamic_node\n-- local events = require(\"luasnip.util.events\")\n-- local r = require(\"luasnip.extras\").rep\n-- local fmt = require(\"luasnip.extras.fmt\").fmt\n-- local fmta = require(\"luasnip.extras.fmt\").fmta\n\nM.pipe = function(fns)\n  return function(...)\n    for _, fn in ipairs(fns) do\n      if not fn(...) then\n        return false\n      end\n    end\n\n    return true\n  end\nend\n\nM.no_backslash = function(line_to_cursor, matched_trigger)\n  return not line_to_cursor:find(\"\\\\%a+$\", -#line_to_cursor)\nend\n\nlocal ts_utils = require(\"luasnip-latex-snippets.util.ts_utils\")\nM.is_math = function(treesitter)\n  if treesitter then\n    return ts_utils.in_mathzone()\n  end\n\n  return vim.fn[\"vimtex#syntax#in_mathzone\"]() == 1\nend\n\nM.not_math = function(treesitter)\n  if treesitter then\n    return ts_utils.in_text(true)\n  end\n\n  return not M.is_math()\nend\n\nM.comment = function()\n  return vim.fn[\"vimtex#syntax#in_comment\"]() == 1\nend\n\nM.env = function(name)\n  local x, y = unpack(vim.fn[\"vimtex#env#is_inside\"](name))\n  return x ~= \"0\" and y ~= \"0\"\nend\n\nM.with_priority = function(snip, priority)\n  snip.priority = priority\n  return snip\nend\n\nM.with_opts = function(fn, opts)\n  return function()\n    return fn(opts)\n  end\nend\n\nreturn M\n"
  },
  {
    "path": "lua/luasnip-latex-snippets/wA.lua",
    "content": "local ls = require(\"luasnip\")\nlocal utils = require(\"luasnip-latex-snippets.util.utils\")\nlocal pipe = utils.pipe\n\nlocal M = {}\n\nfunction M.retrieve(not_math)\n  local parse_snippet = ls.extend_decorator.apply(ls.parser.parse_snippet, {\n    condition = pipe({ not_math }),\n  }) --[[@as function]]\n\n  return {\n    parse_snippet({ trig = \"mk\", name = \"Math\" }, \"\\\\( ${1:${TM_SELECTED_TEXT}} \\\\)$0\"),\n    parse_snippet({ trig = \"dm\", name = \"Block Math\" }, \"\\\\[\\n\\t${1:${TM_SELECTED_TEXT}}\\n\\\\] $0\"),\n  }\nend\n\nreturn M\n"
  }
]