diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 005b535b606..00000000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -tags -test.sh -.luarc.json -nvim - -spell/ -lazy-lock.json diff --git a/init.lua b/init.lua index cbf9ff65d67..a1b3c8caf2d 100644 --- a/init.lua +++ b/init.lua @@ -290,7 +290,7 @@ require('lazy').setup({ -- Then, because we use the `opts` key (recommended), the configuration runs -- after the plugin has been loaded as `require(MODULE).setup(opts)`. - { -- Useful plugin to show you pending keybinds. + { -- Useful plugin to show you pending keybinds. 'folke/which-key.nvim', event = 'VimEnter', -- Sets the loading event to 'VimEnter' opts = { @@ -336,7 +336,7 @@ require('lazy').setup({ -- Document existing key chains spec = { - { 'c', group = '[C]ode', mode = { 'n', 'x' } }, + { 'c', group = '[C]ode', mode = { 'n', 'x' } }, { 'd', group = '[D]ocument' }, { 'r', group = '[R]ename' }, { 's', group = '[S]earch' }, @@ -376,7 +376,7 @@ require('lazy').setup({ { 'nvim-telescope/telescope-ui-select.nvim' }, -- Useful for getting pretty icons, but requires a Nerd Font. - { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, + { 'nvim-tree/nvim-web-devicons', enabled = vim.g.have_nerd_font }, }, config = function() -- Telescope is a fuzzy finder that comes with a lot of different things that @@ -472,6 +472,9 @@ require('lazy').setup({ }, }, }, + + { 'Bilal2453/luvit-meta', lazy = true }, + { -- Main LSP Configuration 'neovim/nvim-lspconfig', @@ -484,8 +487,10 @@ require('lazy').setup({ 'WhoIsSethDaniel/mason-tool-installer.nvim', -- Useful status updates for LSP. + { 'j-hui/fidget.nvim', opts = {} }, + -- Allows extra capabilities provided by nvim-cmp 'hrsh7th/cmp-nvim-lsp', }, @@ -795,12 +800,12 @@ require('lazy').setup({ -- `friendly-snippets` contains a variety of premade snippets. -- See the README about individual language/framework/plugin snippets: -- https://github.com/rafamadriz/friendly-snippets - -- { - -- 'rafamadriz/friendly-snippets', - -- config = function() - -- require('luasnip.loaders.from_vscode').lazy_load() - -- end, - -- }, + { + 'rafamadriz/friendly-snippets', + config = function() + require('luasnip.loaders.from_vscode').lazy_load() + end, + }, }, }, 'saadparwaiz1/cmp_luasnip', @@ -816,7 +821,7 @@ require('lazy').setup({ -- See `:help cmp` local cmp = require 'cmp' local luasnip = require 'luasnip' - luasnip.config.setup {} + luasnip.config.setup ({ enable_autosnippets = true }) cmp.setup { snippet = { @@ -911,7 +916,12 @@ require('lazy').setup({ -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + + vim.cmd.colorscheme 'tokyonight' + + -- You can configure highlights by doing something like: + vim.cmd.hi 'Comment gui=none' + end, }, @@ -966,10 +976,11 @@ require('lazy').setup({ auto_install = true, highlight = { enable = true, + disable = {"latex"}, -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. -- If you are experiencing weird indenting issues, add the language to -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, + additional_vim_regex_highlighting = { 'ruby', "latex","markdown" }, }, indent = { enable = true, disable = { 'ruby' } }, }, @@ -1001,7 +1012,7 @@ require('lazy').setup({ -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -1031,3 +1042,16 @@ require('lazy').setup({ -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et +-- +require("luasnip.loaders.from_lua").load({paths = "/home/BogosBinted/.config/nvim-kickstart/lua/custom/plugins/Luasnip"}) + +-- Somewhere in your Neovim startup, e.g. init.lua +require("luasnip").config.set_config({ -- Setting LuaSnip config + + -- Enable autotriggered snippets + enable_autosnippets = true, + + -- Use Tab (or some other key if you prefer) to trigger visual selection + store_selection_keys = "", +}) + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 00000000000..66b6ce112de --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,32 @@ +{ + "LuaSnip": { "branch": "master", "commit": "0f7bbce41ea152a94d12aea286f2ce98e63c0f58" }, + "auto-session": { "branch": "main", "commit": "8d2eddb14ef66ed1019c92251e2d31bb7a2a2f87" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "f1125f8eace158255cf55772ce039aaf178a6b42" }, + "fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, + "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "gitsigns.nvim": { "branch": "main", "commit": "ac5aba6dce8c06ea22bea2c9016f51a2dbf90dc7" }, + "lazy.nvim": { "branch": "main", "commit": "56ead98e05bb37a4ec28930a54d836d033cf00f2" }, + "lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" }, + "luvit-meta": { "branch": "main", "commit": "57d464c4acb5c2e66bd4145060f5dc9e96a7bbb7" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "43894adcf10bb1190c2184bd7c1750e8ea2b3dce" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.nvim": { "branch": "main", "commit": "6714e738555b1cfbef646a23af29aa113f91f4fe" }, + "nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" }, + "nvim-cmp": { "branch": "main", "commit": "40a03dc225383c4f6256596c2cdf27e03b8119b5" }, + "nvim-lspconfig": { "branch": "master", "commit": "f012c1b176f0e3c71f40eb309bdec0316689462e" }, + "nvim-treesitter": { "branch": "master", "commit": "a3a732107f8b529f97bf4921b3e1af5dcc756bb6" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "0.1.x", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, + "tokyonight.nvim": { "branch": "main", "commit": "c2725eb6d086c8c9624456d734bd365194660017" }, + "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vimtex": { "branch": "master", "commit": "6ee92c7ed2cdc876f499bd5561a65d04dee10d1f" }, + "which-key.nvim": { "branch": "main", "commit": "68e37e12913a66b60073906f5d3f14dee0de19f2" } +} diff --git a/lua/custom/plugins/Luasnip/all.lua b/lua/custom/plugins/Luasnip/all.lua new file mode 100644 index 00000000000..934474fccf3 --- /dev/null +++ b/lua/custom/plugins/Luasnip/all.lua @@ -0,0 +1,15 @@ +-- Place this in ${HOME}/.config/nvim/LuaSnip/all.lua +return { + -- A snippet that expands the trigger "hi" into the string "Hello, world!". + require("luasnip").snippet( + { trig = "hi" }, + { t("Hello, world!") } + ), + + -- To return multiple snippets, use one `return` statement per snippet file + -- and return a table of Lua snippets. + require("luasnip").snippet( + { trig = "foo" }, + { t("Another snippet.") } + ), +} diff --git a/lua/custom/plugins/Luasnip/tex/all.lua b/lua/custom/plugins/Luasnip/tex/all.lua new file mode 100644 index 00000000000..9b4ff22f031 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/all.lua @@ -0,0 +1,16 @@ +return { + -- Example: how to set snippet parameters + require("luasnip").snippet( + { -- Table 1: snippet parameters + trig="saucisse", + dscr="An autotriggering snippet that expands 'hi' into 'Hello, world!'", + regTrig=false, + priority=100, + snippetType="autosnippet" + }, + { -- Table 2: snippet nodes (don't worry about this for now---we'll cover nodes shortly) + t("Hello, world!"), -- A single text node + } + -- Table 3, the advanced snippet options, is left blank. + ), +} \ No newline at end of file diff --git a/lua/custom/plugins/Luasnip/tex/delimiters.lua b/lua/custom/plugins/Luasnip/tex/delimiters.lua new file mode 100644 index 00000000000..1bc00210e81 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/delimiters.lua @@ -0,0 +1,131 @@ +local ls = require("luasnip") +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local fmt = require("luasnip.extras.fmt").fmt + +-- Add LaTeX snippets +return { -- [[ + -- Implies + s({trig="=>", snippetType="autosnippet"}, + { + t("\\implies") + }), + + -- Inline Math + s({trig="mk", snippetType="autosnippet"}, fmt("${}$", { i(1) })), + + + -- Not Equals + s({trig="!=",snippetType="autosnippet"}, t("\\neq")), + + -- Sum + s({trig="sum",snippetType="autosnippet"}, fmt("\\sum_{{n={}}}^{{{}}} {}", { i(1, "1"), i(2, "\\infty"), i(3, "a_n z^n") })), + + -- Taylor Series + s({trig="taylor",snippetType="autosnippet"}, fmt("\\sum_{{{}={}}}^{{{}}} {} (x-a)^{}", { i(1, "k"), i(2, "0"), i(3, "\\infty"), i(4, "c_"), i(1) })), + + -- Limit + s({trig="lim",snippetType="autosnippet"}, fmt("\\lim_{{{} \\to {}}}", { i(1, "n"), i(2, "\\infty") })), + + s({trig="xx",snippetType="autosnippet"}, t("\\times")), + --[[ + -- Greek Letters + s("alpha", t("\\alpha")), + s("beta", t("\\beta")), + s("gamma", t("\\gamma")), + s("delta", t("\\delta")), + s("epsilon", t("\\epsilon")), + s("zeta", t("\\zeta")), + s("eta", t("\\eta")), + s("theta", t("\\theta")), + s("iota", t("\\iota")), + s("kappa", t("\\kappa")), + s("lambda", t("\\lambda")), + s("mu", t("\\mu")), + s("nu", t("\\nu")), + s("xi", t("\\xi")), + s("omicron", t("\\omicron")), + s("pi", t("\\pi")), + s("rho", t("\\rho")), + s("sigma", t("\\sigma")), + s("tau", t("\\tau")), + s("upsilon", t("\\upsilon")), + s("phi", t("\\phi")), + s("chi", t("\\chi")), + s("psi", t("\\psi")), + s("omega", t("\\omega")), + s("Alpha", t("\\Alpha")), + s("Beta", t("\\Beta")), + s("Gamma", t("\\Gamma")), + s("Delta", t("\\Delta")), + s("Epsilon", t("\\Epsilon")), + s("Zeta", t("\\Zeta")), + s("Eta", t("\\Eta")), + s("Theta", t("\\Theta")), + s("Iota", t("\\Iota")), + s("Kappa", t("\\Kappa")), + s("Lambda", t("\\Lambda")), + s("Mu", t("\\Mu")), + s("Nu", t("\\Nu")), + s("Xi", t("\\Xi")), + s("Omicron", t("\\Omicron")), + s("Pi", t("\\Pi")), + s("Rho", t("\\Rho")), + s("Sigma", t("\\Sigma")), + s("Tau", t("\\Tau")), + s("Upsilon", t("\\Upsilon")), + s("Phi", t("\\Phi")), + s("Chi", t("\\Chi")), + s("Psi", t("\\Psi")), + s("Omega", t("\\Omega")), + + -- Other Symbols + s("ooo", t("\\infty")), + s("prod", t("\\prod")), + s("pm", t("\\pm")), + s("mp", t("\\mp")), + s("+-", t("\\pm")), + s("-+", t("\\mp")), + s("...", t("\\dots")), + s("<->", t("\\leftrightarrow")), + s("->", t("\\to")), + s("!>", t("\\mapsto")), + s("invs", t("^{-1}")), + s("\\\\\\", t("\\setminus")), + s("||", t("\\mid")), + s("and", t("\\cap")), + s("orr", t("\\cup")), + s("inn", t("\\in")), + s("notin", t("\\not\\in")), + s("\\subset eq", t("\\subseteq")), + s("eset", t("\\emptyset")), + s("set", fmt("\\{{}}", { i(1) })), + s("=>", t("\\implies")), + s("=<", t("\\impliedby")), + s("iff", t("\\iff")), + s("exists", t("\\exists")), + + -- Special Formatting + s("mcal", fmt("\\mathcal{{{}}}", { i(1) })), + s("mbb", fmt("\\mathbb{{{}}}", { i(1) })), + s("ell", t("\\ell")), + s("lll", t("\\ell")), + s("LL", t("\\mathcal{L}")), + s("HH", t("\\mathcal{H}")), + s("CC", t("\\mathbb{C}")), + s("RR", t("\\mathbb{R}")), + s("ZZ", t("\\mathbb{Z}")), + s("NN", t("\\mathbb{N}")), + s("II", t("\\mathbb{1}")), + + -- Miscellaneous Symbols + s("del", t("\\nabla")), + s("avg", fmt("\\langle {} \\rangle", { i(1) })), + s("norm", fmt("\\lvert {} \\rvert", { i(1) })), + s("ceil", fmt("\\lceil {} \\rceil", { i(1) })), + s("floor", fmt("\\lfloor {} \\rfloor", { i(1) })) + ]]-- +} + diff --git a/lua/custom/plugins/Luasnip/tex/floats.lua b/lua/custom/plugins/Luasnip/tex/floats.lua new file mode 100644 index 00000000000..6478ba3baa6 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/floats.lua @@ -0,0 +1,189 @@ +local ls = require("luasnip") +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local fmt = require("luasnip.extras.fmt").fmt + +return { + + +-- Tabular material + +s({trig = "tab", name = "Table environment"}, + { + t("\\begin{table}["), i(1,"opt"), t("]"), + t({"",""}), t("\\begin{tabular}{"), i(2,"cols"), t("}"), + t({"",""}), t(" "), i(3), + t({"",""}), t("\\end{tabular}"), + t({"",""}), t("\\end{table}") + } +), + +s({trig = "rr", name = "Array environment"}, + { + t("\\begin{array}{"), i(1,"cols"), t("}"), + t({"",""}), t(" "), i(2), + t({"",""}), t("\\end{array}") + } +), + +s({trig = "he", name = "Break line height"}, + { + t("\\\\["), i(1), t("]"), + t({"",""}) + } +), + +s({trig = "hyp", name = "Hyphenate text correctly"}, + { + t("\\hspace{0pt}") + } +), + +s({trig = "bck", name = "Redefine \\\\ last column"}, + { + t("\\arraybackslash") + } +), + +s({trig = "lt", name = "Align text to left"}, + { + t("\\raggedleft") + } +), + +s({trig = "cr", name = "Align text to center"}, + { + t("\\centering") + } +), + +s({trig = "rt", name = "Align text to right"}, + { + t("\\raggedright") + } +), + +s({trig = "hn", name = "Horizontal line"}, + { + t("\\hline"), + t({"",""}) + } +), + +s({trig = "br", name = "Tabular row break"}, + { + t("\\\\"), + t({"",""}), i(1) + } +), + +-- Tabular environment preamble options + +s({trig = "pc", name = "Top column"}, + { + t("p{"), i(1,"width"), t("}") + } +), + +s({trig = "cop", name = "num copies of opts"}, + { + t("*{"), i(1,"num"), t("}{"), i(2,"opts"), t("}") + } +), + +s({trig = "mc", name = "Vertically centered column"}, + { + t("m{"), i(1,"width"), t("}") + } +), + +s({trig = "bc", name = "Bottom column"}, + { + t("b{"), i(1,"width"), t("}") + } +), + +s({trig = "bl", name = "Before column options"}, + { + t(">{"), i(1,"decl"), t("}") + } +), + +s({trig = "af", name = "After column options"}, + { + t("<{"), i(1,"decl"), t("}") + } +), + +-- Floats + +s({trig = "cpt", name = "Caption"}, + { + c(1, + { + { + t("\\caption{"), i(1,"text"), t("}") + }, + { + t("\\caption["), i(1,"list-entry"), t("]{"), i(2,"text"), t("}") + } + } + ) + } +), + +s({trig = "cof", name = "Caption of"}, + { + c(1, + { + { + t("\\captionof{"), i(1,"type"), t("}{"), i(2,"text"), t("}") + }, + { + t("\\captionof{"), i(1,"type"), t("}["), i(2,"list-entry"), t("]{"), i(3,"text"), t("}") + }, + { + t("\\captionof*{"), i(1,"type"), t("}{"), i(2,"text"), t("}") + } + } + ) + } +), + +s({trig = "sbf", name = "Subfloat"}, + { + c(1, + { + { + t("\\subfloat{"), i(1,"object"), t("}") + }, + { + t("\\subfloat["), i(1,"caption"), t("]{"), i(2,"object"), t("}") + }, + { + t("\\subfloat["), i(1,"list-entry"), t("]["), i(2,"caption"), t("]{"), i(3,"object"), t("}") + } + } + ) + } +), + +s({trig = "snt", name = "Sub-numbers for tables"}, + { + t("\\begin{subtables}"), + t({"",""}), t(" "), i(1), + t({"",""}), t("\\end{subtables}") + } +), + +s({trig = "snf", name = "Sub-numbers for figures"}, + { + t("\\begin{subfigures}"), + t({"",""}), t(" "), i(1), + t({"",""}), t("\\end{subfigures}") + } +), + +} diff --git a/lua/custom/plugins/Luasnip/tex/fonts.lua b/lua/custom/plugins/Luasnip/tex/fonts.lua new file mode 100644 index 00000000000..a0cf5b540c1 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/fonts.lua @@ -0,0 +1,244 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local d = ls.dynamic_node +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local rep = require("luasnip.extras").rep + + +-- Visual placeholder +-- +-- taken from https://ejmastnak.com/ + +local get_visual = function(args, parent, default_text) + if (#parent.snippet.env.LS_SELECT_RAW > 0) then + return sn(nil, i(1,parent.snippet.env.LS_SELECT_RAW)) + else -- If LS_SELECT_RAW is empty, return a blank insert node + return sn(nil, i(1,default_text)) + end +end + +local function v(pos, default_text) + return d(pos, function(args, parent) return get_visual(args, parent, default_text) end) +end + +return { + +-- Fonts + +-- Standard size-changing commands + +s({trig = "tny", name = "Tiny font size"}, + { + t("\\tiny") + } +), + +s({trig = "scr", name = "Scriptize font size"}, + { + t("\\scriptsize") + } +), + +s({trig = "fot", name = "Footnote size"}, + { + t("\\footnotesize") + } +), + +s({trig = "sma", name = "Small font size"}, + { + t("\\small") + } +), + +s({trig = "nor", name = "Normalsize font"}, + { + t("\\normalsize") + } +), + +s({trig = "lar", name = "Large font size"}, + { + c(1, + { + { + i(1,"\\large") + }, + { + i(1,"\\Large") + }, + { + i(1,"\\LARGE") + } + } + ) + } +), + +s({trig = "hug", name = "Huge font size"}, + { + c(1, + { + { + i(1,"\\huge") + }, + { + i(1,"\\Huge") + } + } + ) + } +), + +-- Standard font-changing commands and declarations + +s({trig = "rm", name = "Roman family"}, + { + c(1, + { + { + t("\\textrm{"), v(1,"text"), t("}") + }, + { + t("\\begin{rmfamily}"), v(1,"..."), t("\\end{rmfamily}") + }, + { + i(1,"\\rmfamily") + } + } + ) + } +), + +s({trig = "sf", name = "Sans serif family"}, + { + c(1, + { + { + t("\\textsf{"), v(1,"text"), t("}") + }, + { + t("\\begin{sffamily}"), v(1,"..."), t("\\end{sffamily}") + }, + { + i(1,"\\sffamily") + } + } + ) + } +), + +s({trig = "tt", name = "Typewriter family"}, + { + c(1, + { + { + t("\\texttt{"), v(1,"text"), t("}") + }, + { + t("\\begin{ttfamily}"), v(1,"..."), t("\\end{ttfamily}") + }, + { + i(1,"\\ttfamily") + } + } + ) + } +), + +s({trig = "bf", name = "Bold series"}, + { + c(1, + { + { + t("\\textbf{"), v(1,"text"), t("}") + }, + { + t("\\begin{bfseries}"), v(1,"..."), t("\\end{bfseries}") + }, + { + i(1,"\\bfseries") + } + } + ) + } +), + +s({trig = "it", name = "Italic shape"}, + { + c(1, + { + { + t("\\textit{"), v(1,"text"), t("}") + }, + { + t("\\begin{itshape}"), v(1,"..."), t("\\end{itshape}") + }, + { + i(1,"\\itshape") + } + } + ) + } +), + +s({trig = "sc", name = "Small caps shape"}, + { + c(1, + { + { + t("\\textsc{"), v(1,"text"), t("}") + }, + { + t("\\begin{scshape}"), v(1,"..."), t("\\end{scshape}") + }, + { + i(1,"\\scshape") + } + } + ) + } +), + +s({trig = "em", name = "Emphasized text"}, + { + c(1, + { + { + t("\\emph{"), v(1,"text"), t("}") + }, + { + t("\\begin{em}"), v(1,"..."), t("\\end{em}") + }, + { + i(1,"\\em") + } + } + ) + } +), + +s({trig = "tn", name = "Main font"}, + { + c(1, + { + { + t("\\textnormal{"), v(1,"text"), t("}") + }, + { + t("\\begin{normalfont}"), v(1,"..."), t("\\end{normalfont}") + }, + { + i(1,"\\normalfont") + } + } + ) + } +), + +} diff --git a/lua/custom/plugins/Luasnip/tex/formatting.lua b/lua/custom/plugins/Luasnip/tex/formatting.lua new file mode 100644 index 00000000000..d6cdf1f19d8 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/formatting.lua @@ -0,0 +1,491 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local d = ls.dynamic_node +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local rep = require("luasnip.extras").rep +local c = ls.choice_node + + +-- Visual placeholder +-- taken from https://ejmastnak.com/ + +local get_visual = function(args, parent, default_text) + if (#parent.snippet.env.LS_SELECT_RAW > 0) then + return sn(nil, i(1,parent.snippet.env.LS_SELECT_RAW)) + else -- If LS_SELECT_RAW is empty, return a blank insert node + return sn(nil, i(1,default_text)) + end +end + +local function v(pos, default_text) + return d(pos, function(args, parent) return get_visual(args, parent, default_text) end) +end + +return { + +-- Formatting + +-- Text and pages + +s({trig = "url", name = "URLs"}, + { + t("\\url{"), v(1,"url"), t("}") + } +), + +s({trig = "ca", name = "Cancel stroke"}, + { + t("\\cancel{"), v(1,"text"), t("}") + } +), + +s({trig = "vrb", name = "Short verbatim"}, + { + t("\\verb="), v(1,"text"), t("=") + } +), + +s({trig = "ltr", name = "Enlarged letter"}, + { + c(1, + { + { + t("\\lettrine{"), i(1,"initial"), t("}{"), v(2,"text"), t("}") + }, + { + t("\\lettrine["), i(1,"val-list"), t("]{"), i(2,"initial"), t("}{"), v(3,"text"), t("}") + } + } + ) + } +), + +s({trig = "pht", name = "Phantom text"}, + { + c(1, + { + { + t("\\phantom{"), v(1,"text"), t("}") + }, + { + t("\\hphantom{"), v(1,"text"), t("}") + }, + { + t("\\vphantom{"), v(1,"text"), t("}") + } + } + ) + } +), + +s({trig = "foo", name = "Footnote"}, + { + t("\\footnote{"), v(1,"text"), t("}") + } +), + +s({trig = "mrg", name = "Marginal note"}, + { + t("\\marginpar{"), v(1,"text"), t("}") + } +), + +s({trig = "npg", name = "New page"}, + { + t("\\newpage") + } +), + +s({trig = "pp", name = "Paragraph break"}, + { + t({"",""}), t("\\bigskip"), t({"",""}), t({"",""}) + } +), + +s({trig = "fbo", name = "Frame box"}, + { + c(1, + { + { + t("\\fbox{"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("}") + }, + { + t("\\fbox{"), d(1,get_visual), t("}") + } + } + ) + } +), + +s({trig = "fco", name = "Color frame box"}, + { + c(1, + { + { + t("\\fcolorbox{"), i(1,"border-color"), t("}{"), i(2,"bg-color"), t("}{"), + t({"",""}), t(" "), d(3,get_visual), + t({"",""}), t("}") + }, + { + t("\\fcolorbox{"), i(1,"border-color"), t("}{"), i(2,"bg-color"), t("}{"), d(3,get_visual), t("}") + } + } + ) + } +), + +s({trig = "cen", name = "Centered environment"}, + { + t("\\begin{center}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{center}") + } +), + +s({trig = "min", name = "Minpage environment"}, + { + t("\\begin{minipage}{\\linewidth-3\\fboxsep-3\\fboxrule}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{minipage}") + } +), + +s({trig = "code", name = "Code chunk"}, + { + c(1, + { + { + t("{"), + t({"",""}), t("\\renewcommand\\ttdefault{cmtt}"), + t({"",""}), t(" \\begin{adjustwidth}{12mm+2mm}{2mm}"), + t({"",""}), t(" \\lstinputlisting{"), i(1), t("}"), + t({"",""}), t(" \\end{adjustwidth}"), + t({"",""}), + t({"",""}), t("}") + }, + { + t("{"), + t({"",""}), t("\\renewcommand\\ttdefault{cmtt}"), + t({"",""}), t("\\begin{adjustwidth}{12mm+2mm}{2mm}"), + t({"",""}), t("\\begin{lstlisting}"), + t({"",""}), i(1), + t({"",""}), t("\\end{lstlisting}"), + t({"",""}), t("\\end{adjustwidth}"), + t({"",""}), t("}") + } + } + ) + } +), + +-- Columns + +s({trig = "mul", name = "Multicolumns"}, + { + c(1, + { + { + t("\\begin{multicols}{"), i(1,"columns"), t("}"), + t({"",""}), i(2), + t({"",""}), t("\\end{multicols}") + }, + { + t("\\begin{multicols}{"), i(1,"columns"), t("}["), i(2,"preface"), t("]"), + t({"",""}), i(3), + t({"",""}), t("\\end{multicols}") + }, + { + t("\\begin{multicols}{"), i(1,"columns"), t("}["), i(2,"preface"), t("]["), i(3,"skip"), t("]"), + t({"",""}), i(4), + t({"",""}), t("\\end{multicols}") + } + } + ) + } +), + +-- List structures + +-- Ordered lists + +s({trig = "rff", name = "Item reference format"}, + { + t(",ref=\\the"), i(1,"<...>"), t(".\\textnormal{"), sn(2, + c(1, + { + { + i(1,"\\arabic*"), t("}") + }, + { + i(1,"\\Roman*"), t("}") + }, + { + i(1,"\\roman*"), t("}") + }, + { + i(1,"\\Alph*"), t("}") + }, + { + i(1,"\\alph*"), t("}") + } + } + ) + ) + } +), + +s({trig = "tz", name = "Unnumbered list"}, + { + t("\\begin{itemize}"), + t({"",""}), t("\\item "), i(1), + t({"",""}), t("\\end{itemize}") + } +), + +s({trig = "enn", name = "Enumerated list"}, + { + t("\\begin{enumerate}[label=\\textnormal{(\\arabic*)}]"), + t({"",""}), t("\\item "), i(1), + t({"",""}), t("\\end{enumerate}") + } +), + +s({trig = "enI", name = "Capital roman enumerated list"}, + { + t("\\begin{enumerate}[label=\\textnormal{(\\Roman*)}]"), + t({"",""}), t("\\item "), i(1), + t({"",""}), t("\\end{enumerate}") + } +), + +s({trig = "eni", name = "Lowercase roman enumerated list"}, + { + t("\\begin{enumerate}[label=\\textnormal{(\\roman*)}]"), + t({"",""}), t("\\item "), i(1), + t({"",""}), t("\\end{enumerate}") + } +), + +s({trig = "enA", name = "Capital latin enumerated list"}, + { + t("\\begin{enumerate}[label=\\textnormal{(\\Alph*)}]"), + t({"",""}), t("\\item "), i(1), + t({"",""}), t("\\end{enumerate}") + } +), + +s({trig = "ena", name = "Lowercase latin enumerated list"}, + { + t("\\begin{enumerate}[label=\\textnormal{(\\alph*)}]"), + t({"",""}), t("\\item "), i(1), + t({"",""}), t("\\end{enumerate}") + } +), + +s({trig = "tm", name = "New item"}, + { + t({"",""}), + t("\\item "), i(1) + } +), + +-- Theorem-like environments + +s({trig = "oo", name = "New theorem"}, + { + c(1, + { + { + t("\\begin{theorem}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{theorem}") + }, + { + t("\\begin{theorem}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{theorem}") + } + } + ) + } +), + +s({trig = "pf", name = "Proof environment"}, + { + c(1, + { + { + t("\\begin{proof}"), + t({"",""}), i(1), + t({"",""}), t("\\end{proof}") + }, + { + t("\\begin{proof}["), i(1,"name"), t("]"), + t({"",""}), i(2), + t({"",""}), t("\\end{proof}") + } + } + ) + } +), + +s({trig = "ps", name = "New proposition"}, + { + c(1, + { + { + t("\\begin{proposition}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{proposition}") + }, + { + t("\\begin{proposition}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{proposition}") + } + } + ) + } +), + +s({trig = "cc", name = "New corollary"}, + { + c(1, + { + { + t("\\begin{corollary}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{corollary}") + }, + { + t("\\begin{corollary}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{corollary}") + } + } + ) + } +), + +s({trig = "ll", name = "New lemma"}, + { + c(1, + { + { + t("\\begin{lemma}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{lemma}") + }, + { + t("\\begin{lemma}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{lemma}") + } + } + ) + } +), + +s({trig = "dd", name = "New definition"}, + { + c(1, + { + { + t("\\begin{definition}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{definition}") + }, + { + t("\\begin{definition}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{definition}") + } + } + ) + } +), + +s({trig = "re", name = "New remark"}, + { + c(1, + { + { + t("\\begin{remark}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{remark}") + }, + { + t("\\begin{remark}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{remark}") + } + } + ) + } +), + +s({trig = "ex", name = "New exercise"}, + { + c(1, + { + { + t("\\begin{exercise}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{exercise}") + }, + { + t("\\begin{exercise}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{exercise}") + } + } + ) + } +), + +s({trig = "ee", name = "New example"}, + { + c(1, + { + { + t("\\begin{example}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{example}") + }, + { + t("\\begin{example}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{example}") + } + } + ) + } +), + +s({trig = "pn", name = "New principle"}, + { + c(1, + { + { + t("\\begin{principle}"), + t({"",""}), d(1,get_visual), + t({"",""}), t("\\end{principle}") + }, + { + t("\\begin{principle}["), i(1,"name"), t("]"), + t({"",""}), d(2,get_visual), + t({"",""}), t("\\end{principle}") + } + } + ) + } +), + +} diff --git a/lua/custom/plugins/Luasnip/tex/greek_letters.lua b/lua/custom/plugins/Luasnip/tex/greek_letters.lua new file mode 100644 index 00000000000..c350b5a7403 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/greek_letters.lua @@ -0,0 +1,201 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local d = ls.dynamic_node +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local rep = require("luasnip.extras").rep + + + +return { + -- Examples of Greek letter snippets, autotriggered for efficiency + s({trig="@a", snippetType="autosnippet"}, + { + t("\\alpha"), + } + ), + s({trig="@b", snippetType="autosnippet"}, + { + t("\\beta"), + } + ), + s({trig="@g", snippetType="autosnippet"}, + { + t("\\gamma"), + } + ), + s({trig="@G", snippetType="autosnippet"}, + { + t("\\Gamma"), + } + ), + s({trig="@g", snippetType="autosnippet"}, + { + t("\\gamma"), + } + ), + s({trig="@d", snippetType="autosnippet"}, + { + t("\\delta"), + } + ), + s({trig="@D", snippetType="autosnippet"}, + { + t("\\Delta"), + } + ), + s({trig="@e", snippetType="autosnippet"}, + { + t("\\epsilon"), + } + ), + s({trig="@ve", snippetType="autosnippet"}, + { + t("\\varepsilon"), + } + ), + s({trig="@z", snippetType="autosnippet"}, + { + t("\\zeta"), + } + ), + s({trig="@h", snippetType="autosnippet"}, + { + t("\\eta"), + } + ), + s({trig="@th", snippetType="autosnippet"}, + { + t("\\theta"), + } + ), + s({trig="@Th", snippetType="autosnippet"}, + { + t("\\Theta"), + } + ), + s({trig="@vth", snippetType="autosnippet"}, + { + t("\\vartheta"), + } + ), + s({trig="@i", snippetType="autosnippet"}, + { + t("\\iota"), + } + ), + s({trig="@k", snippetType="autosnippet"}, + { + t("\\kappa"), + } + ), + s({trig="@g", snippetType="autosnippet"}, + { + t("\\gamma"), + } + ), + s({trig="@l", snippetType="autosnippet"}, + { + t("\\lambda"), + } + ), + s({trig="@L", snippetType="autosnippet"}, + { + t("\\Lambda"), + } + ), + s({trig="@m", snippetType="autosnippet"}, + { + t("\\mu"), + } + ), + s({trig="@n", snippetType="autosnippet"}, + { + t("\\nu"), + } + ), + s({trig="@x", snippetType="autosnippet"}, + { + t("\\xi"), + } + ), + s({trig="@X", snippetType="autosnippet"}, + { + t("\\Xi"), + } + ), + s({trig="@pi", snippetType="autosnippet"}, + { + t("\\pi"), + } + ), + s({trig="@Pi", snippetType="autosnippet"}, + { + t("\\Pi"), + } + ), + s({trig="@r", snippetType="autosnippet"}, + { + t("\\rho"), + } + ), + s({trig="@s", snippetType="autosnippet"}, + { + t("\\sigma"), + } + ), + s({trig="@S", snippetType="autosnippet"}, + { + t("\\Sigma"), + } + ), + s({trig="@t", snippetType="autosnippet"}, + { + t("\\tau"), + } + ), + s({trig="@ph", snippetType="autosnippet"}, + { + t("\\phi"), + } + ), + s({trig="@Ph", snippetType="autosnippet"}, + { + t("\\Phi"), + } + ), + s({trig="@vph", snippetType="autosnippet"}, + { + t("\\varphi"), + } + ), + s({trig="@ch", snippetType="autosnippet"}, + { + t("\\chi"), + } + ), + s({trig="@ps", snippetType="autosnippet"}, + { + t("\\psi"), + } + ), + s({trig="@Ps", snippetType="autosnippet"}, + { + t("\\Psi"), + } + ), + s({trig="@o", snippetType="autosnippet"}, + { + t("\\omega"), + } + ), + s({trig="@O", snippetType="autosnippet"}, + { + t("\\Omega"), + } + ) +} diff --git a/lua/custom/plugins/Luasnip/tex/greek_letters.lua.bak b/lua/custom/plugins/Luasnip/tex/greek_letters.lua.bak new file mode 100644 index 00000000000..9639aba32ee --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/greek_letters.lua.bak @@ -0,0 +1,83 @@ + + s({ trig = '@G', condition = in_mathzone }, t '\\Gamma', snippetType="autosnippet"), + + s({ trig = '@d', condition = in_mathzone }, t '\\delta', snippetType="autosnippet"), + + s({ trig = '@D', condition = in_mathzone }, t '\\Delta', snippetType="autosnippet"), + + s({ trig = '@e', condition = in_mathzone }, t '\\epsilon', snippetType="autosnippet"), + + s({ trig = '@ve', condition = in_mathzone }, t '\\varepsilon'), + + s({ trig = '@z', condition = in_mathzone }, t '\\zeta'), + + s({ trig = '@h', condition = in_mathzone }, t '\\eta'), + + s({ trig = '@th', condition = in_mathzone }, t '\\theta'), + + s({ trig = '@Th', condition = in_mathzone }, t '\\Theta'), + + s({ trig = '@vth', condition = in_mathzone }, t '\\vartheta'), + + s({ trig = '@i', condition = in_mathzone }, t '\\iota'), + + s({ trig = '@k', condition = in_mathzone }, t '\\kappa'), + + s({ trig = '@l', condition = in_mathzone }, t '\\lambda'), + + s({ trig = '@L', condition = in_mathzone }, t '\\Lambda'), + + s({ trig = '@m', condition = in_mathzone }, t '\\mu'), + + s({ trig = '@n', condition = in_mathzone }, t '\\nu'), + + s({ trig = '@x', condition = in_mathzone }, t '\\xi'), + + s({ trig = '@X', condition = in_mathzone }, t '\\Xi'), + + s({ trig = '@p', condition = in_mathzone }, t '\\pi'), + + s({ trig = '@P', condition = in_mathzone }, t '\\Pi'), + + s({ trig = '@r', condition = in_mathzone }, t '\\rho'), + + s({ trig = '@s', condition = in_mathzone }, t '\\sigma'), + + s({ trig = '@S', condition = in_mathzone }, t '\\Sigma'), + + s({ trig = '@t', condition = in_mathzone }, t '\\tau'), + + s({ trig = '@ph', condition = in_mathzone }, t '\\phi'), + + s({ trig = '@Ph', condition = in_mathzone }, t '\\Phi'), + + s({ trig = '@vph', condition = in_mathzone }, t '\\varphi'), + + s({ trig = '@ch', condition = in_mathzone }, t '\\chi'), + + s({ trig = '@ps', condition = in_mathzone }, t '\\psi'), + + s({ trig = '@Ps', condition = in_mathzone }, t '\\Psi'), + + s({ trig = '@o', condition = in_mathzone }, t '\\omega'), + + s({ trig = '@O', condition = in_mathzone }, t '\\Omega'), + + + +s({ trig = '@a', condition = in_mathzone , snippetType="autosnippet"}, + t('\\alpha'), + ), + s({ trig = '@b', condition = in_mathzone , snippetType="autosnippet"}, + t('\\beta'), + ), + s({ trig = '@g', condition = in_mathzone , snippetType="autosnippet"}, + t('\\gamma'), + ), + s({ trig = '@G', condition = in_mathzone, snippetType="autosnippet"}, + t('\\Gamma'), + ), + +local function in_mathzone() + return vim.fn['vimtex#syntax#in_mathzone']() == 1 +end diff --git a/lua/custom/plugins/Luasnip/tex/math.lua b/lua/custom/plugins/Luasnip/tex/math.lua new file mode 100644 index 00000000000..6299e525b30 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/math.lua @@ -0,0 +1,2938 @@ +local ls = require("luasnip") +local f = ls.function_node +local d = ls.dynamic_node +local r = ls.restore_node + +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") +local extras = require("luasnip.extras") +local l = extras.lambda +local rep = extras.rep +local p = extras.partial +local m = extras.match +local n = extras.nonempty +local dl = extras.dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local conds = require("luasnip.extras.expand_conditions") +local postfix = require("luasnip.extras.postfix").postfix +local types = require("luasnip.util.types") +local parse = require("luasnip.util.parser").parse_snippet +local ms = ls.multi_snippet +local k = require("luasnip.nodes.key_indexer").new_key +-- Auxiliary functions + +-- Math zone context +-- taken from https://ejmastnak.com/ + +local in_mathzone = function() + return vim.fn['vimtex#syntax#in_mathzone']() == 1 +end + +-- Visual placeholder +-- taken from https://ejmastnak.com/ + +local get_visual = function(args, parent, default_text) + if (#parent.snippet.env.LS_SELECT_RAW > 0) then + return sn(nil, i(1,parent.snippet.env.LS_SELECT_RAW)) + else -- If LS_SELECT_RAW is empty, return a blank insert node + return sn(nil, i(1,default_text)) + end +end + +local function v(pos, default_text) + return d(pos, function(args, parent) return get_visual(args, parent, default_text) end) +end + +-- Matrices and cases +-- taken from github.com/evesdropper + +local generate_matrix = function(args, snip) + local rows = tonumber(snip.captures[2]) + local cols = tonumber(snip.captures[3]) + local nodes = {} + local ins_indx = 1 + for j = 1, rows do + table.insert(nodes, r(ins_indx, tostring(j) .. "x1", i(1))) + ins_indx = ins_indx + 1 + for k = 2, cols do + table.insert(nodes, t(" & ")) + table.insert(nodes, r(ins_indx, tostring(j) .. "x" .. tostring(k), i(1))) + ins_indx = ins_indx + 1 + end + table.insert(nodes, t({ " \\\\", "" })) + end + nodes[#nodes] = t(" \\\\") + return sn(nil, nodes) +end + +local generate_hom_matrix = function(args, snip) + local rows = tonumber(snip.captures[2]) + local cols = tonumber(snip.captures[3]) + local nodes = {} + local ins_indx = 1 + for j = 1, rows do + if j == 1 then + table.insert(nodes, r(ins_indx,i(1))) + table.insert(nodes, t("_{11}")) + else + table.insert(nodes, rep(1)) + table.insert(nodes, t("_{" .. tostring(j) .. "1}")) + end + ins_indx = ins_indx + 1 + for k = 2, cols do + table.insert(nodes, t(" & ")) + table.insert(nodes, rep(1)) + table.insert(nodes, t("_{" .. tostring(j) .. tostring(k) .. "}")) + ins_indx = ins_indx + 1 + end + table.insert(nodes, t({ " \\\\", "" })) + end + nodes[#nodes] = t(" \\\\") + return sn(nil, nodes) +end + +local generate_cases = function(args, snip) + local rows = tonumber(snip.captures[1]) or 2 + local cols = 2 + local nodes = {} + local ins_indx = 1 + for j = 1, rows do + table.insert(nodes, r(ins_indx, tostring(j) .. "x1", sn(1,{t(" \\hfil "),i(1)}))) + ins_indx = ins_indx + 1 + for k = 2, cols do + table.insert(nodes, t(" & ")) + table.insert(nodes, r(ins_indx, tostring(j) .. "x" .. tostring(k), i(1))) + ins_indx = ins_indx + 1 + end + table.insert(nodes, t({ " \\\\", "" })) + end + table.remove(nodes, #nodes) + return sn(nil, nodes) +end + +-- Snippets + +return { + +-- Math + +-- Math alphabet identifiers + +s({trig = "mc", name = "Calligraphic math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathcal{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "mr", name = "Roman math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathrm{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "mb", name = "Bold math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathbf{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "ms", name = "Sans serif math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathsf{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "mt", name = "Typewriter math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathtt{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "mn", name = "Normal math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathnormal{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "mi", name = "Italic math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathit{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "mf", name = "Euler Fraktur math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathfrak{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "mk", name = "Blackboard bold math font", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathbb{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +-- Display environments and alignment structures + +s({trig = "mm", name = "Inline display", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("$"), d(1,get_visual), t("$") + } +), + +s({trig = "en", name = "Generic environment"}, + { + t("\\begin{"), i(1,"env"), t("}"), + t({"",""}), t(" "), d(2,get_visual), + t({"",""}), t("\\end{"), rep(1), t("}") + } +), + +s({trig = "nn", name = "New equation"}, + { + c(1, + { + { + t("\\begin{equation*}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{equation*}") + }, + { + t("\\begin{equation}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{equation}") + } + } + ) + } +), + +s({trig = "ml", name = "New multline"}, + { + c(1, + { + { + t("\\begin{multline}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{multline}") + }, + { + t("\\begin{multline*}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{multline*}") + } + } + ) + } +), + +s({trig = "gap", name = "Multline gap"}, + { + t("\\setlenght\\multlinegap{0pt}") + } +), + +s({trig = "sp", name = "New split"}, + { + t("\\begin{split}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{split}") + } +), + +s({trig = "gg", name = "New gather"}, + { + c(1, + { + { + t("\\begin{gather}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{gather}") + }, + { + t("\\begin{gather*}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{gather*}") + } + } + ) + } +), + +s({trig = "aa", name = "New align"}, + { + c(1, + { + { + t("\\begin{align*}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{align*}") + }, + { + t("\\begin{align}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{align}") + } + } + ) + } +), + +s({trig = "fal", name = "New falign"}, + { + c(1, + { + { + t("\\begin{falign}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{falign}") + }, + { + t("\\begin{falign*}"), + t({"",""}), t(" "), d(1,get_visual), + t({"",""}), t("\\end{falign*}") + } + } + ) + } +), + +s({trig = "(%d?)cs", name = "New cases environment", snippetType = "autosnippet", regTrig = true}, + { + t("\\begin{cases}"), + t({"",""}), d(1,generate_cases), + t({"",""}), t("\\end{cases}") + }, + {condition = in_mathzone} +), + +s({trig = "br", name = "Display line break", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\\\"), + t({"",""}), i(1) + }, + {condition = in_mathzone} +), + +s({trig = "itr", name = "Short text between lines", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\intertext{"), v(1,"text"), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "tx", name = "Text inside display", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\text{"), v(1,"text"), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "dib", name = "Display page break", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\displaybreak") + }, + {condition = in_mathzone} +), + +s({trig = "dis", name = "Displaystyle", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\displaystyle") + }, + {condition = in_mathzone} +), + +s({trig = "ty", name = "Textstyle", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\textstyle") + }, + {condition = in_mathzone} +), + +-- Equation numbering and tags + +s({trig = "ntg", name = "Suppress equation tag", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\notag") + }, + {condition = in_mathzone} +), + +s({trig = "tag", name = "Equation tag", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\tag{"), v(1,"tag"), t("}") + }, + { + t("\\tag*{"), v(1,"tag"), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "teq", name = "Last number equation"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\theequation") + } +), + +-- Matrix-like environments + +s({trig = "([bBpvV])(%d+)x(%d+)", name = "New matrix", snippetType = "autosnippet", regTrig = true}, + { + t("\\begin{"), f(function(_, snip) return snip.captures[1] .. "matrix" end), t("}"), + t({"",""}), d(1,generate_matrix), + t({"",""}), t("\\end{"), f(function(_, snip) return snip.captures[1] .. "matrix" end), t("}") + }, + {condition = in_mathzone} +), + + +s({trig = "([bBpvV])(%d+)h(%d+)", name = "New homogeneous matrix", snippetType = "autosnippet", regTrig = true}, + { + t("\\begin{"), f(function(_, snip) return snip.captures[1] .. "matrix" end), t("}"), + t({"",""}), d(1,generate_hom_matrix), + t({"",""}), t("\\end{"), f(function(_, snip) return snip.captures[1] .. "matrix" end), t("}") + }, + {condition = in_mathzone} +), + + +s({trig = "([bBpvV])gn", name = "New generic matrix", snippetType = "autosnippet", regTrig = true}, + { + t("\\begin{"), f(function(_, snip) return snip.captures[1] .. "matrix" end), t("}"), + t({"",""}), t(" "), i(1), t("_{11} & "), rep(1), t("_{12} & \\cdots & "), rep(1), t("_{1"), i(2), t("}"), t(" \\\\"), + t({"",""}), t(" "), rep(1), t("_{21} & "), rep(1), t("_{22} & \\cdots & "), rep(1), t("_{2"), rep(2), t("}"), t(" \\\\"), + t({"",""}), t(" "), t("\\vdots & \\vdots & \\ddots & \\vdots \\\\"), + t({"",""}), t(" "), rep(1), t("_{"), i(3), t("1} & "), rep(1), t("_{"), rep(3), t("2} & \\cdots & "), rep(1), t("_{"), rep(3), rep(2), t("} \\\\"), + t({"",""}), t("\\end{"), f(function(_, snip) return snip.captures[1] .. "matrix" end), t("}") + }, + {condition = in_mathzone} +), + +-- Subscripts and superscripts + +s({trig = ";", name = "Short subscript", snippetType = "autosnippet", wordTrig = false}, + { + t("_") + }, + {condition = in_mathzone} +), + +s({trig = ":", name = "Subscript", snippetType = "autosnippet", wordTrig = false}, + { + t("_{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "´", name = "Short superscript", snippetType = "autosnippet", wordTrig = false}, + { + t("^") + }, + {condition = in_mathzone} +), + +s({trig = "¨", name = "Superscript", snippetType = "autosnippet", wordTrig = false}, + { + t("^{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "¨", name = "Superscript", snippetType = "autosnippet", wordTrig = false}, + { + t("^{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "\'", name = "Subscript and superscript", snippetType = "autosnippet", wordTrig = false}, + { + t("_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "st", name = "Stacking", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\substack{"), d(1,get_visual), t(" \\\\ "), i(2), t("}") + }, + {condition = in_mathzone} +), + +-- Compound structures + +s({trig = "lxl", name = "Left relation arrow", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\xleftarrow{"), i(1,"top"), t("}") + }, + { + t("\\xleftarrow["), i(1,"bottom"), t("]{"), i(2,"top"), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "lxr", name = "Left relation arrow", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\xrightarrow{"), i(1,"top"), t("}") + }, + { + t("\\xrightarrow["), i(1,"bottom"), t("]{"), i(2,"top"), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "cf", name = "Continued fraction", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\cfrac{"), i(1,"num"), t("}{"), + t({"",""}), t(" "), i(2,"den"), + t({"",""}), t("}") + }, + { + t("\\cfrac["), i(1,"num-alignment"), t("]{"), i(2,"num"), t("}{"), + t({"",""}), t(" "), i(3,"den"), + t({"",""}), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "bx", name = "Boxed formula", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\boxed{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "ff", name = "Fraction", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\frac{"), i(1), t("}{"), i(2), t("}") + }, + { + t("\\dfrac{"), i(1), t("}{"), i(2), t("}") + }, + { + t("\\tfrac{"), i(1), t("}{"), i(2), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "bm", name = "Binomial coefficient", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\binom{"), i(1), t("}{"), i(2), t("}") + }, + { + t("\\dbinom{"), i(1), t("}{"), i(2), t("}") + }, + { + t("\\tbinom{"), i(1), t("}{"), i(2), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +-- Decorations + +s({trig = "abv", name = "Place material above", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\overset{"), i(1,"above"), t("}{"), v(2,"material"), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "bel", name = "Place material below", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\underset{"), i(1,"below"), t("}{"), v(2,"material"), t("}") + }, + {condition = in_mathzone} +), + +-- Limiting positions + +s({trig = "lim", name = "Above/below operator", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\limits") + }, + {condition = in_mathzone} +), + +s({trig = "nli", name = "Right of the operator", snippetType = "autosnippet"}, + { + t("\\nolimits") + }, + {condition = in_mathzone} +), + +-- Relations + +s({trig = "eq", name = "Congruence relation", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\equiv") + }, + {condition = in_mathzone} +), + +s({trig = "md", name = "Mod operator", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Mod{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +-- local macro +s({trig = "mod", name = "Modular relation", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"..."), t(" \\equiv "), i(2,"..."), t(" \\pmod{"), i(3,"..."), t("}") + }, + { + i(1,"..."), t(" \\not\\equiv "), i(2,"..."), t(" \\pmod{"), i(3,"..."), t("}") + }, + { + i(1,"..."), t(" \\equiv "), i(2,"..."), t(" \\mod{"), i(3,"..."), t("}") + }, + { + i(1,"..."), t(" \\not\\equiv "), i(2,"..."), t(" \\mod{"), i(3,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "sbg", name = "Left triangle", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\vartriangleleft") + }, + { + i(1,"\\ntriangleleft") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "sgc", name = "Right triangle", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\vartriangleright") + }, + { + i(1,"\\ntriangleright") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "ne", name = "Not equal", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ne") + }, + {condition = in_mathzone} +), + +s({trig = "nr", name = "Relation negation", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\not") + }, + {condition = in_mathzone} +), + +s({trig = "app", name = "Approx", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\approx") + }, + {condition = in_mathzone} +), + +s({trig = "cn", name = "Congruent", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\cong") + }, + { + i(1,"\\ncong") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "le", name = "Less or equal", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\le") + }, + {condition = in_mathzone} +), + +s({trig = "ge", name = "Greater or equal", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ge") + }, + {condition = in_mathzone} +), + +s({trig = "pc", name = "Precedes", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\prec") + }, + { + i(1,"\\nprec") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "sx", name = "Succedes", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\succ") + }, + { + i(1,"\\nsucc") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "re", name = "Relation", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\sim") + }, + { + i(1,"\\nsim") + } + } + ) + }, + {condition = in_mathzone} +), + +-- Operators + +s({trig = "opr", name = "Define new operator"}, + { + c(1, + { + { + t("\\DeclareMathOperator{"), i(1,"cmd"), t("}{"), i(2,"text"), t("}") + }, + { + t("\\DeclareMathOperator*{"), i(1,"cmd"), t("}{"), i(2,"text"), t("}") + } + } + ) + } +), + +s({trig = "ce", name = "Ceiling", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\lceil "), d(1,get_visual), t(" \\rceil") + }, + { + t("\\left\\lceil "), d(1,get_visual), t(" \\right\\rceil") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "fl", name = "Floor", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\lfloor "), d(1,get_visual), t(" \\rfloor") + }, + { + t("\\left\\lfloor "), d(1,get_visual), t(" \\right\\rfloor") + } + } + ) + + }, + {condition = in_mathzone} +), + +s({trig = "sq", name = "Square root", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\sqrt{"), d(1,get_visual), t("}") + }, + { + t("\\sqrt["), i(1,"n-th"), t("]{"), d(2,get_visual), t("}") + }, + { + t("\\sqrt[\\leftroot{"), i(1,"x"), t("}\\uproot{"), i(2,"y"), t("} "), i(3,"n-th"), t("]{"), d(4,get_visual), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "imp", name = "Imaginary part", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Im") + }, + {condition = in_mathzone} +), + +s({trig = "rpa", name = "Real part", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Re") + }, + {condition = in_mathzone} +), + +s({trig = "opm", name = "Mod operator", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + i(1,"..."), t(" \\bmod "), i(2,"...") + }, + {condition = in_mathzone} +), + +s({trig = "mp", name = "Minus plus", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mp") + }, + {condition = in_mathzone} +), + +s({trig = "pm", name = "Plus minus", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\pm") + }, + {condition = in_mathzone} +), + +s({trig = "tm", name = "Times", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\times") + }, + {condition = in_mathzone} +), + +s({trig = "cd", name = "Centered dot", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\cdot") + }, + {condition = in_mathzone} +), + +s({trig = "cir", name = "Circle", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\circ") + }, + {condition = in_mathzone} +), + +s({trig = "opl", name = "Oplus", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\oplus") + }, + {condition = in_mathzone} +), + +s({trig = "omt", name = "Otimes", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\otimes") + }, + {condition = in_mathzone} +), + +s({trig = "dv", name = "Middle bar", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mid") + }, + {condition = in_mathzone} +), + +s({trig = "ndv", name = "Middle bar", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\centernot\\mid") + }, + {condition = in_mathzone} +), + +s({trig = "xm", name = "Maximum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\max") + }, + { + t("\\max_{"), i(1,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "mu", name = "Minimum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\min") + }, + { + t("\\min_{"), i(1,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "nf", name = "Infimum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\inf") + }, + { + t("\\inf_{"), i(1,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "sr", name = "Supremum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\sup") + }, + { + t("\\sup_{"), i(1,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "arg", name = "Argument", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arg") + }, + {condition = in_mathzone} +), + +s({trig = "deg", name = "Degree", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\deg") + }, + {condition = in_mathzone} +), + +s({trig = "det", name = "Determinant", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\det") + }, + {condition = in_mathzone} +), + +s({trig = "dim", name = "Dimension", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\dim") + }, + {condition = in_mathzone} +), + +s({trig = "gc", name = "Greatest common divisor", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\gcd") + }, + {condition = in_mathzone} +), + +s({trig = "hm", name = "Hom", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\hom") + }, + {condition = in_mathzone} +), + +s({trig = "kr", name = "Kernel", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ker") + }, + {condition = in_mathzone} +), + +s({trig = "lap", name = "Laplacian", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\nabla^2 ") + }, + {condition = in_mathzone} +), + +s({trig = "div", name = "Divergence", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\nabla\\cdot\\vv{"), i(1), t("}") + }, + { + t("\\nabla\\cdot\\vec{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "cur", name = "Curl", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\nabla\\times\\vv{"), i(1), t("}") + }, + { + t("\\nabla\\times\\vec{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "ba", name = "Bra", snippetType = "autosnippet"}, + { + c(1, + { + { + t("\\bra{"), i(1), t("}") + }, + { + t("\\bra*{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "kt", name = "Ket", snippetType = "autosnippet"}, + { + c(1, + { + { + t("\\ket{"), i(1), t("}") + }, + { + t("\\ket*{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "bk", name = "Braket", snippetType = "autosnippet"}, + { + c(1, + { + { + t("\\braket{"), i(1), t("}{"), i(2), t("}") + }, + { + t("\\braket*{"), i(1), t("}{"), i(2), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +-- Operators with limits + +s({trig = "lm", name = "Limit", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\lim_{"), i(1), t(" \\to "), i(2), t("}") + }, + { + i(1,"\\lim") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "lif", name = "liminf", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\liminf_{"), i(1), t(" \\to "), i(2), t("}") + }, + { + i(1,"\\liminf") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "lsu", name = "limsup", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\limsup_{"), i(1), t(" \\to "), i(2), t("}") + }, + { + i(1,"\\limsup") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "lvf", name = "varliminf", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\varliminf_{"), i(1), t(" \\to "), i(2), t("}") + }, + { + i(1,"\\varliminf") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "lvu", name = "varlimsup", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\varlimsup_{"), i(1), t(" \\to "), i(2), t("}") + }, + { + i(1,"\\varlimsup") + } + } + ) + }, + {condition = in_mathzone} +), + +-- Functions + +s({trig = "fn", name = "Function domain and codomain", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + i(1,"fun"), t(" : "), i(2,"dom"), t(" \\longrightarrow "), i(3,"cod") + }, + {condition = in_mathzone} +), + +s({trig = "fd", name = "Function definition"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\begin{align*}"), + t({"",""}), t(" "), i(1,"fun"), t(" : "), i(2,"dom"), t(" & \\longrightarrow "), i(3,"cod"), t(" \\\\"), + t({"",""}), t(" "), i(4,"point"), t(" & \\longmapsto "), i(5,"img"), + t({"",""}), t("\\end{align*}") + } +), + +s({trig = "sni", name = "sin", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\sin") + }, + {condition = in_mathzone} +), + +s({trig = "co", name = "cos", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\cos") + }, + {condition = in_mathzone} +), + +s({trig = "tan", name = "tan", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\tan") + }, + {condition = in_mathzone} +), + +s({trig = "ot", name = "cot", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\cot") + }, + {condition = in_mathzone} +), + +s({trig = "sc", name = "sec", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\sec") + }, + {condition = in_mathzone} +), + +s({trig = "cc", name = "csc", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\csc") + }, + {condition = in_mathzone} +), + +s({trig = "asin", name = "arcsin", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arcsin") + }, + {condition = in_mathzone} +), + +s({trig = "acos", name = "arccos", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arccos") + }, + {condition = in_mathzone} +), + +s({trig = "atan", name = "arctan", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arctan") + }, + {condition = in_mathzone} +), + +s({trig = "acot", name = "arccot", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arccot") + }, + {condition = in_mathzone} +), + +s({trig = "asec", name = "arcsec", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arcsec") + }, + {condition = in_mathzone} +), + +s({trig = "acc", name = "arccsc", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arccsc") + }, + {condition = in_mathzone} +), + +s({trig = "sinh", name = "sinh", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\sinh") + }, + {condition = in_mathzone} +), + +s({trig = "cosh", name = "cosh", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\cosh") + }, + {condition = in_mathzone} +), + +s({trig = "tanh", name = "tanh", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\tanh") + }, + {condition = in_mathzone} +), + +s({trig = "coth", name = "coth", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\coth") + }, + {condition = in_mathzone} +), + +s({trig = "sh", name = "sech", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\sech") + }, + {condition = in_mathzone} +), + +s({trig = "hcc", name = "csch", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\csch") + }, + {condition = in_mathzone} +), + +s({trig = "ahsin", name = "arcsinh", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arcsinh") + }, + {condition = in_mathzone} +), + +s({trig = "ahcos", name = "arccosh", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arccosh") + }, + {condition = in_mathzone} +), + +s({trig = "ahtan", name = "arctanh", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arctanh") + }, + {condition = in_mathzone} +), + +s({trig = "ahcot", name = "arccoth", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arccoth") + }, + {condition = in_mathzone} +), + +s({trig = "ahsec", name = "arcsech", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arcsech") + }, + {condition = in_mathzone} +), + +s({trig = "ahcc", name = "arccsch", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\arccsch") + }, + {condition = in_mathzone} +), + +s({trig = "xp", name = "exp", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\exp") + }, + {condition = in_mathzone} +), + +s({trig = "ln", name = "ln", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ln") + }, + {condition = in_mathzone} +), + +s({trig = "lg", name = "log", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\log") + }, + {condition = in_mathzone} +), + +-- Ellipsis + +s({trig = "dd", name = "Lower dots", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ldots") + }, + {condition = in_mathzone} +), + +s({trig = "cr", name = "Centered dots", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\cdots") + }, + {condition = in_mathzone} +), + +s({trig = "vd", name = "Vertical dots", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\vdots") + }, + {condition = in_mathzone} +), + +s({trig = "gd", name = "Diagonal dots", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ddots") + }, + {condition = in_mathzone} +), + +s({trig = "cln", name = "Colon", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t(":") + }, + {condition = in_mathzone} +), + +s({trig = "sln", name = "Semicolon", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t(";") + }, + {condition = in_mathzone} +), + +-- Horizontal extensions + +s({trig = "ovr", name = "Overline", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\overline{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "und", name = "Underline", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\underline{"), d(1,get_visual), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "ovb", name = "Overbrace", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\overbrace{"), d(1,get_visual), t("}^{"), i(2,"top"), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "unb", name = "Underbrace", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\underbrace{"), d(1,get_visual), t("}_{"), i(2,"bottom"), t("}") + }, + {condition = in_mathzone} +), + +-- Delimiters + +s({trig = "dp", name = "Parenthesis", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\left( "), d(1,get_visual), t(" \\right)") + }, + {condition = in_mathzone} +), + +s({trig = "ds", name = "Brackets", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\left[ "), d(1,get_visual), t(" \\right]") + }, + {condition = in_mathzone} +), + +s({trig = "bb", name = "Braces", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\{ "), d(1,get_visual), t(" \\}") + }, + {condition = in_mathzone} +), + +s({trig = "db", name = "Extensible braces", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\left\\{ "), d(1,get_visual), t(" \\right\\}") + }, + {condition = in_mathzone} +), + +s({trig = "dk", name = "Angle brackets", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\left\\langle "), d(1,get_visual), t(" \\right\\rangle") + }, + { + t("\\langle "), d(1,get_visual), t(" \\rangle") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "da", name = "Pipes", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\left\\lvert "), d(1,get_visual), t(" \\right\\rvert") + }, + { + t("\\lvert "), d(1,get_visual), t(" \\rvert") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "dn", name = "Double pipes", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\left\\lVert "), d(1,get_visual), t(" \\right\\rVert") + }, + { + t("\\lVert "), d(1,get_visual), t(" \\rVert") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "big", name = "Big-d delimiters", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\big") + }, + { + i(1,"\\Big") + }, + { + i(1,"\\bigg") + }, + { + i(1,"\\Bigg") + } + } + ) + }, + {condition = in_mathzone} +), + +-- Spacing commands + +s({trig = "thp", name = "Thin space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\,") + }, + {condition = in_mathzone} +), + +s({trig = "mdn", name = "Medium space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\:") + }, + {condition = in_mathzone} +), + +s({trig = "tkp", name = "Thick space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\;") + }, + {condition = in_mathzone} +), + +s({trig = "enp", name = "Enskip", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\enskip") + }, + {condition = in_mathzone} +), + +s({trig = "qu", name = "Quad", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\quad") + }, + {condition = in_mathzone} +), + +s({trig = "qq", name = "Double quad", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\qquad") + }, + {condition = in_mathzone} +), + +s({trig = "thn", name = "Negative thin space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\!") + }, + {condition = in_mathzone} +), + +s({trig = "men", name = "Negative medium space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\negmedspace") + }, + {condition = in_mathzone} +), + +s({trig = "tkn", name = "Negative thick space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\negthickspace") + }, + {condition = in_mathzone} +), + +s({trig = "hs", name = "Horizontal space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\hspace{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "vs", name = "Vertical space", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\vspace{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +-- Greek alphabet + +s({trig = "[.]a", name = "Alpha", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\alpha") + }, + {condition = in_mathzone} +), + +s({trig = "[.]b", name = "Beta", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\beta") + }, + {condition = in_mathzone} +), + +s({trig = "[.]c", name = "Chi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\chi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]D", name = "Uppercase delta", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Delta") + }, + {condition = in_mathzone} +), + +s({trig = "[.]d", name = "Lowercase delta", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\delta") + }, + {condition = in_mathzone} +), + +s({trig = "[.]e", name = "Epsilon", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\varepsilon") + }, + {condition = in_mathzone} +), + +s({trig = "[.]G", name = "Uppercase gamma", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Gamma") + }, + {condition = in_mathzone} +), + +s({trig = "[.]g", name = "Lowercase gamma", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\gamma") + }, + {condition = in_mathzone} +), + +s({trig = "[.]h", name = "Eta", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\eta") + }, + {condition = in_mathzone} +), + +s({trig = "[.]i", name = "Iota", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\iota") + }, + {condition = in_mathzone} +), + +s({trig = "[.]k", name = "Kappa", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\kappa") + }, + {condition = in_mathzone} +), + +s({trig = "[.]L", name = "Uppercase lambda", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Lambda") + }, + {condition = in_mathzone} +), + +s({trig = "[.]l", name = "Lowercase lambda", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\lambda") + }, + {condition = in_mathzone} +), + +s({trig = "[.]m", name = "Mu", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mu") + }, + {condition = in_mathzone} +), + +s({trig = "[.]n", name = "Nu", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\nu") + }, + {condition = in_mathzone} +), + +s({trig = "[.]O", name = "Uppercase omega", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Omega") + }, + {condition = in_mathzone} +), + +s({trig = "[.]o", name = "Lowercase omega", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\omega") + }, + {condition = in_mathzone} +), + +s({trig = "[.]Ph", name = "Uppercase phi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Phi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]ph", name = "Lowecase phi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\phi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]Pi", name = "Uppercase pi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Pi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]pi", name = "Lowercase pi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\pi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]Ps", name = "Uppercase psi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Psi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]ps", name = "Lowercase psi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\psi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]r", name = "Rho", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\rho") + }, + {condition = in_mathzone} +), + +s({trig = "[.]S", name = "Uppercase sigma", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Sigma") + }, + {condition = in_mathzone} +), + +s({trig = "[.]s", name = "Lowercase sigma", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\sigma") + }, + {condition = in_mathzone} +), + +s({trig = "[.]ta", name = "Tau", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\tau") + }, + {condition = in_mathzone} +), + +s({trig = "[.]Th", name = "Uppercase theta", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Theta") + }, + {condition = in_mathzone} +), + +s({trig = "[.]th", name = "Lowercase theta", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\theta") + }, + {condition = in_mathzone} +), + +s({trig = "[.]U", name = "Uppercase upsilon", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Upsilon") + }, + {condition = in_mathzone} +), + +s({trig = "[.]u", name = "Lowecase upsilon", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\upsilon") + }, + {condition = in_mathzone} +), + +s({trig = "[.]X", name = "Uppercase xi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\Xi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]x", name = "Lowercase xi", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\xi") + }, + {condition = in_mathzone} +), + +s({trig = "[.]z", name = "Zeta", snippetType = "autosnippet", regTrig = true}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\zeta") + }, + {condition = in_mathzone} +), + +-- Letter-shaped symbols + +s({trig = "ha", name = "Aleph", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\aleph") + }, + {condition = in_mathzone} +), + +s({trig = "hb", name = "Beth", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\beth") + }, + {condition = in_mathzone} +), + +s({trig = "hd", name = "Daleth", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\daleth") + }, + {condition = in_mathzone} +), + +s({trig = "hg", name = "Gimel", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\gimel") + }, + {condition = in_mathzone} +), + +s({trig = "ll", name = "ell", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ell") + }, + {condition = in_mathzone} +), + +s({trig = "cm", name = "Set complement", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\complement") + }, + {condition = in_mathzone} +), + +s({trig = "hr", name = "hbar", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\hbar") + }, + {condition = in_mathzone} +), + +s({trig = "hl", name = "hslash", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\hslash") + }, + {condition = in_mathzone} +), + +s({trig = "pt", name = "Partial", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\partial") + }, + {condition = in_mathzone} +), + +-- Miscellaneous symbols + +s({trig = "dl", name = "Dollar sign", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\$") + }, + {condition = in_mathzone} +), + +s({trig = "hh", name = "Numeral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\#") + }, + {condition = in_mathzone} +), + +s({trig = "fy", name = "Infinity", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\infty") + }, + {condition = in_mathzone} +), + +s({trig = "pr", name = "Prime", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\prime") + }, + {condition = in_mathzone} +), + +s({trig = "per", name = "Percentaje", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\%") + }, + {condition = in_mathzone} +), + +s({trig = "amp", name = "Ampersand", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\&") + }, + {condition = in_mathzone} +), + +s({trig = "ang", name = "Angle", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\angle") + }, + {condition = in_mathzone} +), + +s({trig = "nb", name = "Nabla", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\nabla") + }, + {condition = in_mathzone} +), + +s({trig = "ch", name = "Section symbol"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\S") + } +), + +-- Accents + +s({trig = "dr", name = "Dot accent", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\dot{"), v(1,"..."), t("}") + }, + { + t("\\ddot{"), v(1,"..."), t("}") + }, + { + t("\\dddot{"), v(1,"..."), t("}") + }, + { + t("\\ddddot{"), v(1,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "ht", name = "Hat", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\hat{"), v(1,"..."), t("}") + }, + { + t("\\widehat{"), v(1,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "rng", name = "Math ring", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\mathring{"), v(1,"..."), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "til", name = "Tilde", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\tilde{"), i(1), t("}") + }, + { + t("\\widetilde{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "vv", name = "Vector", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\vv{"), v(1,"..."), t("}") + }, + { + t("\\vec{"), v(1,"..."), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +-- Logic + +s({trig = "fa", name = "For all", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\forall") + }, + {condition = in_mathzone} +), + +s({trig = "ex", name = "Exists", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\exists") + }, + {condition = in_mathzone} +), + +s({trig = "nx", name = "Not exist", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\nexists") + }, + {condition = in_mathzone} +), + +s({trig = "lt", name = "Logic negation", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\lnot") + }, + {condition = in_mathzone} +), + +s({trig = "lan", name = "Logic and", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\land") + }, + {condition = in_mathzone} +), + +s({trig = "lor", name = "Logic or", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\lor") + }, + {condition = in_mathzone} +), + +s({trig = "ip", name = "Implies", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\implies") + }, + {condition = in_mathzone} +), + +s({trig = "ib", name = "Implied by", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\impliedby") + }, + {condition = in_mathzone} +), + +s({trig = "iff", name = "If and only if", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\iff") + }, + {condition = in_mathzone} +), + +-- Sets and inclusion + +s({trig = "in", name = "Belongs to", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\in") + }, + {condition = in_mathzone} +), + +s({trig = "ntn", name = "Not in", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\notin") + }, + {condition = in_mathzone} +), + +s({trig = "na", name = "Owns", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\ni") + }, + {condition = in_mathzone} +), + +s({trig = "vc", name = "Empty set", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\emptyset") + }, + { + i(1,"\\varnothing") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "nun", name = "Union", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\cup") + }, + {condition = in_mathzone} +), + +s({trig = "bun", name = "Big union", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigcup") + }, + {condition = in_mathzone} +), + +s({trig = "sun", name = "Big subscript union", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigcup_{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "dun", name = "Big definite union", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigcup_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "nit", name = "Intersection", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\cap") + }, + {condition = in_mathzone} +), + +s({trig = "bit", name = "Big intersection", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigcap") + }, + {condition = in_mathzone} +), + +s({trig = "sit", name = "Big subscript intersection", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigcap_{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "dit", name = "Big definite intersection", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigcap_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "sf", name = "Set difference", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\setminus") + }, + {condition = in_mathzone} +), + +s({trig = "sbs", name = "Subset", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\subset") + }, + {condition = in_mathzone} +), + +s({trig = "sbq", name = "Subset or equals", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\subseteq") + }, + { + i(1,"\\nsubseteq") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "sus", name = "Contains", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\supset") + }, + {condition = in_mathzone} +), + +s({trig = "suq", name = "Contains or equals", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\supseteq") + }, + { + i(1,"\\nsupseteq") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "setd", name = "Dots set", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\{ "), i(1), t(" \\std "), i(2), t(" \\}") + }, + {condition = in_mathzone} +), + +s({trig = "setb", name = "Bar set", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\{ "), i(1), t(" \\mid "), i(2), t(" \\}") + }, + {condition = in_mathzone} +), + +-- Arrows + +s({trig = "rar", name = "Long right arrow", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\longrightarrow") + }, + {condition = in_mathzone} +), + +s({trig = "lar", name = "Long left arrow", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\longleftarrow") + }, + {condition = in_mathzone} +), + +s({trig = "to", name = "Long maps to", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\longmapsto") + }, + {condition = in_mathzone} +), + +-- Sums + +s({trig = "sm", name = "Subscript sum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\sum_{"), i(1), t("}") + }, + { + i(1,"\\sum") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "ss", name = "Definite sum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\sum_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "sos", name = "Subscript o-sum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigoplus_{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "nos", name = "Definite o-sum", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigoplus_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +-- Products + +s({trig = "sp", name = "Subscript product", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\prod_{"), i(1), t("}") + }, + { + i(1,"\\prod") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "pp", name = "Definite product", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\prod_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "sop", name = "Subscript o-product", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigotimes_{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "nop", name = "Definite o-product", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\bigotimes_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +-- Derivatives + +s({trig = "df", name = "Differential", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\dx{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "der", name = "Derivative", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\der{"), i(1,"func"), t("}{"), i(2,"var"), t("}") + }, + { + t("\\Der{"), i(1,"func"), t("}{"), i(2,"var"), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "ndr", name = "n-th derivative", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\ndr{"), i(1,"n"), t("}{"), i(2,"func"), t("}{"), i(3,"var"), t("}") + }, + { + t("\\Ndr{"), i(1,"n"), t("}{"), i(2,"func"), t("}{"), i(3,"var"), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "pdr", name = "Partial derivative", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\pdr{"), i(1,"func"), t("}{"), i(2,"var"), t("}") + }, + { + t("\\Pdr{"), i(1,"func"), t("}{"), i(2,"var"), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "npd", name = "n-th partial derivative", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\npd{"), i(1,"n"), t("}{"), i(2,"func"), t("}{"), i(3,"var"), t("}") + }, + { + t("\\Npd{"), i(1,"n"), t("}{"), i(2,"func"), t("}{"), i(3,"var"), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "evl", name = "Derivative evaluation", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\evl{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +-- Integrals + +s({trig = "itn", name = "Integral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\int") + }, + { + i(1,"\\oint") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "its", name = "Subscript integral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\int_{"), i(1), t("}") + }, + { + t("\\oint_{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "itd", name = "Definite integral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\int_{"), i(1), t("}^{"), i(2), t("}") + }, + {condition = in_mathzone} +), + +s({trig = "itbn", name = "Double integral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\iint") + }, + { + i(1,"\\oiint") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "itbs", name = "Double integral subscript", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\iint_{"), i(1), t("}") + }, + { + t("\\oiint_{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "ittn", name = "Triple integral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\iiint") + }, + { + i(1,"\\oiiint") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "itts", name = "Triple integral subscript", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\iiint_{"), i(1), t("}") + }, + { + t("\\oiiint_{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "itqn", name = "Quadruple integral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + i(1,"\\iiiint") + }, + { + i(1,"\\oiiint") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "itqs", name = "Quadruple integral subscript", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + c(1, + { + { + t("\\iiint_{"), i(1), t("}") + }, + { + t("\\oiiint_{"), i(1), t("}") + } + } + ) + }, + {condition = in_mathzone} +), + +s({trig = "itmn", name = "Multiple integral", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\idotsint") + }, + {condition = in_mathzone} +), + +s({trig = "itms", name = "Multiple integral subscript", snippetType = "autosnippet"}, + { + f(function(_,snip) return snip.captures[1] end), + t("\\idotsint_{"), i(1), t("}") + }, + {condition = in_mathzone} +), + +} diff --git a/lua/custom/plugins/Luasnip/tex/math.lua.bak b/lua/custom/plugins/Luasnip/tex/math.lua.bak new file mode 100644 index 00000000000..8bda401470b --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/math.lua.bak @@ -0,0 +1,2064 @@ +local ls = require 'luasnip' +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local d = ls.dynamic_node +local c = ls.choice_node +local fmt = require('luasnip.extras.fmt').fmt +local fmta = require('luasnip.extras.fmt').fmta +local rep = require('luasnip.extras').rep +local line_begin = require('luasnip.extras.expand_conditions').line_begin +local tex = require 'luasnip.extras.tex' + +-- Helper functions +local function in_mathzone() + return vim.fn['vimtex#syntax#in_mathzone']() == 1 +end + +local function in_comment() + return vim.fn['vimtex#syntax#in_comment']() == 1 +end + +local function in_env(name) + local is_inside = vim.fn['vimtex#env#is_inside'](name) + return (is_inside[1] ~= '0' and is_inside[2] ~= '0') +end + +-- Auto-expanding snippets when typing +local function auto_snippets(context, snip) + if not context then + return false + end + local line_to_cursor = vim.api.nvim_get_current_line():sub(1, vim.api.nvim_win_get_cursor(0)[2]) + return line_to_cursor:match(snip.trigger .. '$') +end + +local snippets = { + -- Document Structure Snippets + s( + { trig = 'template', dscr = 'Basic template', snippetType = 'autosnippet' }, + fmta( + [[ + \documentclass[a4paper]{article} + + \usepackage[utf8]{inputenc} + \usepackage[T1]{fontenc} + \usepackage{textcomp} + \usepackage[dutch]{babel} + \usepackage{amsmath, amssymb} + + % figure support + \usepackage{import} + \usepackage{xifthen} + \pdfminorversion=7 + \usepackage{pdfpages} + \usepackage{transparent} + \newcommand{\incfig}[1]{% + \def\svgwidth{\columnwidth} + \import{./figures/}{#1.pdf_tex} + } + + \pdfsuppresswarningpagegroup=1 + + \begin{document} + <> + \end{document} + ]], + { i(0) } + ) + ), + + -- Environment snippets + s( + { trig = 'beg', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{<>} + <> + \end{<>} + ]], + { + i(1), + i(0), + rep(1), + } + ) + ), + + s({ trig = '...', snippetType = 'autosnippet' }, t '\\ldots'), + + s( + { trig = 'table', dscr = 'Table environment' }, + fmta( + [[ + \begin{table}[<>] + \centering + \caption{<>} + \label{tab:<>} + \begin{tabular}{<>} + <> + \end{tabular} + \end{table} + ]], + { + i(1, 'htpb'), + i(2, 'caption'), + i(3, 'label'), + i(4, 'c'), + i(0), + } + ) + ), + + s( + { trig = 'fig', dscr = 'Figure environment' }, + fmta( + [[ + \begin{figure}[<>] + \centering + \includegraphics[width=0.8\textwidth]{<>} + \caption{<>} + \label{fig:<>} + \end{figure} + ]], + { + i(1, 'htpb'), + i(2), + i(3), + i(4), + } + ) + ), + + s( + { trig = 'enum', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{enumerate} + \item <> + \end{enumerate} + ]], + { i(0) } + ) + ), + + s( + { trig = 'item', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{itemize} + \item <> + \end{itemize} + ]], + { i(0) } + ) + ), + + s( + { trig = 'desc', dscr = 'Description environment' }, + fmta( + [[ + \begin{description} + \item[<>] <> + \end{description} + ]], + { + i(1), + i(0), + } + ) + ), + + s( + { trig = 'pac', dscr = 'Package inclusion' }, + fmta('\\usepackage[<>]{<>}<>', { + i(1, 'options'), + i(2, 'package'), + i(0), + }) + ), +} + +-- Mathematical Snippets +local math_snippets = { + -- Logic operators + s({ trig = '=>', snippetType = 'autosnippet' }, t '\\implies'), + + s({ trig = '=<', snippetType = 'autosnippet' }, t '\\impliedby'), + + s({ trig = 'iff', snippetType = 'autosnippet', condition = in_mathzone }, t '\\iff'), + + -- Math mode snippets + s( + { trig = 'mk', snippetType = 'autosnippet' }, + fmt('${}${}', { + i(1), + i(2), + }) + ), + + s( + { trig = 'dm', snippetType = 'autosnippet' }, + fmta( + [[ + \[ + <> + .\] <> + ]], + { + i(1), + i(0), + } + ) + ), + + s( + { trig = 'ali', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{align*} + <> + .\end{align*} + ]], + { i(1) } + ) + ), + + -- Fractions + s( + { trig = '//', snippetType = 'autosnippet', condition = in_mathzone }, + fmta('\\frac{<>}{<>}<>', { + i(1), + i(2), + i(0), + }) + ), + + s( + { trig = '/', snippetType = 'autosnippet' }, + fmta('\\frac{<>}{<>}<>', { + f(function(_, snip) + return snip.env.TM_SELECTED_TEXT[1] or {} + end), + i(1), + i(0), + }) + ), + + -- Auto subscripts + s( + { trig = '([A-Za-z])(%d)', regTrig = true, snippetType = 'autosnippet', condition = in_mathzone }, + f(function(_, snip) + return string.format('%s_%s', snip.captures[1], snip.captures[2]) + end) + ), + + s( + { trig = '([A-Za-z])_(%d%d)', regTrig = true, snippetType = 'autosnippet', condition = in_mathzone }, + f(function(_, snip) + return string.format('%s_{%s}', snip.captures[1], snip.captures[2]) + end) + ), + + -- Common math functions + s( + { trig = 'sum', condition = in_mathzone }, + fmta('\\sum_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(3), + }) + ), + + s( + { trig = 'taylor', condition = in_mathzone }, + fmta('\\sum_{<>}^{<>} <> (x-a)^<>', { + i(1, 'k=0'), + i(2, '\\infty'), + i(3, 'c_k'), + rep(1), + }) + ), + + s( + { trig = 'lim', condition = in_mathzone }, + fmta('\\lim_{<> \\to <>}', { + i(1, 'n'), + i(2, '\\infty'), + }) + ), + + s( + { trig = 'limsup', condition = in_mathzone }, + fmta('\\limsup_{<> \\to <>}', { + i(1, 'n'), + i(2, '\\infty'), + }) + ), + + s( + { trig = 'prod', condition = in_mathzone }, + fmta('\\prod_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'part', condition = in_mathzone }, + fmta('\\frac{\\partial <>}{\\partial <>}', { + i(1, 'V'), + i(2, 'x'), + }) + ), + + -- Square root and powers + s({ trig = 'sq', condition = in_mathzone }, fmta('\\sqrt{<>}', { i(1) })), + + s({ trig = 'sr', condition = in_mathzone }, t '^2'), + + s({ trig = 'cb', condition = in_mathzone }, t '^3'), + + s({ trig = 'td', condition = in_mathzone }, fmt('^{{}}', { i(1) })), + + s({ trig = 'rd', condition = in_mathzone }, fmt('^{({})}', { i(1) })), + + -- Subscripts and special notations + s({ trig = '__', condition = in_mathzone }, fmt('_{{}}', { i(1) })), + + s({ trig = 'ooo', condition = in_mathzone }, t '\\infty'), + + s( + { trig = 'rij', condition = in_mathzone }, + fmta('(<>_{<>})_{<>\\in<>}', { + i(1, 'x'), + i(2, 'n'), + rep(2), + i(3, '\\N'), + }) + ), + + -- Comparison operators + s({ trig = '<=', snippetType = 'autosnippet' }, t '\\le '), + + s({ trig = '>=', snippetType = 'autosnippet' }, t '\\ge '), + + -- Quantifiers + s({ trig = 'EE', condition = in_mathzone }, t '\\exists '), + + s({ trig = 'AA', condition = in_mathzone }, t '\\forall '), +} + +-- Matrix and Vector Snippets + +-- Matrix and Vector Snippets +local matrix_vector_snippets = { + -- Parenthesis Matrix + s( + { trig = 'pmat', condition = in_mathzone }, + fmta( + [[ + \begin{pmatrix} + <> + \end{pmatrix} <> + ]], + { + i(1), + i(0), + } + ) + ), + + -- Bracket Matrix + s( + { trig = 'bmat', condition = in_mathzone }, + fmta( + [[ + \begin{bmatrix} + <> + \end{bmatrix} <> + ]], + { + i(1), + i(0), + } + ) + ), + + -- Column Vector + s( + { trig = 'cvec', condition = in_mathzone }, + fmta( + [[ + \begin{pmatrix} + <>_<>\\ + \vdots\\ + <>_<> + \end{pmatrix} + ]], + { + i(1, 'x'), + i(2, '1'), + rep(1), + i(3, 'n'), + } + ) + ), + + -- Parentheses + s( + { trig = '()', condition = in_mathzone }, + fmta('\\left( <> \\right) <>', { + i(1), + i(0), + }) + ), + + -- Left-Right Parentheses + s( + { trig = 'lr', condition = in_mathzone }, + fmta('\\left( <> \\right) <>', { + i(1), + i(0), + }) + ), + + s( + { trig = 'lr(', condition = in_mathzone }, + fmta('\\left( <> \\right) <>', { + i(1), + i(0), + }) + ), + + -- Left-Right Vertical Bars + s( + { trig = 'lr|', condition = in_mathzone }, + fmta('\\left| <> \\right| <>', { + i(1), + i(0), + }) + ), + + -- Left-Right Curly Braces + s( + { trig = 'lr{', condition = in_mathzone }, + fmta('\\left\\{ <> \\right\\} <>', { + i(1), + i(0), + }) + ), + + s( + { trig = 'lrb', condition = in_mathzone }, + fmta('\\left\\{ <> \\right\\} <>', { + i(1), + i(0), + }) + ), + + -- Left-Right Square Brackets + s( + { trig = 'lr[', condition = in_mathzone }, + fmta('\\left[ <> \\right] <>', { + i(1), + i(0), + }) + ), + + -- Left-Right Angle Brackets + s( + { trig = 'lra', condition = in_mathzone }, + fmta('\\left\\langle <> \\right\\rangle <>', { + i(1), + i(0), + }) + ), + + -- Norm + s( + { trig = 'norm', condition = in_mathzone }, + fmta('\\|<>\\|<>', { + i(1), + i(0), + }) + ), + + -- Cases Environment + s( + { trig = 'case', condition = in_mathzone }, + fmta( + [[ + \begin{cases} + <> + \end{cases} + ]], + { i(1) } + ) + ), + + -- Big Function Definition + s( + { trig = 'bigfun', condition = in_mathzone }, + fmta( + [[ + \begin{align*} + <>: <> &\longrightarrow <> \\ + <> &\longmapsto <>(<>) = <> + .\end{align*} + ]], + { + i(1), + i(2), + i(3), + i(4), + rep(1), + rep(4), + i(0), + } + ) + ), + + -- Set Notation + s( + { trig = 'set', condition = in_mathzone }, + fmta('\\{<>\\} <>', { + i(1), + i(0), + }) + ), + + -- Mid Vertical Bar + s({ trig = '||', snippetType = 'autosnippet' }, t ' \\mid '), +} + +-- +-- Special Mathematical Symbols and Operators +local math_symbols_snippets = { + -- Basic Operators + s({ trig = '!=', snippetType = 'autosnippet' }, t '\\neq '), + + s({ trig = '==', condition = in_mathzone }, t '&= \\\\'), + + s({ trig = '~=', snippetType = 'autosnippet' }, t '\\approx '), + + s({ trig = '~~', snippetType = 'autosnippet' }, t '\\sim '), + + s({ trig = '->', condition = in_mathzone }, t '\\to '), + + s({ trig = '<->', condition = in_mathzone }, t '\\leftrightarrow'), + + s({ trig = '!>', condition = in_mathzone }, t '\\mapsto '), + + s({ trig = '>>', snippetType = 'autosnippet' }, t '\\gg'), + + s({ trig = '<<', snippetType = 'autosnippet' }, t '\\ll'), + + -- Set Theory Operators + s({ trig = 'cc', condition = in_mathzone }, t '\\subset '), + + s({ trig = 'notin', snippetType = 'autosnippet' }, t '\\not\\in '), + + s({ trig = 'inn', condition = in_mathzone }, t '\\in '), + + s({ trig = 'Nn', snippetType = 'autosnippet' }, t '\\cap '), + + s({ trig = 'UU', snippetType = 'autosnippet' }, t '\\cup '), + + s( + { trig = 'uuu', snippetType = 'autosnippet' }, + fmta('\\bigcup_{<> \\in <>} <>', { + i(1, 'i'), + i(2, 'I'), + i(0), + }) + ), + + s( + { trig = 'nnn', snippetType = 'autosnippet' }, + fmta('\\bigcap_{<> \\in <>} <>', { + i(1, 'i'), + i(2, 'I'), + i(0), + }) + ), + + s({ trig = 'OO', snippetType = 'autosnippet' }, t '\\O'), + + -- Number Sets + s({ trig = 'RR', snippetType = 'autosnippet' }, t '\\R'), + + s({ trig = 'QQ', snippetType = 'autosnippet' }, t '\\Q'), + + s({ trig = 'ZZ', snippetType = 'autosnippet' }, t '\\Z'), + + s({ trig = 'NN', snippetType = 'autosnippet' }, t '\\N'), + + s({ trig = 'HH', snippetType = 'autosnippet' }, t '\\mathbb{H}'), + + s({ trig = 'DD', snippetType = 'autosnippet' }, t '\\mathbb{D}'), + + -- Special Operators + s({ trig = '**', snippetType = 'autosnippet' }, t '\\cdot '), + + s({ trig = 'xx', condition = in_mathzone }, t '\\times '), + + s({ trig = '', snippetType = 'autosnippet' }, t '\\diamond '), + + -- Calculus and Analysis + s({ trig = 'nabl', condition = in_mathzone }, t '\\nabla '), + + -- Function Modifiers + s( + { trig = 'bar', condition = in_mathzone }, + fmta('\\overline{<>}<>', { + i(1), + i(0), + }) + ), + + s( + { trig = '([a-zA-Z])bar', regTrig = true, condition = in_mathzone }, + f(function(_, snip) + return string.format('\\overline{%s}', snip.captures[1]) + end) + ), + + s( + { trig = 'hat', condition = in_mathzone }, + fmta('\\hat{<>}<>', { + i(1), + i(0), + }) + ), + + s( + { trig = '([a-zA-Z])hat', regTrig = true, condition = in_mathzone }, + f(function(_, snip) + return string.format('\\hat{%s}', snip.captures[1]) + end) + ), + + -- Common Mathematical Functions + s( + { trig = 'conj', condition = in_mathzone }, + fmta('\\overline{<>}<>', { + i(1), + i(0), + }) + ), + + -- Inverse and Complement + s({ trig = 'invs', condition = in_mathzone }, t '^{-1}'), + + s({ trig = 'compl', condition = in_mathzone }, t '^{c}'), + + -- Set Operations + s({ trig = '\\\\', condition = in_mathzone }, t '\\setminus'), + + -- Text in Math Mode + s( + { trig = 'tt', condition = in_mathzone }, + fmta('\\text{<>}<>', { + i(1), + i(0), + }) + ), + + s( + { trig = 'sts', condition = in_mathzone }, + fmta('_\\text{<>} <>', { + i(1), + i(0), + }) + ), + + -- Calligraphic Letters + s( + { trig = 'mcal', condition = in_mathzone }, + fmta('\\mathcal{<>}<>', { + i(1), + i(0), + }) + ), + + -- Special Letters + s({ trig = 'lll', snippetType = 'autosnippet' }, t '\\ell'), +} + +-- +-- +-- Greek Letters and Other Mathematical Notation +local greek_math_notation = { + -- Common Greek Letters (auto-expanding in math mode) + s({ trig = '@a', condition = in_mathzone }, t '\\alpha'), + + s({ trig = '@b', condition = in_mathzone }, t '\\beta'), + + s({ trig = '@g', condition = in_mathzone }, t '\\gamma'), + + s({ trig = '@G', condition = in_mathzone }, t '\\Gamma'), + + s({ trig = '@d', condition = in_mathzone }, t '\\delta'), + + s({ trig = '@D', condition = in_mathzone }, t '\\Delta'), + + s({ trig = '@e', condition = in_mathzone }, t '\\epsilon'), + + s({ trig = '@ve', condition = in_mathzone }, t '\\varepsilon'), + + s({ trig = '@z', condition = in_mathzone }, t '\\zeta'), + + s({ trig = '@h', condition = in_mathzone }, t '\\eta'), + + s({ trig = '@th', condition = in_mathzone }, t '\\theta'), + + s({ trig = '@Th', condition = in_mathzone }, t '\\Theta'), + + s({ trig = '@vth', condition = in_mathzone }, t '\\vartheta'), + + s({ trig = '@i', condition = in_mathzone }, t '\\iota'), + + s({ trig = '@k', condition = in_mathzone }, t '\\kappa'), + + s({ trig = '@l', condition = in_mathzone }, t '\\lambda'), + + s({ trig = '@L', condition = in_mathzone }, t '\\Lambda'), + + s({ trig = '@m', condition = in_mathzone }, t '\\mu'), + + s({ trig = '@n', condition = in_mathzone }, t '\\nu'), + + s({ trig = '@x', condition = in_mathzone }, t '\\xi'), + + s({ trig = '@X', condition = in_mathzone }, t '\\Xi'), + + s({ trig = '@p', condition = in_mathzone }, t '\\pi'), + + s({ trig = '@P', condition = in_mathzone }, t '\\Pi'), + + s({ trig = '@r', condition = in_mathzone }, t '\\rho'), + + s({ trig = '@s', condition = in_mathzone }, t '\\sigma'), + + s({ trig = '@S', condition = in_mathzone }, t '\\Sigma'), + + s({ trig = '@t', condition = in_mathzone }, t '\\tau'), + + s({ trig = '@ph', condition = in_mathzone }, t '\\phi'), + + s({ trig = '@Ph', condition = in_mathzone }, t '\\Phi'), + + s({ trig = '@vph', condition = in_mathzone }, t '\\varphi'), + + s({ trig = '@ch', condition = in_mathzone }, t '\\chi'), + + s({ trig = '@ps', condition = in_mathzone }, t '\\psi'), + + s({ trig = '@Ps', condition = in_mathzone }, t '\\Psi'), + + s({ trig = '@o', condition = in_mathzone }, t '\\omega'), + + s({ trig = '@O', condition = in_mathzone }, t '\\Omega'), + + -- Common Variable Notations + s({ trig = 'xnn', condition = in_mathzone }, t 'x_{n}'), + + s({ trig = 'ynn', condition = in_mathzone }, t 'y_{n}'), + + s({ trig = 'xii', condition = in_mathzone }, t 'x_{i}'), + + s({ trig = 'yii', condition = in_mathzone }, t 'y_{i}'), + + s({ trig = 'xjj', condition = in_mathzone }, t 'x_{j}'), + + s({ trig = 'yjj', condition = in_mathzone }, t 'y_{j}'), + + s({ trig = 'xp1', condition = in_mathzone }, t 'x_{n+1}'), + + s({ trig = 'xmm', condition = in_mathzone }, t 'x_{m}'), + + -- Special Sets and Notations + s({ trig = 'R0+', snippetType = 'autosnippet' }, t '\\R_0^+'), + + -- Common Mathematical Decorations + s({ trig = 'bar', condition = in_mathzone }, fmta('\\overline{<>}', { i(1) })), + + s({ trig = 'hat', condition = in_mathzone }, fmta('\\hat{<>}', { i(1) })), + + s({ trig = 'vec', condition = in_mathzone }, fmta('\\vec{<>}', { i(1) })), + + s({ trig = 'tilde', condition = in_mathzone }, fmta('\\tilde{<>}', { i(1) })), + + -- Dots + s({ trig = '...', snippetType = 'autosnippet' }, t '\\dots'), + + s({ trig = 'cd', snippetType = 'autosnippet' }, t '\\cdots'), + + s({ trig = 'vd', snippetType = 'autosnippet' }, t '\\vdots'), + + s({ trig = 'dd', snippetType = 'autosnippet' }, t '\\ddots'), + + -- Special Functions + s({ trig = 'letw', snippetType = 'autosnippet' }, t 'Let $\\Omega \\subset \\C$ be open.'), + + -- Common Mathematical Accents + s({ trig = 'dot', condition = in_mathzone }, fmta('\\dot{<>}', { i(1) })), + + s({ trig = 'ddot', condition = in_mathzone }, fmta('\\ddot{<>}', { i(1) })), + + -- Special Delimiters + s({ trig = 'ceil', condition = in_mathzone }, fmta('\\left\\lceil <> \\right\\rceil', { i(1) })), + + s({ trig = 'floor', condition = in_mathzone }, fmta('\\left\\lfloor <> \\right\\rfloor', { i(1) })), + + -- Mathematical Spaces + s({ trig = 'qq', snippetType = 'autosnippet' }, t '\\quad '), + + s({ trig = 'qw', snippetType = 'autosnippet' }, t '\\qquad '), + + -- Special Constants + s({ trig = 'pi', condition = in_mathzone }, t '\\pi'), + + s({ trig = 'ee', condition = in_mathzone }, t '\\mathrm{e}'), + + s({ trig = 'ii', condition = in_mathzone }, t '\\mathrm{i}'), +} + +---- Environment-specific Snippets +local environment_snippets = { + -- Align Environment + s( + { trig = 'ali', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{align*} + <> + \end{align*} + ]], + { i(1) } + ) + ), + + -- Equation Environment + s( + { trig = 'eq', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{equation*} + <> + \end{equation*} + ]], + { i(1) } + ) + ), + + -- Cases Environment + s( + { trig = 'case', condition = in_mathzone }, + fmta( + [[ + \begin{cases} + <> + \end{cases} + ]], + { i(1) } + ) + ), + + -- Matrix Environments + s( + { trig = 'mat', condition = in_mathzone }, + c(1, { + sn(nil, { + t '\\begin{matrix} ', + i(1), + t ' \\end{matrix}', + }), + sn(nil, { + t '\\begin{pmatrix} ', + i(1), + t ' \\end{pmatrix}', + }), + sn(nil, { + t '\\begin{bmatrix} ', + i(1), + t ' \\end{bmatrix}', + }), + sn(nil, { + t '\\begin{vmatrix} ', + i(1), + t ' \\end{vmatrix}', + }), + sn(nil, { + t '\\begin{Vmatrix} ', + i(1), + t ' \\end{Vmatrix}', + }), + }) + ), + + -- Theorem Environments + s( + { trig = 'thm', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{theorem}[<>] + <> + \end{theorem} + ]], + { + i(1), + i(0), + } + ) + ), + + s( + { trig = 'lem', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{lemma}[<>] + <> + \end{lemma} + ]], + { + i(1), + i(0), + } + ) + ), + + s( + { trig = 'prop', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{proposition}[<>] + <> + \end{proposition} + ]], + { + i(1), + i(0), + } + ) + ), + + s( + { trig = 'cor', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{corollary}[<>] + <> + \end{corollary} + ]], + { + i(1), + i(0), + } + ) + ), + + s( + { trig = 'def', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{definition}[<>] + <> + \end{definition} + ]], + { + i(1), + i(0), + } + ) + ), + + -- Proof Environment + s( + { trig = 'prf', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{proof} + <> + \end{proof} + ]], + { i(0) } + ) + ), + + -- Example Environment + s( + { trig = 'exe', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{example}[<>] + <> + \end{example} + ]], + { + i(1), + i(0), + } + ) + ), + + -- Remark Environment + s( + { trig = 'rem', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{remark} + <> + \end{remark} + ]], + { i(0) } + ) + ), + + -- List Environments + s( + { trig = 'enum', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{enumerate} + \item <> + \end{enumerate} + ]], + { i(0) } + ) + ), + + s( + { trig = 'item', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{itemize} + \item <> + \end{itemize} + ]], + { i(0) } + ) + ), + + s( + { trig = 'desc', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{description} + \item[<>] <> + \end{description} + ]], + { + i(1), + i(0), + } + ) + ), + + -- Figure Environment + s( + { trig = 'fig', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{figure}[<>] + \centering + \includegraphics[width=<>\textwidth]{<>} + \caption{<>} + \label{fig:<>} + \end{figure} + ]], + { + i(1, 'htbp'), + i(2, '0.8'), + i(3, 'filename'), + i(4, 'caption'), + i(5, 'label'), + } + ) + ), + + -- Table Environment + s( + { trig = 'tab', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{table}[<>] + \centering + \caption{<>} + \label{tab:<>} + \begin{tabular}{<>} + \toprule + <> + \midrule + <> + \bottomrule + \end{tabular} + \end{table} + ]], + { + i(1, 'htbp'), + i(2, 'caption'), + i(3, 'label'), + i(4, 'cc'), + i(5, 'Header 1 & Header 2 \\\\'), + i(0, 'Content'), + } + ) + ), + + -- TikZ Environment + s( + { trig = 'tikz', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{tikzpicture}[<>] + <> + \end{tikzpicture} + ]], + { + i(1), + i(0), + } + ) + ), + + -- Plot Environment + s( + { trig = 'plot', snippetType = 'autosnippet' }, + fmta( + [[ + \begin{figure}[<>] + \centering + \begin{tikzpicture} + \begin{axis}[ + xmin= <>, xmax= <>, + ymin= <>, ymax = <>, + axis lines = middle, + ] + \addplot[domain=<>:<>, samples=<>]{<>}; + \end{axis} + \end{tikzpicture} + \caption{<>} + \label{<>} + \end{figure} + ]], + { + i(1, 'htbp'), + i(2, '-10'), + i(3, '10'), + i(4, '-10'), + i(5, '10'), + rep(2), + rep(3), + i(6, '100'), + i(7, 'x^2'), + i(8, 'caption'), + i(9, 'label'), + } + ) + ), +} + +-- Common Mathematical Functions +local math_functions_snippets = { + -- Trigonometric Functions + s({ trig = 'sin', condition = in_mathzone }, t '\\sin'), + + s({ trig = 'cos', condition = in_mathzone }, t '\\cos'), + + s({ trig = 'tan', condition = in_mathzone }, t '\\tan'), + + s({ trig = 'csc', condition = in_mathzone }, t '\\csc'), + + s({ trig = 'sec', condition = in_mathzone }, t '\\sec'), + + s({ trig = 'cot', condition = in_mathzone }, t '\\cot'), + + -- Inverse Trigonometric Functions + s({ trig = 'asin', condition = in_mathzone }, t '\\arcsin'), + + s({ trig = 'acos', condition = in_mathzone }, t '\\arccos'), + + s({ trig = 'atan', condition = in_mathzone }, t '\\arctan'), + + s({ trig = 'acsc', condition = in_mathzone }, t '\\arccsc'), + + s({ trig = 'asec', condition = in_mathzone }, t '\\arcsec'), + + s({ trig = 'acot', condition = in_mathzone }, t '\\arccot'), + + -- Hyperbolic Functions + s({ trig = 'sinh', condition = in_mathzone }, t '\\sinh'), + + s({ trig = 'cosh', condition = in_mathzone }, t '\\cosh'), + + s({ trig = 'tanh', condition = in_mathzone }, t '\\tanh'), + + s({ trig = 'csch', condition = in_mathzone }, t '\\csch'), + + s({ trig = 'sech', condition = in_mathzone }, t '\\sech'), + + s({ trig = 'coth', condition = in_mathzone }, t '\\coth'), + + -- Logarithmic Functions + s({ trig = 'log', condition = in_mathzone }, t '\\log'), + + s({ trig = 'ln', condition = in_mathzone }, t '\\ln'), + + s({ trig = 'lg', condition = in_mathzone }, t '\\lg'), + + -- Exponential Function + s({ trig = 'exp', condition = in_mathzone }, t '\\exp'), + + -- Limit Operations + s( + { trig = 'lim', condition = in_mathzone }, + fmta('\\lim_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'limsup', condition = in_mathzone }, + fmta('\\limsup_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'liminf', condition = in_mathzone }, + fmta('\\liminf_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Summation and Product + s( + { trig = 'sum', condition = in_mathzone }, + fmta('\\sum_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'prod', condition = in_mathzone }, + fmta('\\prod_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Integral Operations + s( + { trig = 'int', condition = in_mathzone }, + fmta('\\int_{<>}^{<>} <> \\,d<>', { + i(1, 'a'), + i(2, 'b'), + i(3), + i(4, 'x'), + }) + ), + + s( + { trig = 'dint', condition = in_mathzone }, + fmta('\\int\\int_{<>} <> \\,d<>\\,d<>', { + i(1, 'D'), + i(2), + i(3, 'x'), + i(4, 'y'), + }) + ), + + s( + { trig = 'tint', condition = in_mathzone }, + fmta('\\iiint_{<>} <> \\,d<>\\,d<>\\,d<>', { + i(1, 'E'), + i(2), + i(3, 'x'), + i(4, 'y'), + i(5, 'z'), + }) + ), + + -- Differential Operators + s( + { trig = 'partial', condition = in_mathzone }, + fmta('\\frac{\\partial <>}{\\partial <>}', { + i(1, 'f'), + i(2, 'x'), + }) + ), + + s( + { trig = 'dv', condition = in_mathzone }, + fmta('\\frac{d <>}{d <>}', { + i(1, 'y'), + i(2, 'x'), + }) + ), + + -- Special Functions + s({ trig = 'sqrt', condition = in_mathzone }, fmta('\\sqrt{<>}', { i(1) })), + + s({ trig = 'max', condition = in_mathzone }, fmta('\\max\\{<>\\}', { i(1) })), + + s({ trig = 'min', condition = in_mathzone }, fmta('\\min\\{<>\\}', { i(1) })), + + s( + { trig = 'sup', condition = in_mathzone }, + fmta('\\sup_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + s( + { trig = 'inf', condition = in_mathzone }, + fmta('\\inf_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + -- Floor and Ceiling Functions + s({ trig = 'floor', condition = in_mathzone }, fmta('\\left\\lfloor <> \\right\\rfloor', { i(1) })), + + s({ trig = 'ceil', condition = in_mathzone }, fmta('\\left\\lceil <> \\right\\rceil', { i(1) })), +} + +local math_functions_snippets = { + -- Trigonometric Functions + s({ trig = 'sin', condition = in_mathzone }, t '\\sin'), + + s({ trig = 'cos', condition = in_mathzone }, t '\\cos'), + + s({ trig = 'tan', condition = in_mathzone }, t '\\tan'), + + s({ trig = 'csc', condition = in_mathzone }, t '\\csc'), + + s({ trig = 'sec', condition = in_mathzone }, t '\\sec'), + + s({ trig = 'cot', condition = in_mathzone }, t '\\cot'), + + -- Inverse Trigonometric Functions + s({ trig = 'asin', condition = in_mathzone }, t '\\arcsin'), + + s({ trig = 'acos', condition = in_mathzone }, t '\\arccos'), + + s({ trig = 'atan', condition = in_mathzone }, t '\\arctan'), + + s({ trig = 'acsc', condition = in_mathzone }, t '\\arccsc'), + + s({ trig = 'asec', condition = in_mathzone }, t '\\arcsec'), + + s({ trig = 'acot', condition = in_mathzone }, t '\\arccot'), + + -- Hyperbolic Functions + s({ trig = 'sinh', condition = in_mathzone }, t '\\sinh'), + + s({ trig = 'cosh', condition = in_mathzone }, t '\\cosh'), + + s({ trig = 'tanh', condition = in_mathzone }, t '\\tanh'), + + s({ trig = 'csch', condition = in_mathzone }, t '\\csch'), + + s({ trig = 'sech', condition = in_mathzone }, t '\\sech'), + + s({ trig = 'coth', condition = in_mathzone }, t '\\coth'), + + -- Logarithmic Functions + s({ trig = 'log', condition = in_mathzone }, t '\\log'), + + s({ trig = 'ln', condition = in_mathzone }, t '\\ln'), + + s({ trig = 'lg', condition = in_mathzone }, t '\\lg'), + + -- Exponential Function + s({ trig = 'exp', condition = in_mathzone }, t '\\exp'), + + -- Limit Operations + s( + { trig = 'lim', condition = in_mathzone }, + fmta('\\lim_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'limsup', condition = in_mathzone }, + fmta('\\limsup_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'liminf', condition = in_mathzone }, + fmta('\\liminf_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Summation and Product + s( + { trig = 'sum', condition = in_mathzone }, + fmta('\\sum_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'prod', condition = in_mathzone }, + fmta('\\prod_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Integral Operations + s( + { trig = 'int', condition = in_mathzone }, + fmta('\\int_{<>}^{<>} <> \\,d<>', { + i(1, 'a'), + i(2, 'b'), + i(3), + i(4, 'x'), + }) + ), + + s( + { trig = 'dint', condition = in_mathzone }, + fmta('\\int\\int_{<>} <> \\,d<>\\,d<>', { + i(1, 'D'), + i(2), + i(3, 'x'), + i(4, 'y'), + }) + ), + + s( + { trig = 'tint', condition = in_mathzone }, + fmta('\\iiint_{<>} <> \\,d<>\\,d<>\\,d<>', { + i(1, 'E'), + i(2), + i(3, 'x'), + i(4, 'y'), + i(5, 'z'), + }) + ), + + -- Differential Operators + s( + { trig = 'partial', condition = in_mathzone }, + fmta('\\frac{\\partial <>}{\\partial <>}', { + i(1, 'f'), + i(2, 'x'), + }) + ), + + s( + { trig = 'dv', condition = in_mathzone }, + fmta('\\frac{d <>}{d <>}', { + i(1, 'y'), + i(2, 'x'), + }) + ), + + -- Special Functions + s({ trig = 'sqrt', condition = in_mathzone }, fmta('\\sqrt{<>}', { i(1) })), + + s({ trig = 'max', condition = in_mathzone }, fmta('\\max\\{<>\\}', { i(1) })), + + s({ trig = 'min', condition = in_mathzone }, fmta('\\min\\{<>\\}', { i(1) })), + + s( + { trig = 'sup', condition = in_mathzone }, + fmta('\\sup_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + s( + { trig = 'inf', condition = in_mathzone }, + fmta('\\inf_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + -- Floor and Ceiling Functions + s({ trig = 'floor', condition = in_mathzone }, fmta('\\left\\lfloor <> \\right\\rfloor', { i(1) })), + + s({ trig = 'ceil', condition = in_mathzone }, fmta('\\left\\lceil <> \\right\\rceil', { i(1) })), +} + +-- Add these snippets to your main snippets table +for k, v in pairs(math_functions_snippets) do + table.insert(snippets, v) +end -- Common Mathematical Functions +local math_functions_snippets = { + -- Trigonometric Functions + s({ trig = 'sin', condition = in_mathzone }, t '\\sin'), + + s({ trig = 'cos', condition = in_mathzone }, t '\\cos'), + + s({ trig = 'tan', condition = in_mathzone }, t '\\tan'), + + s({ trig = 'csc', condition = in_mathzone }, t '\\csc'), + + s({ trig = 'sec', condition = in_mathzone }, t '\\sec'), + + s({ trig = 'cot', condition = in_mathzone }, t '\\cot'), + + -- Inverse Trigonometric Functions + s({ trig = 'asin', condition = in_mathzone }, t '\\arcsin'), + + s({ trig = 'acos', condition = in_mathzone }, t '\\arccos'), + + s({ trig = 'atan', condition = in_mathzone }, t '\\arctan'), + + s({ trig = 'acsc', condition = in_mathzone }, t '\\arccsc'), + + s({ trig = 'asec', condition = in_mathzone }, t '\\arcsec'), + + s({ trig = 'acot', condition = in_mathzone }, t '\\arccot'), + + -- Hyperbolic Functions + s({ trig = 'sinh', condition = in_mathzone }, t '\\sinh'), + + s({ trig = 'cosh', condition = in_mathzone }, t '\\cosh'), + + s({ trig = 'tanh', condition = in_mathzone }, t '\\tanh'), + + s({ trig = 'csch', condition = in_mathzone }, t '\\csch'), + + s({ trig = 'sech', condition = in_mathzone }, t '\\sech'), + + s({ trig = 'coth', condition = in_mathzone }, t '\\coth'), + + -- Logarithmic Functions + s({ trig = 'log', condition = in_mathzone }, t '\\log'), + + s({ trig = 'ln', condition = in_mathzone }, t '\\ln'), + + s({ trig = 'lg', condition = in_mathzone }, t '\\lg'), + + -- Exponential Function + s({ trig = 'exp', condition = in_mathzone }, t '\\exp'), + + -- Limit Operations + s( + { trig = 'lim', condition = in_mathzone }, + fmta('\\lim_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'limsup', condition = in_mathzone }, + fmta('\\limsup_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'liminf', condition = in_mathzone }, + fmta('\\liminf_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Summation and Product + s( + { trig = 'sum', condition = in_mathzone }, + fmta('\\sum_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'prod', condition = in_mathzone }, + fmta('\\prod_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Integral Operations + s( + { trig = 'int', condition = in_mathzone }, + fmta('\\int_{<>}^{<>} <> \\,d<>', { + i(1, 'a'), + i(2, 'b'), + i(3), + i(4, 'x'), + }) + ), + + s( + { trig = 'dint', condition = in_mathzone }, + fmta('\\int\\int_{<>} <> \\,d<>\\,d<>', { + i(1, 'D'), + i(2), + i(3, 'x'), + i(4, 'y'), + }) + ), + + s( + { trig = 'tint', condition = in_mathzone }, + fmta('\\iiint_{<>} <> \\,d<>\\,d<>\\,d<>', { + i(1, 'E'), + i(2), + i(3, 'x'), + i(4, 'y'), + i(5, 'z'), + }) + ), + + -- Differential Operators + s( + { trig = 'partial', condition = in_mathzone }, + fmta('\\frac{\\partial <>}{\\partial <>}', { + i(1, 'f'), + i(2, 'x'), + }) + ), + + s( + { trig = 'dv', condition = in_mathzone }, + fmta('\\frac{d <>}{d <>}', { + i(1, 'y'), + i(2, 'x'), + }) + ), + + -- Special Functions + s({ trig = 'sqrt', condition = in_mathzone }, fmta('\\sqrt{<>}', { i(1) })), + + s({ trig = 'max', condition = in_mathzone }, fmta('\\max\\{<>\\}', { i(1) })), + + s({ trig = 'min', condition = in_mathzone }, fmta('\\min\\{<>\\}', { i(1) })), + + s( + { trig = 'sup', condition = in_mathzone }, + fmta('\\sup_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + s( + { trig = 'inf', condition = in_mathzone }, + fmta('\\inf_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + -- Floor and Ceiling Functions + s({ trig = 'floor', condition = in_mathzone }, fmta('\\left\\lfloor <> \\right\\rfloor', { i(1) })), + + s({ trig = 'ceil', condition = in_mathzone }, fmta('\\left\\lceil <> \\right\\rceil', { i(1) })), +} + +-- Add these snippets to your main snippets table +for k, v in pairs(math_functions_snippets) do + table.insert(snippets, v) +end -- Common Mathematical Functions +local math_functions_snippets = { + -- Trigonometric Functions + s({ trig = 'sin', condition = in_mathzone }, t '\\sin'), + + s({ trig = 'cos', condition = in_mathzone }, t '\\cos'), + + s({ trig = 'tan', condition = in_mathzone }, t '\\tan'), + + s({ trig = 'csc', condition = in_mathzone }, t '\\csc'), + + s({ trig = 'sec', condition = in_mathzone }, t '\\sec'), + + s({ trig = 'cot', condition = in_mathzone }, t '\\cot'), + + -- Inverse Trigonometric Functions + s({ trig = 'asin', condition = in_mathzone }, t '\\arcsin'), + + s({ trig = 'acos', condition = in_mathzone }, t '\\arccos'), + + s({ trig = 'atan', condition = in_mathzone }, t '\\arctan'), + + s({ trig = 'acsc', condition = in_mathzone }, t '\\arccsc'), + + s({ trig = 'asec', condition = in_mathzone }, t '\\arcsec'), + + s({ trig = 'acot', condition = in_mathzone }, t '\\arccot'), + + -- Hyperbolic Functions + s({ trig = 'sinh', condition = in_mathzone }, t '\\sinh'), + + s({ trig = 'cosh', condition = in_mathzone }, t '\\cosh'), + + s({ trig = 'tanh', condition = in_mathzone }, t '\\tanh'), + + s({ trig = 'csch', condition = in_mathzone }, t '\\csch'), + + s({ trig = 'sech', condition = in_mathzone }, t '\\sech'), + + s({ trig = 'coth', condition = in_mathzone }, t '\\coth'), + + -- Logarithmic Functions + s({ trig = 'log', condition = in_mathzone }, t '\\log'), + + s({ trig = 'ln', condition = in_mathzone }, t '\\ln'), + + s({ trig = 'lg', condition = in_mathzone }, t '\\lg'), + + -- Exponential Function + s({ trig = 'exp', condition = in_mathzone }, t '\\exp'), + + -- Limit Operations + s( + { trig = 'lim', condition = in_mathzone }, + fmta('\\lim_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'limsup', condition = in_mathzone }, + fmta('\\limsup_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'liminf', condition = in_mathzone }, + fmta('\\liminf_{<> \\to <>} <>', { + i(1, 'n'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Summation and Product + s( + { trig = 'sum', condition = in_mathzone }, + fmta('\\sum_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + s( + { trig = 'prod', condition = in_mathzone }, + fmta('\\prod_{<>}^{<>} <>', { + i(1, 'n=1'), + i(2, '\\infty'), + i(0), + }) + ), + + -- Integral Operations + s( + { trig = 'int', condition = in_mathzone }, + fmta('\\int_{<>}^{<>} <> \\,d<>', { + i(1, 'a'), + i(2, 'b'), + i(3), + i(4, 'x'), + }) + ), + + s( + { trig = 'dint', condition = in_mathzone }, + fmta('\\int\\int_{<>} <> \\,d<>\\,d<>', { + i(1, 'D'), + i(2), + i(3, 'x'), + i(4, 'y'), + }) + ), + + s( + { trig = 'tint', condition = in_mathzone }, + fmta('\\iiint_{<>} <> \\,d<>\\,d<>\\,d<>', { + i(1, 'E'), + i(2), + i(3, 'x'), + i(4, 'y'), + i(5, 'z'), + }) + ), + + -- Differential Operators + s( + { trig = 'partial', condition = in_mathzone }, + fmta('\\frac{\\partial <>}{\\partial <>}', { + i(1, 'f'), + i(2, 'x'), + }) + ), + + s( + { trig = 'dv', condition = in_mathzone }, + fmta('\\frac{d <>}{d <>}', { + i(1, 'y'), + i(2, 'x'), + }) + ), + + -- Special Functions + s({ trig = 'sqrt', condition = in_mathzone }, fmta('\\sqrt{<>}', { i(1) })), + + s({ trig = 'max', condition = in_mathzone }, fmta('\\max\\{<>\\}', { i(1) })), + + s({ trig = 'min', condition = in_mathzone }, fmta('\\min\\{<>\\}', { i(1) })), + + s( + { trig = 'sup', condition = in_mathzone }, + fmta('\\sup_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + s( + { trig = 'inf', condition = in_mathzone }, + fmta('\\inf_{<>} <>', { + i(1, 'n \\in \\N'), + i(0), + }) + ), + + -- Floor and Ceiling Functions + s({ trig = 'floor', condition = in_mathzone }, fmta('\\left\\lfloor <> \\right\\rfloor', { i(1) })), + + s({ trig = 'ceil', condition = in_mathzone }, fmta('\\left\\lceil <> \\right\\rceil', { i(1) })), +} + +-- Add these snippets to your main snippets table +for k, v in pairs(math_functions_snippets) do + table.insert(snippets, v) +end + +local additional_math_snippets = { + -- Additional Operators + s({ trig = 'oplus', condition = in_mathzone }, t '\\oplus '), + + s({ trig = 'otimes', condition = in_mathzone }, t '\\otimes '), + + s({ trig = 'odot', condition = in_mathzone }, t '\\odot '), + + s( + { trig = 'bigoplus', condition = in_mathzone }, + fmta('\\bigoplus_{<>}^{<>} <>', { + i(1, 'i=1'), + i(2, 'n'), + i(0), + }) + ), + + s( + { trig = 'bigotimes', condition = in_mathzone }, + fmta('\\bigotimes_{<>}^{<>} <>', { + i(1, 'i=1'), + i(2, 'n'), + i(0), + }) + ), + + -- Additional Arrows + s({ trig = 'rar', condition = in_mathzone }, t '\\rightarrow '), + + s({ trig = 'lar', condition = in_mathzone }, t '\\leftarrow '), + + s({ trig = 'lrar', condition = in_mathzone }, t '\\leftrightarrow '), + + s({ trig = 'Rar', condition = in_mathzone }, t '\\Rightarrow '), + + s({ trig = 'Lar', condition = in_mathzone }, t '\\Leftarrow '), + + s({ trig = 'Lrar', condition = in_mathzone }, t '\\Leftrightarrow '), + + -- Additional Delimiters + s({ trig = 'langle', condition = in_mathzone }, fmta('\\langle <> \\rangle', { i(1) })), + + s({ trig = 'lvert', condition = in_mathzone }, fmta('\\lvert <> \\rvert', { i(1) })), + + s({ trig = 'lVert', condition = in_mathzone }, fmta('\\lVert <> \\rVert', { i(1) })), + + -- Additional Mathematical Spaces + s({ trig = ',', condition = in_mathzone }, t ', '), + + s({ trig = ':', condition = in_mathzone }, t ': '), + + s({ trig = 'quad', condition = in_mathzone }, t '\\quad '), + + s({ trig = 'qquad', condition = in_mathzone }, t '\\qquad '), + + -- Additional Set Theory + s({ trig = 'empty', condition = in_mathzone }, t '\\emptyset'), + + s({ trig = 'comp', condition = in_mathzone }, t '^{\\complement}'), + + s({ trig = 'powerset', condition = in_mathzone }, t '\\mathcal{P}'), + + -- Additional Accents + s({ trig = 'vec', condition = in_mathzone }, fmta('\\vec{<>}', { i(1) })), + + s({ trig = 'overline', condition = in_mathzone }, fmta('\\overline{<>}', { i(1) })), + + s({ trig = 'underline', condition = in_mathzone }, fmta('\\underline{<>}', { i(1) })), + + s({ trig = 'widehat', condition = in_mathzone }, fmta('\\widehat{<>}', { i(1) })), + + s({ trig = 'widetilde', condition = in_mathzone }, fmta('\\widetilde{<>}', { i(1) })), + + -- Additional Font Styles + s({ trig = 'bb', condition = in_mathzone }, fmta('\\mathbb{<>}', { i(1) })), + + s({ trig = 'bf', condition = in_mathzone }, fmta('\\mathbf{<>}', { i(1) })), + + s({ trig = 'cal', condition = in_mathzone }, fmta('\\mathcal{<>}', { i(1) })), + + s({ trig = 'scr', condition = in_mathzone }, fmta('\\mathscr{<>}', { i(1) })), + + s({ trig = 'frak', condition = in_mathzone }, fmta('\\mathfrak{<>}', { i(1) })), + + -- Additional Relations + s({ trig = 'prec', condition = in_mathzone }, t '\\prec '), + + s({ trig = 'succ', condition = in_mathzone }, t '\\succ '), + + s({ trig = 'preceq', condition = in_mathzone }, t '\\preceq '), + + s({ trig = 'succeq', condition = in_mathzone }, t '\\succeq '), + + -- Special Functions and Notation + s( + { trig = 'binom', condition = in_mathzone }, + fmta('\\binom{<>}{<>}', { + i(1), + i(2), + }) + ), + + s({ trig = 'pmod', condition = in_mathzone }, fmta('\\pmod{<>}', { i(1) })), + + s({ trig = 'equiv', condition = in_mathzone }, t '\\equiv '), + + s({ trig = 'cong', condition = in_mathzone }, t '\\cong '), + + -- Probability and Statistics + s({ trig = 'prob', condition = in_mathzone }, t '\\mathbb{P}'), + + s({ trig = 'expect', condition = in_mathzone }, t '\\mathbb{E}'), + + s({ trig = 'var', condition = in_mathzone }, t '\\text{Var}'), + + s({ trig = 'cov', condition = in_mathzone }, t '\\text{Cov}'), + + -- SI Units + s( + { trig = 'SI', snippetType = 'autosnippet' }, + fmta('\\SI{<>}{<>}', { + i(1), + i(2), + }) + ), + + -- Sympy Integration + s( + { trig = 'sympy', snippetType = 'autosnippet' }, + fmta( + [[ + sympy <> sympy + ]], + { i(1) } + ) + ), + + -- Mathematica Integration + s( + { trig = 'math', snippetType = 'autosnippet' }, + fmta( + [[ + math <> math + ]], + { i(1) } + ) + ), + + -- Additional Useful Shortcuts + s({ trig = 'deff', condition = in_mathzone }, t '\\triangleq '), + + s({ trig = 'isom', condition = in_mathzone }, t '\\cong '), + + s({ trig = 'surj', condition = in_mathzone }, t '\\twoheadrightarrow '), + + s({ trig = 'inj', condition = in_mathzone }, t '\\hookrightarrow '), + + -- Common Subscript Patterns + s( + { trig = "([%w%)%]%}])'", regTrig = true, condition = in_mathzone }, + f(function(_, snip) + return snip.captures[1] .. '^\\prime' + end) + ), + + s( + { trig = '([%w%)%]%}])_%(%d+%)', regTrig = true, condition = in_mathzone }, + f(function(_, snip) + local base = snip.captures[1] + local subscript = snip.captures[2]:sub(3, -2) -- Remove _( and ) + return string.format('%s_{%s}', base, subscript) + end) + ), +} +return { + ls.add_snippets('tex', snippets), + ls.add_snippets('tex', math_snippets), + ls.add_snippets('tex', environment_snippets), + ls.add_snippets('tex', math_functions_snippets), + ls.add_snippets('tex', additional_math_snippets), + ls.add_snippets('tex', math_symbols_snippets), + ls.add_snippets('tex', math_functions_snippets), +} diff --git a/lua/custom/plugins/Luasnip/tex/operations.lua b/lua/custom/plugins/Luasnip/tex/operations.lua new file mode 100644 index 00000000000..9580dfc3e6b --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/operations.lua @@ -0,0 +1,95 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local d = ls.dynamic_node +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local rep = require("luasnip.extras").rep + + + +return { + s({ trig = "BigProd",snippetType="autosnippet" }, + fmta('\\prod_{<>}^{<>} <>', { + i(1, "n=1"), + i(2, "\\infty"), + i(0),} + )), + s( + { trig = "__", snippetType="autosnippet" }, + fmta("_{<>}", { i(1) }) + ), + s({ trig = "!=", snippetType = "autosnippet" }, {t("\\neq")}), + + s({ trig = "==", snippetType = "autosnippet" }, {t("&= \\\\")}), + + s({ trig = "~=", snippetType = "autosnippet" }, {t("\\approx ")}), + + s({ trig = "~~", snippetType = "autosnippet" }, {t("\\sim ")}), + + s({ trig = "->", snippetType = "autosnippet" }, {t("\\to ")}), + + s({ trig = "<->", snippetType = "autosnippet" }, {t("\\leftrightarrow")}), + + s({ trig = "!>", snippetType = "autosnippet" }, {t("\\mapsto ")}), + + s({ trig = ">>", snippetType = "autosnippet" }, {t("\\gg")}), + + s({ trig = "<<", snippetType = "autosnippet" }, {t("\\ll")}), + + s({ trig = "cc", snippetType = "autosnippet" }, {t("\\subset ")}), + + s({ trig = "notin", snippetType = "autosnippet" }, {t("\\not\\in ")}), + + s({ trig = "inn", snippetType = "autosnippet" }, {t("\\in ")}), + + s({ trig = "Nn", snippetType = "autosnippet" }, {t("\\cap ")}), + + s({ trig = "UU", snippetType = "autosnippet" }, {t("\\cup ")}), + --- Debugging additional snippets + s( + { trig = "uuu", snippetType = "autosnippet" }, + fmta("\\bigcup_{<> \\in <>} <>", { + i(1, "i"), + i(2, "I"), + i(0), + }) + ), + s({trig="rond", snippetType="autosnippet"}, + { + t("\\circ"), + }), + s({trig="Brond", snippetType="autosnippet"}, + { + t("\\bigcircs"), + }), + s( + { trig = "Pscal", snippetType = "autosnippet" }, + fmta("\\bigcup_{<> \\in <>} <>", { + i(1, "i"), + i(2, "I"), + i(0), + }) + ), + s({trig="nabl", snippetType="autosnippet"}, + { + t("\\nabla"), + }), + s({trig="partial", snippetType="autosnippet"}, + { + t("\\partial"), + }), + s({trig=";comp", snippetType="autosnippet"}, + { + t("^{c}") + }), + s({trig="//",snippetType="autosnippet"}, + fmta("\\frac{<>}{<>}<>", { + i(1,"a"), + i(2,"b"), + i(0," ") + })), + } diff --git a/lua/custom/plugins/Luasnip/tex/structure.lua b/lua/custom/plugins/Luasnip/tex/structure.lua new file mode 100644 index 00000000000..0b9655934e8 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/structure.lua @@ -0,0 +1,934 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") +local extras = require("luasnip.extras") +local l = extras.lambda +local rep = extras.rep +local p = extras.partial +local m = extras.match +local n = extras.nonempty +local dl = extras.dynamic_lambda +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local conds = require("luasnip.extras.expand_conditions") +local postfix = require("luasnip.extras.postfix").postfix +local types = require("luasnip.util.types") +local parse = require("luasnip.util.parser").parse_snippet +local ms = ls.multi_snippet +local k = require("luasnip.nodes.key_indexer").new_key +-- Visual placeholder + +-- taken from https://ejmastnak.com/ + +local get_visual = function(args, parent, default_text) + if (#parent.snippet.env.LS_SELECT_RAW > 0) then + return sn(nil, i(1,parent.snippet.env.LS_SELECT_RAW)) + else -- If LS_SELECT_RAW is empty, return a blank insert node + return sn(nil, i(1,default_text)) + end +end + +local function v(pos, default_text) + return d(pos, function(args, parent) return get_visual(args, parent, default_text) end) +end + +return { + +-- Document preamble + +s({trig = "doc", name = "Document class"}, + { + c(1, + { + { + t("\\documentclass{"), i(1,"document-class"), t("}") + }, + { + t("\\documentclass["), i(1,"class-options"), t("]{"), i(2,"document-class"), t("}") + } + } + ) + } +), + +s({trig = "pk", name = "Use package"}, + { + c(1, + { + { + t("\\usepackage{"), i(1,"package-name"), t("}") + }, + { + t("\\usepackage["), i(1,"package-options"), t("]{"), i(2,"package-name"), t("}") + } + } + ) + } +), + +s({trig = "tl", name = "Title"}, + { + t("\\title{"), i(1,"..."), t("}") + } +), + +s({trig = "dat", name = "Date"}, + { + t("\\date{"), i(1,"..."), t("}") + } +), + +s({trig = "aut", name = "Author"}, + { + t("\\author{"), i(1,"..."), t("}") + } +), + +s({trig = "td", name = "Today's date"}, + { + t("\\today") + } +), + +s({trig = "bd", name = "Begin document"}, + { + t("\\begin{document}"), + t({"",""}), + t({"",""}), i(1), + t({"",""}), + t({"",""}), t("\\end{document}") + } +), + +-- Sectioning + +s({trig = "scn", name = "Section"}, + { + c(1, + { + { + t("\\section{"), v(1,"title"), t("}") + }, + { + t("\\section*{"), v(1,"title"), t("}") + }, + { + t("\\section["), i(1,"toc-entry"), t("]{"), v(2,"title"), t("}") + } + } + ) + } +), + +s({trig = "sbn", name = "Subection"}, + { + c(1, + { + { + t("\\subsection{"), v(1,"title"), t("}") + }, + { + t("\\subsection*{"), v(1,"title"), t("}") + }, + { + t("\\subsection["), i(1,"toc-entry"), t("]{"), v(2,"title"), t("}") + } + } + ) + } +), + +s({trig = "ssn", name = "Subsubection"}, + { + c(1, + { + { + t("\\subsubsection{"), v(1,"title"), t("}") + }, + { + t("\\subsubsection*{"), v(1,"title"), t("}") + }, + { + t("\\subsubsection["), i(1,"toc-entry"), t("]{"), v(2,"title"), t("}") + } + } + ) + } +), + +s({trig = "chr", name = "Chapter"}, + { + c(1, + { + { + t("\\chapter{"), v(1,"title"), t("}") + }, + { + t("\\chapter*{"), v(1,"title"), t("}") + }, + { + t("\\chapter["), i(1,"toc-entry"), t("]{"), v(2,"title"), t("}") + } + } + ) + } +), + +s({trig = "prt", name = "Part"}, + { + c(1, + { + { + t("\\part{"), i(1,"title"), t("}") + }, + { + t("\\part*{"), i(1,"title"), t("}") + }, + { + t("\\part["), i(1,"toc-entry"), t("]{"), v(2,"title"), t("}") + } + } + ) + } +), + +s({trig = "pr", name = "Paragraph"}, + { + c(1, + { + { + t("\\paragraph{"), i(1,"title"), t("}") + }, + { + t("\\paragraph*{"), i(1,"title"), t("}") + }, + { + t("\\paragraph["), i(1,"toc-entry"), t("]{"), v(2,"title"), t("}") + } + } + ) + } +), + +s({trig = "sbp", name = "Subaragraph"}, + { + c(1, + { + { + t("\\subparagraph{"), i(1,"title"), t("}") + }, + { + t("\\subparagraph*{"), i(1,"title"), t("}") + }, + { + t("\\subparagraph["), i(1,"toc-entry"), t("]{"), v(2,"title"), t("}") + } + } + ) + } +), + +s({trig = "phs", name = "Hyperref jump to correct page"}, + { + t("\\phantomsection") + } +), + +s({trig = "add", name = "Add entry to list"}, + { + t("\\addcontentsline{"), i(1,"file"), t("}{"), i(2,"sec-unit"), t("}{"), i(3,"list-entry"), t("}") + } +), + +s({trig = "mkb", name = "Headers in twoside mode"}, + { + t("\\markboth{"), i(1,"left"), t("}{"), i(2,"right"), t("}") + } +), + +s({trig = "mkt", name = "Maketitle"}, + { + t("\\maketitle") + } +), + +s({trig = "toc", name = "Table of contents"}, + { + t("\\tableofcontents") + } +), + +s({trig = "lot", name = "List of tables"}, + { + t("\\listoftables") + } +), + +s({trig = "lof", name = "List of figures"}, + { + t("\\listoffigures") + } +), + +s({trig = "mki", name = "Makeindex"}, + { + t("\\makeindex") + } +), + +s({trig = "pix", name = "Print index"}, + { + t("\\printindex") + } +), + +s({trig = "pdf", name = "PDF bookmark"}, + { + t("\\texorpdfstring{"), v(1,"tex"), t("}{"), i(2,"bookmark"), t("}") + } +), + +s({trig = "lec", name = "Lecture section"}, + { + t("%%% "), v(1,"title"), + t({"",""}), t("\\seclecture{"), rep(1), t("}{"), i(2,"date"), t("}") + } +), + +s({trig = "les", name = "Lecture subsection"}, + { + t("%%% "), v(1,"title"), + t({"",""}), t("\\sublecture{"), rep(1), t("}{"), i(2,"date"), t("}") + } +), + +s({trig = "date", name = "Print current date"}, + { + f(function() return os.date("%a %d %b %y") end) + } +), + +s({trig = "tim", name = "Margin paragraph timestamp"}, + { + t("\\marginpar{\\footnotesize\\textsf{\\mbox{"), i(1,"date"), t("}}}") + } +), + +-- Cross-references + +-- Labels + +s({trig = "lge", name = "Generic label"}, + { + t("\\label{"), i(1,"key"), t("}") + } +), + +s({trig = "lsn", name = "Label section"}, + { + t("\\label{sec:"), i(1,"key"), t("}") + } +), + +s({trig = "lsb", name = "Label subsection"}, + { + t("\\label{sub:"), i(1,"key"), t("}") + } +), + +s({trig = "lss", name = "Label subsubsection"}, + { + t("\\label{ssub:"), i(1,"key"), t("}") + } +), + +s({trig = "lch", name = "Label chapter"}, + { + t("\\label{ch:"), i(1,"key"), t("}") + } +), + +s({trig = "lpa", name = "Label paragraph"}, + { + t("\\label{par:"), i(1,"key"), t("}") + } +), + +s({trig = "lsp", name = "Label subparagraph"}, + { + t("\\label{subpar:"), i(1,"key"), t("}") + } +), + +s({trig = "lbe", name = "Label equation"}, + { + t("\\label{eq:"), i(1,"key"), t("}") + } +), + +s({trig = "lbt", name = "Label theorem"}, + { + t("\\label{thm:"), i(1,"key"), t("}") + } +), + +s({trig = "lps", name = "Label proposition"}, + { + t("\\label{prop:"), i(1,"key"), t("}") + } +), + +s({trig = "lle", name = "Label lemma"}, + { + t("\\label{lem:"), i(1,"key"), t("}") + } +), + +s({trig = "lco", name = "Label corollary"}, + { + t("\\label{cor:"), i(1,"key"), t("}") + } +), + +s({trig = "lde", name = "Label definition"}, + { + t("\\label{def:"), i(1,"key"), t("}") + } +), + +s({trig = "lre", name = "Label remark"}, + { + t("\\label{rem:"), i(1,"key"), t("}") + } +), + +s({trig = "lex", name = "Label exercise"}, + { + t("\\label{ex:"), i(1,"key"), t("}") + } +), + +s({trig = "leg", name = "Label example"}, + { + t("\\label{eg:"), i(1,"key"), t("}") + } +), + +s({trig = "lpn", name = "Label principle"}, + { + t("\\label{princ:"), i(1,"key"), t("}") + } +), + +s({trig = "lbi", name = "Label item"}, + { + t("\\label{it:"), i(1,"key"), t("}") + } +), + +s({trig = "lfg", name = "Label figure"}, + { + t("\\label{fig:"), i(1,"key"), t("}") + } +), + +s({trig = "lta", name = "Label table"}, + { + t("\\label{tbl:"), i(1,"key"), t("}") + } +), + +-- Reference commands + +s({trig = "rge", name = "Generic cross-reference"}, + { + c(1, + { + { + t("\\ref{"), i(1,"key"), t("}") + }, + { + t("\\cref{"), i(1,"key"), t("}") + }, + { + t("\\Cref{"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rsn", name = "Reference section"}, + { + c(1, + { + { + t("\\ref{sec:"), i(1,"key"), t("}") + }, + { + t("\\cref{sec:"), i(1,"key"), t("}") + }, + { + t("\\Cref{sec:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rsb", name = "Reference subsection"}, + { + c(1, + { + { + t("\\ref{sub:"), i(1,"key"), t("}") + }, + { + t("\\cref{sub:"), i(1,"key"), t("}") + }, + { + t("\\Cref{sub:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rss", name = "Reference subsubsection"}, + { + c(1, + { + { + t("\\ref{ssub:"), i(1,"key"), t("}") + }, + { + t("\\cref{ssub:"), i(1,"key"), t("}") + }, + { + t("\\Cref{ssub:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rch", name = "Reference chapter"}, + { + c(1, + { + { + t("\\ref{ch:"), i(1,"key"), t("}") + }, + { + t("\\cref{ch:"), i(1,"key"), t("}") + }, + { + t("\\Cref{ch:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rpa", name = "Reference paragraph"}, + { + c(1, + { + { + t("\\ref{par:"), i(1,"key"), t("}") + }, + { + t("\\cref{par:"), i(1,"key"), t("}") + }, + { + t("\\Cref{par:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rsp", name = "Reference subparagraph"}, + { + c(1, + { + { + t("\\ref{subpar:"), i(1,"key"), t("}") + }, + { + t("\\cref{subpar:"), i(1,"key"), t("}") + }, + { + t("\\Cref{subpar:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rfe", name = "Reference equation"}, + { + c(1, + { + { + t("\\eqref{eq:"), i(1,"key"), t("}") + }, + { + t("\\cref{eq:"), i(1,"key"), t("}") + }, + { + t("\\Cref{eq:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rft", name = "Reference theorem"}, + { + c(1, + { + { + t("\\ref{thm:"), i(1,"key"), t("}") + }, + { + t("\\cref{thm:"), i(1,"key"), t("}") + }, + { + t("\\Cref{thm:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rps", name = "Reference proposition"}, + { + c(1, + { + { + t("\\ref{prop:"), i(1,"key"), t("}") + }, + { + t("\\cref{prop:"), i(1,"key"), t("}") + }, + { + t("\\Cref{prop:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rle", name = "Reference lemma"}, + { + c(1, + { + { + t("\\ref{lem:"), i(1,"key"), t("}") + }, + { + t("\\cref{lem:"), i(1,"key"), t("}") + }, + { + t("\\Cref{lem:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rco", name = "Reference corollary"}, + { + c(1, + { + { + t("\\ref{cor:"), i(1,"key"), t("}") + }, + { + t("\\cref{cor:"), i(1,"key"), t("}") + }, + { + t("\\Cref{cor:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rde", name = "Reference definition"}, + { + c(1, + { + { + t("\\ref{def:"), i(1,"key"), t("}") + }, + { + t("\\cref{def:"), i(1,"key"), t("}") + }, + { + t("\\Cref{def:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rre", name = "Reference remark"}, + { + c(1, + { + { + t("\\ref{rem:"), i(1,"key"), t("}") + }, + { + t("\\cref{rem:"), i(1,"key"), t("}") + }, + { + t("\\Cref{rem:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rex", name = "Reference exercise"}, + { + c(1, + { + { + t("\\ref{ex:"), i(1,"key"), t("}") + }, + { + t("\\cref{ex:"), i(1,"key"), t("}") + }, + { + t("\\Cref{ex:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "reg", name = "Reference example"}, + { + c(1, + { + { + t("\\ref{eg:"), i(1,"key"), t("}") + }, + { + t("\\cref{eg:"), i(1,"key"), t("}") + }, + { + t("\\Cref{eg:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rpn", name = "Reference principle"}, + { + c(1, + { + { + t("\\ref{princ:"), i(1,"key"), t("}") + }, + { + t("\\cref{princ:"), i(1,"key"), t("}") + }, + { + t("\\Cref{princ:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rfi", name = "Reference item"}, + { + c(1, + { + { + t("\\ref{it:"), i(1,"key"), t("}") + }, + { + t("\\cref{it:"), i(1,"key"), t("}") + }, + { + t("\\Cref{it:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rfg", name = "Reference figure"}, + { + c(1, + { + { + t("\\ref{fig:"), i(1,"key"), t("}") + }, + { + t("\\cref{fig:"), i(1,"key"), t("}") + }, + { + t("\\Cref{fig:"), i(1,"key"), t("}") + } + } + ) + } +), + +s({trig = "rta", name = "Reference table"}, + { + c(1, + { + { + t("\\ref{tbl:"), i(1,"key"), t("}") + }, + { + t("\\cref{tbl:"), i(1,"key"), t("}") + }, + { + t("\\Cref{tbl:"), i(1,"key"), t("}") + } + } + ) + } +), + +-- Page reference commands + +s({trig = "pge", name = "Generic page reference"}, + { + t("\\pageref{"), i(1,"key"), t("}") + } +), + +s({trig = "psn", name = "Page of section"}, + { + t("\\pageref{sec:"), i(1,"key"), t("}") + } +), + +s({trig = "psb", name = "Page of subsection"}, + { + t("\\pageref{sub:"), i(1,"key"), t("}") + } +), + +s({trig = "pss", name = "Page of subsubsection"}, + { + t("\\pageref{ssub:"), i(1,"key"), t("}") + } +), + +s({trig = "pch", name = "Page of chapter"}, + { + t("\\pageref{ch:"), i(1,"key"), t("}") + } +), + +s({trig = "ppa", name = "Page of paragraph"}, + { + t("\\pageref{par:"), i(1,"key"), t("}") + } +), + +s({trig = "psp", name = "Page of subparagraph"}, + { + t("\\pageref{subpar:"), i(1,"key"), t("}") + } +), + +s({trig = "peq", name = "Page of equation"}, + { + t("\\eqref{eq:"), i(1,"key"), t("}") + } +), + +s({trig = "pgt", name = "Page of theorem"}, + { + t("\\pageref{thm:"), i(1,"key"), t("}") + } +), + +s({trig = "pps", name = "Page of proposition"}, + { + t("\\pageref{prop:"), i(1,"key"), t("}") + } +), + +s({trig = "ple", name = "Page of lemma"}, + { + t("\\pageref{lem:"), i(1,"key"), t("}") + } +), + +s({trig = "pco", name = "Page of corollary"}, + { + t("\\pageref{cor:"), i(1,"key"), t("}") + } +), + +s({trig = "pde", name = "Page of definition"}, + { + t("\\pageref{def:"), i(1,"key"), t("}") + } +), + +s({trig = "pre", name = "Page of remark"}, + { + t("\\pageref{rem:"), i(1,"key"), t("}") + } +), + +s({trig = "pex", name = "Page of exercise"}, + { + t("\\pageref{ex:"), i(1,"key"), t("}") + } +), + +s({trig = "peg", name = "Page of example"}, + { + t("\\pageref{eg:"), i(1,"key"), t("}") + } +), + +s({trig = "ppn", name = "Page of principle"}, + { + t("\\pageref{princ:"), i(1,"key"), t("}") + } +), + +s({trig = "pgi", name = "Page of item"}, + { + t("\\pageref{it:"), i(1,"key"), t("}") + } +), + +s({trig = "pfg", name = "Page of figure"}, + { + t("\\pageref{fig:"), i(1,"key"), t("}") + } +), + +s({trig = "pta", name = "Page of table"}, + { + t("\\pageref{tbl:"), i(1,"key"), t("}") + } +), + +} diff --git a/lua/custom/plugins/Luasnip/tex/symbols.lua b/lua/custom/plugins/Luasnip/tex/symbols.lua new file mode 100644 index 00000000000..2e4de31d0f6 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/symbols.lua @@ -0,0 +1,217 @@ +local ls = require("luasnip") +local s = ls.snippet +local sn = ls.snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local d = ls.dynamic_node +local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta +local rep = require("luasnip.extras").rep + + +return { + -- Common symbols + s({trig="ooo", snippetType="autosnippet"}, + { + t("\\infty"), + } + ), + s({trig="+-", snippetType="autosnippet"}, + { + t("\\pm"), + } + ), + --[[ + s({trig="pm", snippetType="autosnippet"}, + { + t("\\pm"), + }), + ]]-- + s({trig="-+", snippetType="autosnippet"}, + { + t("\\mp"), + }), + s({trig="mp", snippetType="autosnippet"}, + { + t("\\mp"), + }), + s({trig="->", snippetType="autosnippet"}, + { + t("\\to"), + }), + s({trig="!>", snippetType="autosnippet"}, + { + t("\\mapsto"), + }), + s({trig="invs", snippetType="autosnippet"}, + { + t("^{-1}"), + }), + s({trig="and", snippetType="autosnippet"}, + { + t("\\cap"), + }), + s({trig="orr", snippetType="autosnippet"}, + { + t("\\cup"), + }), + s({trig="inn", snippetType="autosnippet"}, + { + t("\\in"), + }), + s({trig="notin", snippetType="autosnippet"}, + { + t("\\not\\in"), + }), + s({trig="eset", snippetType="autosnippet"}, + { + t("\\emptyset"), + }), + s({trig="=>", snippetType="autosnippet"}, + { + t("\\implies"), + }), + s({trig="=<", snippetType="autosnippet"}, + { + t("\\impliedby"), + }), + s({trig="iff", snippetType="autosnippet"}, + { + t("\\iff"), + }), + s({trig="exists", snippetType="autosnippet"}, + { + t("\\exists"), + }), + s({trig="ortho", snippetType="autosnippet"}, + { + t("\\perp"), + }), + + + + -- Set notation + + s({trig="NN", snippetType="autosnippet"}, + { + t("\\mathbb{N}"), + }), + s({trig="ZZ", snippetType="autosnippet"}, + { + t("\\mathbb{Z}"), + }), + s({trig="QQ", snippetType="autosnippet"}, + { + t("\\mathbb{Q}"), + }), + s({trig="II1", snippetType="autosnippet"}, + { + t("\\mathbb{1}"), + }), + s({trig="III", snippetType="autosnippet"}, + { + t("\\mathcal{I}"), + }), + s({trig="RR", snippetType="autosnippet"}, + { + t("\\mathbb{R}"), + }), + s({trig="QQ", snippetType="autosnippet"}, + { + t("\\mathbb{Q}"), + }), + s({trig="MnnR", snippetType="autosnippet"}, + { + t("\\mathcal{M}_{n}(\\mathbb{R})"), + }), + s({trig="Mn1R", snippetType="autosnippet"}, + { + t("\\mathcal{M}_{n,1}(\\mathbb{R})"), + }), + s({trig="KK", snippetType="autosnippet"}, + { + t("\\mathbb{K}"), + }), + s({trig="CC", snippetType="autosnippet"}, + { + t("\\mathbb{C}"), + }), + + + s({trig="norm", snippetType="autosnippet"}, + fmta("\\lvert <> \\rvert <>",{ i(1,"u"), i(0) })), + + s({trig="pentiere", snippetType="autosnippet"}, + fmta("\\lfloor <> \\floor <>",{ i(1, "n"), i(0) })), + + s({trig="mcal", snippetType="autosnippet"}, + fmta("\\mathcal{<>} <>",{ i(1, "I"), i(0) })), + + s({trig="mbb", snippetType="autosnippet"}, + fmta("\\mathbb{<>} <>",{ i(1, "I"), i(0) })), + + + + s({trig="norm", snippetType="autosnippet"}, + {fmt("\\lvert {} \\rvert",{ i(1) }) + }), + + s({trig="pentiere", snippetType="autosnippet"}, + fmt("\\lfloor {} \\rfloor",{ i(1) })), + + + + s({ trig = 'mcal', snippetType="autosnippet" }, + {fmta('\\mathcal{<>}<>', { + i(1), + i(0),}) + }), + + s({ trig = 'mbb', snippetType="autosnippet" }, + {fmta('\\mathbb{<>}<>', { + i(1), + i(0),}) + }), + + + + s({trig="etoile", snippetType="autosnippet"}, + { + t("\\ast"), + }), + + + s({trig="xnn", snippetType="autosnippet"}, + { + t("x_{n}"), + }), + + -- Common Variable Notations + + s({ trig = 'ynn', snippetType="autosnippet" }, {t('y_{n}')}), + + s({ trig = 'xii', snippetType="autosnippet" }, {t('x_{i}')}), + + s({ trig = 'yii', snippetType="autosnippet" }, {t('y_{i}')} ), + + s({ trig = 'xjj', snippetType="autosnippet" }, {t('x_{j}')} ), + + s({ trig = 'yjj', snippetType="autosnippet" }, {t('y_{j}')} ), + + s({ trig = 'xp1', snippetType="autosnippet" }, {t('x_{n+1}')} ), + + s({ trig = 'xmm', snippetType="autosnippet" }, {t('x_{m}')} ), + + s({ trig = ';adh', snippetType="autosnippet" }, + fmta('\\overset{\\circ}{<>}<>', { + i(1), + i(0),}) + ), + s({ trig = ';int', snippetType="autosnippet" }, + fmta('\\overline{<>}<>', { + i(1), + i(0),}) + ), + +} diff --git a/lua/custom/plugins/Luasnip/tex/template.lua b/lua/custom/plugins/Luasnip/tex/template.lua new file mode 100644 index 00000000000..8b67d0f274a --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/template.lua @@ -0,0 +1,61 @@ +local ls = require("luasnip") +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node +local fmta = require("luasnip.extras.fmt").fmta + +-- Template pour un document LaTeX + return { + s({trig="textemplate",snippetType="autosnippet"}, fmta([[ +\documentclass[a4paper]{article} + +% Packages pour les mathématiques et la langue française +\usepackage{amsmath, amssymb, amsfonts, amsthm} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[french]{babel} +\setlength{\parindent}{0pt} % Pas d'indentation en début de paragraphe + +% Définitions des environnements pour les théorèmes, définitions, etc. +\newtheorem{definition}{Définition} +\newtheorem{proposition}{Proposition} + +\title{<>} +\author{<>} +\date{\today} + +\begin{document} + +\maketitle % Génère le titre + +\tableofcontents % Génère la table des matières + +\section{<>} + +\begin{definition}[<>] + \vspace{5pt} + <> +\end{definition} + +\begin{proposition} + \vspace{5pt} + <> +\end{proposition} + +\begin{proof} + \vspace{5pt} + <> +\end{proof} + +\end{document} +]], { + i(1, "Titre du document"), -- Titre du document + i(2, "Ton Nom"), -- Auteur + i(3, "Titre de la section"), -- Titre de la première section + i(4, "Nom de la définition"), -- Nom de la définition + i(5, "Contenu de la définition"), -- Contenu de la définition + i(6, "Contenu de la proposition"), -- Contenu de la proposition + i(7, "Contenu de la preuve"), -- Contenu de la preuve + })), +} + diff --git a/lua/custom/plugins/auto-session.lua b/lua/custom/plugins/auto-session.lua new file mode 100644 index 00000000000..14464fcf15c --- /dev/null +++ b/lua/custom/plugins/auto-session.lua @@ -0,0 +1,6 @@ +return { + "rmagatti/auto-session", + config = function() + require("auto-session").setup() + end, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..8d6d9d96ed7 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,34 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return {{ + "lervag/vimtex", + lazy = false, -- we don't want to lazy load VimTeX + -- tag = "v2.15", -- uncomment to pin to a specific release + init = function() + -- VimTeX configuration goes here, e.g. + vim.g.vimtex_view_method = "zathura" + end +}, +{"windwp/nvim-autopairs", + event = "InsertEnter", + config = true +}, +{ + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = "cd app && yarn install", + init = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, +} +--[[ +"iurimateus/luasnip-latex-snippets.nvim", + config = function() + require'luasnip-latex-snippets'.setup({use_treesitter=false}) + -- or setup({ use_treesitter = true }) + require("luasnip").config.setup({ enable_autosnippets = true }) + end, + +} ]]}