diff options
Diffstat (limited to 'modules/by-name')
3 files changed, 102 insertions, 78 deletions
diff --git a/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/all.lua b/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/all.lua index 1abb70cb..7909014e 100644 --- a/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/all.lua +++ b/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/all.lua @@ -10,13 +10,14 @@ local ls = require("luasnip") -- auto_pairs {{{ -local get_visual = function(args, parent) +local get_visual = function(_, parent) if #parent.snippet.env.SELECT_RAW > 0 then - return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + return ls.snippet_node(nil, ls.insert_node(1, parent.snippet.env.SELECT_RAW)) else - return sn(nil, i(1, "")) + return ls.snippet_node(nil, ls.insert_node(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). @@ -38,30 +39,42 @@ local function pair(pair_begin, pair_end, file_types, condition_function) -- It would be nice, if it would support both an empty array (`{}`) and nil <2023-08-27> -- file_types = file_types or {}; - return s( - { trig = pair_begin, wordTrig = false, snippetType = "autosnippet" }, - { t({ pair_begin }), d(1, get_visual), t({ pair_end }) }, + return ls.snippet( + { + trig = pair_begin; + wordTrig = false; + snippetType = "autosnippet"; + }, + { + ls.text_node({ pair_begin; }); + ls.dynamic_node(1, get_visual); + ls.text_node({ pair_end; }); + }, { condition = function() local filetype_check = true - if file_types ~= nil then filetype_check = file_types[vim.bo.filetype] or false end + + if file_types ~= nil then + filetype_check = file_types[vim.bo.filetype] or false + end + return (not condition_function(pair_begin, pair_end)) and filetype_check - end, + end; } ) end local auto_pairs = { - pair("(", ")", nil, char_count_same), - pair("{", "}", nil, char_count_same), - pair("[", "]", nil, char_count_same), - pair("<", ">", { ["rust"] = true, ["tex"] = true }, char_count_same), - pair("'", "'", nil, even_count), - pair("\"", "\"", nil, even_count), - pair("`", "`", nil, even_count), + pair("(", ")", nil, char_count_same); + pair("{", "}", nil, char_count_same); + pair("[", "]", nil, char_count_same); + pair("<", ">", { ["rust"] = true; ["tex"] = true; }, char_count_same); + pair("'", "'", nil, even_count); + pair("\"", "\"", nil, even_count); + pair("`", "`", nil, even_count); } -ls.add_snippets("all", auto_pairs, { type = "snippets", key = "auto_pairs" }) +ls.add_snippets("all", auto_pairs, { type = "snippets"; key = "auto_pairs"; }) -- }}} -- todo_comments {{{ @@ -70,10 +83,15 @@ local utils = require("Comment.utils") local read_git_config = function(config_value) local command = string.format("git config \"%s\"", config_value) + local handle = io.popen(command) - if handle == nil then return error(string.format("Failed to call `%s`.", command)) end + if handle == nil then + return error(string.format("Failed to call `%s`.", command)) + end + local result = handle:read("*a") handle:close() + -- stripped = string.gsub(str, '%s+', '') return string.gsub(result, "\n", "") end @@ -188,24 +206,25 @@ local process_marks = function(context, aliases, opts, marks) output[#output + 1] = todo_snippet(context, aliases, opts, mark_function) context.trig = contex_trig_local end + return output end local todo_snippet_specs = { - { { trig = "todo" }, { "TODO" }, { ctype = 1 } }, - { { trig = "fix" }, { "FIXME", "ISSUE" }, { ctype = 1 } }, - { { trig = "hack" }, { "HACK" }, { ctype = 1 } }, - { { trig = "warn" }, { "WARNING" }, { ctype = 1 } }, - { { trig = "perf" }, { "PERFORMANCE", "OPTIMIZE" }, { ctype = 1 } }, - { { trig = "note" }, { "NOTE", "INFO" }, { ctype = 1 } }, + { { trig = "todo"; }; { "TODO"; }; { ctype = 1; }; }; + { { trig = "fix"; }; { "FIXME"; "ISSUE"; }; { ctype = 1; }; }; + { { trig = "hack"; }; { "HACK"; }; { ctype = 1; }; }; + { { trig = "warn"; }; { "WARNING"; }; { ctype = 1; }; }; + { { trig = "perf"; }; { "PERFORMANCE"; "OPTIMIZE"; }; { ctype = 1; }; }; + { { trig = "note"; }; { "NOTE"; "INFO"; }; { ctype = 1; }; }; -- NOTE: Block commented todo-comments - { { trig = "todob" }, { "TODO" }, { ctype = 2 } }, - { { trig = "fixb" }, { "FIXME", "ISSUE" }, { ctype = 2 } }, - { { trig = "hackb" }, { "HACK" }, { ctype = 2 } }, - { { trig = "warnb" }, { "WARNING" }, { ctype = 2 } }, - { { trig = "perfb" }, { "PERF", "PERFORMANCE", "OPTIM", "OPTIMIZE" }, { ctype = 2 } }, - { { trig = "noteb" }, { "NOTE", "INFO" }, { ctype = 2 } }, + { { trig = "todob"; }; { "TODO"; }; { ctype = 2; }; }; + { { trig = "fixb"; }; { "FIXME"; "ISSUE"; }; { ctype = 2; }; }; + { { trig = "hackb"; }; { "HACK"; }; { ctype = 2; }; }; + { { trig = "warnb"; }; { "WARNING"; }; { ctype = 2; }; }; + { { trig = "perfb"; }; { "PERF"; "PERFORMANCE"; "OPTIM"; "OPTIMIZE"; }; { ctype = 2; }; }; + { { trig = "noteb"; }; { "NOTE"; "INFO"; }; { ctype = 2; }; }; } local todo_comment_snippets = {} diff --git a/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua b/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua index 371fe627..bcd128f7 100644 --- a/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua +++ b/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/delimiter.lua @@ -8,31 +8,34 @@ -- You should have received a copy of the License along with this program. -- If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. -local get_visual = function(args, parent) +local ls = require("luasnip") +local fmt = require("luasnip.extras.fmt").fmt + +local get_visual = function(_, parent) if #parent.snippet.env.SELECT_RAW > 0 then - return sn(nil, i(1, parent.snippet.env.SELECT_RAW)) + return ls.snippet_node(nil, ls.insert_node(1, parent.snippet.env.SELECT_RAW)) else - return sn(nil, i(1, "")) + return ls.snippet_node(nil, ls.insert_node(1, "")) end end -local translation_table = { ["("] = ")", ["{"] = "}", ["["] = "]" } +local translation_table = { ["("] = ")"; ["{"] = "}"; ["["] = "]"; } -- Return snippet tables return { -- LEFT/RIGHT ALL BRACES - s( + ls.snippet( { - trig = "([^%a])l([%(%[%{])", - regTrig = true, - wordTrig = false, - snippetType = "autosnippet", + 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), + fmt("{}\\left{}{}\\right{}", { + ls.function_node(function(_, snip) return snip.captures[1] end); + ls.function_node(function(_, snip) return snip.captures[2] end); + ls.dynamic_node(1, get_visual); + ls.function_node(function(_, snip) return translation_table[snip.captures[2]] end); }) - ), + ); } diff --git a/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/greek.lua b/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/greek.lua index 4a5651ce..21aa7414 100644 --- a/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/greek.lua +++ b/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/tex/greek.lua @@ -8,40 +8,42 @@ -- You should have received a copy of the License along with this program. -- If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. +local ls = require("luasnip") + -- 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") }), + ls.snippet({ trig = ";a"; snippetType = "autosnippet"; }, { ls.text_node("\\alpha"); }); + ls.snippet({ trig = ";b"; snippetType = "autosnippet"; }, { ls.text_node("\\beta"); }); + ls.snippet({ trig = ";g"; snippetType = "autosnippet"; }, { ls.text_node("\\gamma"); }); + ls.snippet({ trig = ";G"; snippetType = "autosnippet"; }, { ls.text_node("\\Gamma"); }); + ls.snippet({ trig = ";d"; snippetType = "autosnippet"; }, { ls.text_node("\\delta"); }); + ls.snippet({ trig = ";D"; snippetType = "autosnippet"; }, { ls.text_node("\\Delta"); }); + ls.snippet({ trig = ";e"; snippetType = "autosnippet"; }, { ls.text_node("\\epsilon"); }); + ls.snippet({ trig = ";ve"; snippetType = "autosnippet"; }, { ls.text_node("\\varepsilon"); }); + ls.snippet({ trig = ";z"; snippetType = "autosnippet"; }, { ls.text_node("\\zeta"); }); + ls.snippet({ trig = ";h"; snippetType = "autosnippet"; }, { ls.text_node("\\eta"); }); + ls.snippet({ trig = ";o"; snippetType = "autosnippet"; }, { ls.text_node("\\theta"); }); + ls.snippet({ trig = ";vo"; snippetType = "autosnippet"; }, { ls.text_node("\\vartheta"); }); + ls.snippet({ trig = ";O"; snippetType = "autosnippet"; }, { ls.text_node("\\Theta"); }); + ls.snippet({ trig = ";k"; snippetType = "autosnippet"; }, { ls.text_node("\\kappa"); }); + ls.snippet({ trig = ";l"; snippetType = "autosnippet"; }, { ls.text_node("\\lambda"); }); + ls.snippet({ trig = ";L"; snippetType = "autosnippet"; }, { ls.text_node("\\Lambda"); }); + ls.snippet({ trig = ";m"; snippetType = "autosnippet"; }, { ls.text_node("\\mu"); }); + ls.snippet({ trig = ";n"; snippetType = "autosnippet"; }, { ls.text_node("\\nu"); }); + ls.snippet({ trig = ";x"; snippetType = "autosnippet"; }, { ls.text_node("\\xi"); }); + ls.snippet({ trig = ";X"; snippetType = "autosnippet"; }, { ls.text_node("\\Xi"); }); + ls.snippet({ trig = ";i"; snippetType = "autosnippet"; }, { ls.text_node("\\pi"); }); + ls.snippet({ trig = ";I"; snippetType = "autosnippet"; }, { ls.text_node("\\Pi"); }); + ls.snippet({ trig = ";r"; snippetType = "autosnippet"; }, { ls.text_node("\\rho"); }); + ls.snippet({ trig = ";s"; snippetType = "autosnippet"; }, { ls.text_node("\\sigma"); }); + ls.snippet({ trig = ";S"; snippetType = "autosnippet"; }, { ls.text_node("\\Sigma"); }); + ls.snippet({ trig = ";t"; snippetType = "autosnippet"; }, { ls.text_node("\\tau"); }); + ls.snippet({ trig = ";f"; snippetType = "autosnippet"; }, { ls.text_node("\\phi"); }); + ls.snippet({ trig = ";vf"; snippetType = "autosnippet"; }, { ls.text_node("\\varphi"); }); + ls.snippet({ trig = ";F"; snippetType = "autosnippet"; }, { ls.text_node("\\Phi"); }); + ls.snippet({ trig = ";c"; snippetType = "autosnippet"; }, { ls.text_node("\\chi"); }); + ls.snippet({ trig = ";p"; snippetType = "autosnippet"; }, { ls.text_node("\\psi"); }); + ls.snippet({ trig = ";P"; snippetType = "autosnippet"; }, { ls.text_node("\\Psi"); }); + ls.snippet({ trig = ";w"; snippetType = "autosnippet"; }, { ls.text_node("\\omega"); }); + ls.snippet({ trig = ";W"; snippetType = "autosnippet"; }, { ls.text_node("\\Omega"); }); } |