summaryrefslogtreecommitdiffstats
path: root/modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/all.lua
diff options
context:
space:
mode:
Diffstat (limited to 'modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/all.lua')
-rw-r--r--modules/by-name/nv/nvim/plgs/luasnip/lua/snippets/all.lua77
1 files changed, 48 insertions, 29 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 = {}