summaryrefslogtreecommitdiff
path: root/ar/.config/TheSiahxyz/lua/thesiahxyz/utils/snippet.lua
diff options
context:
space:
mode:
Diffstat (limited to 'ar/.config/TheSiahxyz/lua/thesiahxyz/utils/snippet.lua')
-rw-r--r--ar/.config/TheSiahxyz/lua/thesiahxyz/utils/snippet.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/utils/snippet.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/utils/snippet.lua
new file mode 100644
index 0000000..57bb211
--- /dev/null
+++ b/ar/.config/TheSiahxyz/lua/thesiahxyz/utils/snippet.lua
@@ -0,0 +1,38 @@
+local ls = require("luasnip")
+-- local s = ls.snippet
+local i = ls.insert_node
+local t = ls.text_node
+-- local d = ls.dynamic_node
+-- local f = ls.function_node
+local c = ls.choice_node
+-- local rep = require("luasnip.extras").rep
+-- local k = require("luasnip.nodes.key_indexer").new_key
+local r = ls.restore_node
+local fmt = require("luasnip.extras.fmt").fmt
+
+local M = {}
+M.i = 0
+
+M.js_quotes = function(index)
+ M.i = M.i + 1
+ return c(index, { fmt("'{}'", { r(1, M.i) }), fmt("`{}`", { r(1, M.i) }), fmt('"{}"', { r(1, M.i) }), t("") })
+end
+
+M.js_selector = function(index)
+ return c(index, { fmt("/{}/i", { i(1) }), fmt("'{}'", { i(1) }), fmt("`{}`", { i(1) }), t("") })
+end
+
+M.rtl_selector = function(index)
+ return c(index, { t("screen.get"), t("await screen.find"), t("screen.query") })
+end
+
+M.tracked_i_nodes = {}
+
+M.tin = function(index, key)
+ if not M.tracked_i_nodes[key] then
+ M.tracked_i_nodes[key] = i(index)
+ end
+ return M.tracked_i_nodes[key]
+end
+
+return M