diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 005b535b..00000000 --- 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 08717d53..1b76641f 100644 --- a/init.lua +++ b/init.lua @@ -271,7 +271,7 @@ require('lazy').setup({ -- after the plugin has been loaded: -- config = function() ... end - { -- 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 = { @@ -314,7 +314,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' }, @@ -354,7 +354,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 @@ -450,7 +450,7 @@ require('lazy').setup({ }, }, }, - { 'Bilal2453/luvit-meta', lazy = true }, + { 'Bilal2453/luvit-meta', lazy = true }, { -- Main LSP Configuration 'neovim/nvim-lspconfig', @@ -462,7 +462,7 @@ require('lazy').setup({ -- Useful status updates for LSP. -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` - { 'j-hui/fidget.nvim', opts = {} }, + { 'j-hui/fidget.nvim', opts = {} }, -- Allows extra capabilities provided by nvim-cmp 'hrsh7th/cmp-nvim-lsp', @@ -738,12 +738,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', @@ -758,7 +758,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 = { @@ -845,7 +845,7 @@ 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' @@ -903,10 +903,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' } }, }, @@ -938,7 +939,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! @@ -968,3 +969,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 00000000..f593aaf4 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,30 @@ +{ + "LuaSnip": { "branch": "master", "commit": "659c4479529a05cc9b05ef762639a09d366cc690" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" }, + "fidget.nvim": { "branch": "main", "commit": "e2a175c2abe2d4f65357da1c98c59a5cfb2b543f" }, + "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "gitsigns.nvim": { "branch": "main", "commit": "9521fe8be39255b9abc6ec54e352bf04c410f5cf" }, + "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "lazydev.nvim": { "branch": "main", "commit": "d5800897d9180cea800023f2429bce0a94ed6064" }, + "luasnip-latex-snippets.nvim": { "branch": "main", "commit": "4b91f28d91979f61a3e8aef1cee5b7c7f2c7beb8" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, + "mini.nvim": { "branch": "main", "commit": "7b4d5d48b6b5a75009d63f8f3e4ef4819b7e8139" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, + "nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" }, + "nvim-treesitter": { "branch": "master", "commit": "e1e3108cd23d7f967842261bd66126b6734d8907" }, + "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": "9758827c3b380ba89da4a2212b6255d01afbcf08" }, + "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 00000000..934474fc --- /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 00000000..9b4ff22f --- /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.bak b/lua/custom/plugins/Luasnip/tex/delimiters.lua.bak new file mode 100644 index 00000000..a79af077 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/delimiters.lua.bak @@ -0,0 +1,142 @@ +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 +ls.add_snippets("tex", { + -- LaTeX Template + s("latex-template", fmt([[ + \documentclass[a4paper]{article} + + \usepackage{amsmath} + + \begin{document} + {} + \end{document} + ]], { i(0) })), + + -- Implies + s("=>", t("\\implies")), + + -- Inline Math + s("mk", fmt("${}$", { i(1) })), + + -- Fraction with auto-expansion for a/b pattern + s("////", fmt("\\frac{{{}}}{{{}}}", { i(1), i(2) })), + s({ trig = "(%w+)/(%w+)", regTrig = true, wordTrig = false }, { + f(function(_, snip) return "\\frac{" .. snip.captures[1] .. "}{" .. snip.captures[2] .. "}" end) + }), + + -- Not Equals + s("!=", t("\\neq")), + + -- Sum + s("sum", fmt("\\sum_{{n={}}}^{{{}}} {}", { i(1, "1"), i(2, "\\infty"), i(3, "a_n z^n") })), + + -- Taylor Series + s("taylor", fmt("\\sum_{{{}={}}}^{{{}}} {} (x-a)^{}", { i(1, "k"), i(2, "0"), i(3, "\\infty"), i(4, "c_"), i(1) })), + + -- Limit + s("lim", fmt("\\lim_{{{} \\to {}}}", { i(1, "n"), i(2, "\\infty") })), + + -- 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("xx", t("\\times")), + 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/greek_letters.lua b/lua/custom/plugins/Luasnip/tex/greek_letters.lua new file mode 100644 index 00000000..c350b5a7 --- /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 00000000..9639aba3 --- /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.bak b/lua/custom/plugins/Luasnip/tex/math.lua.bak new file mode 100644 index 00000000..8bda4014 --- /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 00000000..e69de29b diff --git a/lua/custom/plugins/Luasnip/tex/symbols.lua b/lua/custom/plugins/Luasnip/tex/symbols.lua new file mode 100644 index 00000000..9e294274 --- /dev/null +++ b/lua/custom/plugins/Luasnip/tex/symbols.lua @@ -0,0 +1,141 @@ +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"), + }), + + -- 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}"), + }), + -- Delimiters + s({trig="norm", snippetType="autosnippet"}, + fmt("\\lvert {} \\rvert",{ i(1) }) + ), + s({trig="pentiere", snippetType="autosnippet"}, + fmt("\\lfloor {} \\rfloor",{ i(1) }) + ), + + +} \ No newline at end of file diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..17e04476 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,21 @@ -- 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 +}, +--[[ { +"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, + +} ]]}