diff options
author | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2023-08-26 23:42:21 +0200 |
commit | 3f600ab07dbad3b6dd7655587ddea158b19aea71 (patch) | |
tree | 7164ccd965e1d14ade970aeb8eb188b1442a6c91 /home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets | |
parent | Style(treewide): Format all lua-files makes lua ➛ nix easier (diff) | |
download | nixos-config-3f600ab07dbad3b6dd7655587ddea158b19aea71.zip |
Refactor(treewide): Abbreviate path names
Diffstat (limited to 'home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets')
4 files changed, 0 insertions, 239 deletions
diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/all.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/all.lua deleted file mode 100644 index 5ce91a87..00000000 --- a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/all.lua +++ /dev/null @@ -1,60 +0,0 @@ -local get_visual = function(args, parent) - if #parent.snippet.env.SELECT_RAW > 0 then - return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) - else - return sn(nil, i(1, "")) - end -end -local function char_count_same(c1, c2) - local line = vim.api.nvim_get_current_line() - -- '%'-escape chars to force explicit match (gsub accepts patterns). - -- second return value is number of substitutions. - local _, ct1 = string.gsub(line, "%" .. c1, "") - local _, ct2 = string.gsub(line, "%" .. c2, "") - return ct1 == ct2 -end - -local function even_count(c) - local line = vim.api.nvim_get_current_line() - local _, ct = string.gsub(line, c, "") - return ct % 2 == 0 -end - -local function neg(fn, ...) - return not fn(...) -end - -local function part(fn, ...) - local args = { ...; } - return function() - return fn(unpack(args)) - end -end - --- This makes creation of pair-type snippets easier. -local function pair(pair_begin, pair_end, expand_func, ...) - -- triggerd by opening part of pair, wordTrig=false to trigger anywhere. - -- ... is used to pass any args following the expand_func to it. - return s( - { trig = pair_begin; wordTrig = false; snippetType = "autosnippet"; }, - { t({ pair_begin; }); d(1, get_visual); t({ pair_end; }); }, - { condition = part(expand_func, part(..., pair_begin, pair_end)); } - ) -end - -local maybe = { pair = nil; } -if vim.bo.filetype == "tex" then - maybe.pair = pair("<", ">", neg, char_count_same) -end - -local output_table = { - pair("(", ")", neg, char_count_same); - pair("{", "}", neg, char_count_same); - pair("[", "]", neg, char_count_same); - pair("'", "'", neg, even_count); - pair('"', '"', neg, even_count); - pair("`", "`", neg, even_count); -} -output_table[#output_table + 1] = maybe.pair - -return output_table diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/html.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/html.lua deleted file mode 100644 index c467dd68..00000000 --- a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/html/html.lua +++ /dev/null @@ -1,108 +0,0 @@ -local get_visual = function(args, parent) - if #parent.snippet.env.SELECT_RAW > 0 then - return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) - else - return sn(nil, i(1)) - end -end - -local line_begin = require("luasnip.extras.expand_conditions").line_begin - -return { - -- HEADER - s( - { - trig = "h([123456])"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; - }, - fmt( - [[ - <h{}>{}</h{}> - ]], - { - f(function(_, snip) - return snip.captures[1] - end); - d(1, get_visual); - f(function(_, snip) - return snip.captures[1] - end); - } - ), - { condition = line_begin; } - ); -- PARAGRAPH - s( - { trig = "pp"; snippetType = "autosnippet"; }, - fmt( - [[ - <p>{}</p> - ]], - { d(1, get_visual); } - ), - { condition = line_begin; } - ); -- UNORDERED LIST - s( - { trig = "itt"; snippetType = "autosnippet"; }, - fmt( - [[ - <ul> - <li>{}</li>{} - </ul> - ]], - { i(1); i(0); } - ), - { condition = line_begin; } - ); -- LIST ITEM - s( - { trig = "ii"; snippetType = "autosnippet"; }, - fmt( - [[ - <li>{}</li> - ]], - { d(1, get_visual); } - ), - { condition = line_begin; } - ); - -- DOCUMENT TEMPLATE - s( - { trig = "base"; }, - fmt( - [[ - <!doctype HTML> - <html lang="en"> - <head> - <meta charset="UTF-8"> - <title>{}</title> - </head> - <body> - {} - </body> - </html> - ]], - { i(1, "FooBar"); i(0); } - ), - { condition = line_begin; } - ); -- ANCHOR TAG - s( - { - trig = "([^%l])aa"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; - }, - fmt( - [[ - {}<a href="{}">{}</a> - ]], - { - f(function(_, snip) - return snip.captures[1] - end); - i(1); - d(2, get_visual); - } - ) - ); -} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/delimiter.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/delimiter.lua deleted file mode 100644 index e50898fc..00000000 --- a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/delimiter.lua +++ /dev/null @@ -1,34 +0,0 @@ -local get_visual = function(args, parent) - if #parent.snippet.env.SELECT_RAW > 0 then - return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) - else - return sn(nil, i(1, "")) - end -end - -local translation_table = { ["("] = ")"; ["{"] = "}"; ["["] = "]"; } - --- Return snippet tables -return { - -- LEFT/RIGHT ALL BRACES - s( - { - trig = "([^%a])l([%(%[%{])"; - regTrig = true; - wordTrig = false; - snippetType = "autosnippet"; - }, - fmta("<>\\left<><>\\right<>", { - f(function(_, snip) - return snip.captures[1] - end); - f(function(_, snip) - return snip.captures[2] - end); - d(1, get_visual); - f(function(_, snip) - return translation_table[snip.captures[2]] - end); - }) - ); -} diff --git a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/greek.lua b/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/greek.lua deleted file mode 100644 index 19989093..00000000 --- a/home-manager/soispha/config/neovim/nixvim/plugins/luasnip/lua/snippets/tex/greek.lua +++ /dev/null @@ -1,37 +0,0 @@ --- Return snippet tables -return { - 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 = ";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 = ";o"; snippetType = "autosnippet"; }, { t("\\theta"); }); - s({ trig = ";vo"; snippetType = "autosnippet"; }, { t("\\vartheta"); }); - s({ trig = ";O"; snippetType = "autosnippet"; }, { t("\\Theta"); }); - s({ trig = ";k"; snippetType = "autosnippet"; }, { t("\\kappa"); }); - 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 = ";i"; snippetType = "autosnippet"; }, { t("\\pi"); }); - s({ trig = ";I"; 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 = ";f"; snippetType = "autosnippet"; }, { t("\\phi"); }); - s({ trig = ";vf"; snippetType = "autosnippet"; }, { t("\\varphi"); }); - s({ trig = ";F"; snippetType = "autosnippet"; }, { t("\\Phi"); }); - s({ trig = ";c"; snippetType = "autosnippet"; }, { t("\\chi"); }); - s({ trig = ";p"; snippetType = "autosnippet"; }, { t("\\psi"); }); - s({ trig = ";P"; snippetType = "autosnippet"; }, { t("\\Psi"); }); - s({ trig = ";w"; snippetType = "autosnippet"; }, { t("\\omega"); }); - s({ trig = ";W"; snippetType = "autosnippet"; }, { t("\\Omega"); }); -} |