From e711158bb790bdcb6634df9521c880e9eb0c1d6b Mon Sep 17 00:00:00 2001 From: Nanderty Date: Sun, 24 Nov 2024 16:45:51 +0100 Subject: Snippet improvements --- lua/Snippets/luasniphelperslatex.lua | 4 ++ lua/Snippets/tex/figures.lua | 27 +++++++++-- lua/Snippets/tex/general.lua | 2 +- lua/Snippets/tex/greek.lua | 2 +- lua/Snippets/tex/math.lua | 90 ++++++++++++++++++++++++++++++------ lua/Snippets/tex/postfix.lua | 4 +- lua/Snippets/tex/schemes.lua | 12 +++-- lua/Snippets/tex/tables.lua | 30 ++++++++++++ 8 files changed, 145 insertions(+), 26 deletions(-) diff --git a/lua/Snippets/luasniphelperslatex.lua b/lua/Snippets/luasniphelperslatex.lua index e5e3458..97abaee 100644 --- a/lua/Snippets/luasniphelperslatex.lua +++ b/lua/Snippets/luasniphelperslatex.lua @@ -29,4 +29,8 @@ tex.in_scheme = function() return tex.in_env('scheme') end +tex.in_table = function() + return tex.in_env('table') +end + return tex diff --git a/lua/Snippets/tex/figures.lua b/lua/Snippets/tex/figures.lua index e2fddd5..32def02 100644 --- a/lua/Snippets/tex/figures.lua +++ b/lua/Snippets/tex/figures.lua @@ -3,7 +3,27 @@ local helper = require('Snippets.luasniphelpers') return { - + s({ trig = 'tikzfig', snippetType = 'autosnippet' }, + fmta( + [[ +\begin{figure}[!h] + \centering + \begin{tikzpicture} + <> + \end{tikzpicture} + \caption{<> + } + \label{fig:<>} +\end{figure} +]], + { + i(1), + i(2), + i(3), + } + ), + { condition = helper.line_begin } + ), s({ trig = 'imfig', snippetType = 'autosnippet' }, fmta( @@ -33,10 +53,7 @@ return { [[ \begin{figure}[!h] \centering - \resizebox - {<>} - {!} - {\input{<>}} + {\includegraphics[<>]{<>}} \caption{<> } \label{fig:<>} diff --git a/lua/Snippets/tex/general.lua b/lua/Snippets/tex/general.lua index 39025f4..0aaca6d 100644 --- a/lua/Snippets/tex/general.lua +++ b/lua/Snippets/tex/general.lua @@ -63,7 +63,7 @@ return { ) ), - s({ trig = 'snr', snippetType = 'autosnippet' }, + s({ trig = 'nmb', snippetType = 'autosnippet' }, fmta( '\\num{<>}', { diff --git a/lua/Snippets/tex/greek.lua b/lua/Snippets/tex/greek.lua index b2d076e..42b9207 100644 --- a/lua/Snippets/tex/greek.lua +++ b/lua/Snippets/tex/greek.lua @@ -68,7 +68,7 @@ return { s({ trig = 'zet', snippetType = 'autosnippet' }, { - t('\\Zeta '), + t('\\zeta '), }, { condition = tex.in_mathzone } ), diff --git a/lua/Snippets/tex/math.lua b/lua/Snippets/tex/math.lua index ddaf2a2..33903a6 100644 --- a/lua/Snippets/tex/math.lua +++ b/lua/Snippets/tex/math.lua @@ -65,13 +65,11 @@ return { { condition = tex.in_mathzone } ), - s({ trig = 'hhn', snippetType = 'autosnippet' }, - fmta( - '\\num{<>}', - { - i(1), - } - ) + s({ trig = 'prt', snippetType = 'autosnippet' }, + { + t('\\partial ') + }, + { condition = tex.in_mathzone } ), s({ trig = 'mcl', snippetType = 'autosnippet' }, @@ -102,6 +100,17 @@ return { ), { condition = tex.in_mathzone } ), + + s({ trig = "tld", snippetType = "autosnippet" }, + fmta( + '\\tilde{<>}', + { + i(1), + } + ), + { condition = tex.in_mathzone } + ), + s({ trig = "vrl", snippetType = "autosnippet" }, fmta( '\\overline{<>}', @@ -112,6 +121,26 @@ return { { condition = tex.in_mathzone } ), + s({ trig = "bar", snippetType = "autosnippet" }, + fmta( + '\\bar{<>}', + { + i(1), + } + ), + { condition = tex.in_mathzone } + ), + + s({ trig = "bsl", snippetType = "autosnippet" }, + fmta( + '\\boldsymbol{<>}', + { + i(1), + } + ), + { condition = tex.in_mathzone } + ), + s({ trig = 'ΓΆΓΆ', snippetType = 'autosnippet' }, fmta( '^{<>}', @@ -174,9 +203,9 @@ return { { condition = tex.in_mathzone } ), - s({ trig = 'str', snippetType = 'autosnippet' }, + s({ trig = 'dgg', snippetType = 'autosnippet' }, { - t('\\star '), + t('\\dagger '), }, { condition = tex.in_mathzone } ), @@ -230,7 +259,7 @@ return { { condition = tex.in_mathzone } ), - s({ trig = "det", snippetType = "autosnippet" }, + s({ trig = "dets", snippetType = "autosnippet" }, fmta( '\\det{(<>)}', { @@ -240,6 +269,30 @@ return { { condition = tex.in_mathzone } ), + s({ trig = "detm", snippetType = "autosnippet" }, + fmta([[\det{\begin{vmatrix} + <> +\end{vmatrix}} +]], + { + i(1), + } + ), + { condition = tex.in_mathzone } + ), + + s({ trig = "mtrx", snippetType = "autosnippet" }, + fmta([[\begin{pmatrix} + <> +\end{pmatrix} +]], + { + i(1), + } + ), + { condition = tex.in_mathzone } + ), + s({ trig = "ln", snippetType = "autosnippet" }, fmta( '\\ln{(<>)}', @@ -252,7 +305,7 @@ return { s({ trig = "exp", snippetType = "autosnippet" }, fmta( - 'e^{<>}', + '\\exp\\left(<>\\right)', { i(1), } @@ -262,7 +315,7 @@ return { s({ trig = "bra", snippetType = "autosnippet" }, fmta( - '\\Bra{<>}', + '\\left\\langle <>\\right|', { i(1), } @@ -272,9 +325,20 @@ return { s({ trig = "ket", snippetType = "autosnippet" }, fmta( - '\\Ket{<>}', + '\\left| <>\\right\\rangle', + { + i(1), + } + ), + { condition = tex.in_mathzone } + ), + + s({ trig = "brkt", snippetType = "autosnippet" }, + fmta( + '\\left\\langle <>\\middle| <>\\right\\rangle', { i(1), + i(2), } ), { condition = tex.in_mathzone } diff --git a/lua/Snippets/tex/postfix.lua b/lua/Snippets/tex/postfix.lua index 54b09a5..fafd78e 100644 --- a/lua/Snippets/tex/postfix.lua +++ b/lua/Snippets/tex/postfix.lua @@ -2,7 +2,7 @@ local helper = require('Snippets.luasniphelpers') return { - s({ trig = 'bgn', snippetType = 'autosnippet' }, + s({ trig = 'lsls', snippetType = 'autosnippet' }, fmta( [[ \lstinputlisting[ @@ -11,7 +11,7 @@ return { caption = { <> }, - label = <>, + label = lst:<>, ]{<>} ]], { diff --git a/lua/Snippets/tex/schemes.lua b/lua/Snippets/tex/schemes.lua index 5a726be..3841bff 100644 --- a/lua/Snippets/tex/schemes.lua +++ b/lua/Snippets/tex/schemes.lua @@ -7,9 +7,11 @@ return { [[ \begin{scheme}[!h] \centering - \chemfig { - <> - } + \chemname { + \chemfig { + <> + } + }{<>} \caption{<> } \label{sch:<>} @@ -19,6 +21,7 @@ return { i(1), i(2), i(3), + i(4), } ), { condition = helper.line_begin } @@ -34,7 +37,7 @@ return { \chemfig { <> } - }{} + }{<>} \schemestop \caption{<> } @@ -45,6 +48,7 @@ return { i(1), i(2), i(3), + i(4), } ), { condition = helper.line_begin } diff --git a/lua/Snippets/tex/tables.lua b/lua/Snippets/tex/tables.lua index fb768f7..72bfd9f 100644 --- a/lua/Snippets/tex/tables.lua +++ b/lua/Snippets/tex/tables.lua @@ -48,4 +48,34 @@ return { { condition = helper.line_begin } ), + s({ trig = "mcl", snippetType = "autosnippet" }, + fmta( + '\\multicolumn{<>}{<>}{<>}', + { + i(1), + i(2), + i(3), + } + ), + { condition = tex.in_table } + ), + + s({ trig = "cln", snippetType = "autosnippet" }, + fmta( + '\\cline{<>-<>}', + { + i(1), + i(2), + } + ), + { condition = tex.in_table } + ), + + s({ trig = 'hln', snippetType = 'autosnippet' }, + { + t('\\hline'), + }, + { condition = tex.in_table } + ), + } -- cgit v1.2.3