summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYigit Sever2024-08-26 11:07:42 +0200
committerYigit Sever2024-08-26 11:07:42 +0200
commit36c316b53476fff406db292a54f3c88b07b4b944 (patch)
tree411f66376b88f86d87fd567a6dd3f820686b85a3
parentf588b6d660b6481c7b47e0a12d29372d0aa8ae8d (diff)
downloaddotfiles-36c316b53476fff406db292a54f3c88b07b4b944.tar.gz
dotfiles-36c316b53476fff406db292a54f3c88b07b4b944.tar.bz2
dotfiles-36c316b53476fff406db292a54f3c88b07b4b944.zip
nvim: add lua snippets
A year later... https://git.yigitsever.com/personal/dotfiles/commit/.config/nvim/my_snippets?id=387e08c52d9752bc839c71119f140ba8435c3d70
-rw-r--r--.config/nvim/lua/luasnippets/PKGBUILD.lua36
-rw-r--r--.config/nvim/lua/luasnippets/mail.lua36
-rw-r--r--.config/nvim/lua/luasnippets/vimwiki.lua60
-rw-r--r--.config/nvim/lua/plugins/cmp.lua1
4 files changed, 133 insertions, 0 deletions
diff --git a/.config/nvim/lua/luasnippets/PKGBUILD.lua b/.config/nvim/lua/luasnippets/PKGBUILD.lua
new file mode 100644
index 0000000..334baf1
--- /dev/null
+++ b/.config/nvim/lua/luasnippets/PKGBUILD.lua
@@ -0,0 +1,36 @@
1local ls = require("luasnip")
2local s = ls.snippet
3local sn = ls.snippet_node
4local isn = ls.indent_snippet_node
5local t = ls.text_node
6local i = ls.insert_node
7local f = ls.function_node
8local c = ls.choice_node
9local d = ls.dynamic_node
10local r = ls.restore_node
11local events = require("luasnip.util.events")
12local ai = require("luasnip.nodes.absolute_indexer")
13local extras = require("luasnip.extras")
14local l = extras.lambda
15local rep = extras.rep
16local p = extras.partial
17local m = extras.match
18local n = extras.nonempty
19local dl = extras.dynamic_lambda
20local fmt = require("luasnip.extras.fmt").fmt
21local fmta = require("luasnip.extras.fmt").fmta
22local conds = require("luasnip.extras.expand_conditions")
23local postfix = require("luasnip.extras.postfix").postfix
24local types = require("luasnip.util.types")
25local parse = require("luasnip.util.parser").parse_snippet
26local ms = ls.multi_snippet
27local k = require("luasnip.nodes.key_indexer").new_key
28local strftime = vim.fn.strftime
29
30return {
31 s("m",
32 {
33 t("# Maintainer: Yigit Sever <yigit at yigitsever dot com>")
34 }
35 )
36}
diff --git a/.config/nvim/lua/luasnippets/mail.lua b/.config/nvim/lua/luasnippets/mail.lua
new file mode 100644
index 0000000..3d60baa
--- /dev/null
+++ b/.config/nvim/lua/luasnippets/mail.lua
@@ -0,0 +1,36 @@
1local ls = require("luasnip")
2local s = ls.snippet
3local sn = ls.snippet_node
4local isn = ls.indent_snippet_node
5local t = ls.text_node
6local i = ls.insert_node
7local f = ls.function_node
8local c = ls.choice_node
9local d = ls.dynamic_node
10local r = ls.restore_node
11local events = require("luasnip.util.events")
12local ai = require("luasnip.nodes.absolute_indexer")
13local extras = require("luasnip.extras")
14local l = extras.lambda
15local rep = extras.rep
16local p = extras.partial
17local m = extras.match
18local n = extras.nonempty
19local dl = extras.dynamic_lambda
20local fmt = require("luasnip.extras.fmt").fmt
21local fmta = require("luasnip.extras.fmt").fmta
22local conds = require("luasnip.extras.expand_conditions")
23local postfix = require("luasnip.extras.postfix").postfix
24local types = require("luasnip.util.types")
25local parse = require("luasnip.util.parser").parse_snippet
26local ms = ls.multi_snippet
27local k = require("luasnip.nodes.key_indexer").new_key
28local strftime = vim.fn.strftime
29
30return {
31 s("~",
32 {
33 t("~yigit")
34 }
35 )
36}
diff --git a/.config/nvim/lua/luasnippets/vimwiki.lua b/.config/nvim/lua/luasnippets/vimwiki.lua
new file mode 100644
index 0000000..c5e8532
--- /dev/null
+++ b/.config/nvim/lua/luasnippets/vimwiki.lua
@@ -0,0 +1,60 @@
1local ls = require("luasnip")
2local s = ls.snippet
3local sn = ls.snippet_node
4local isn = ls.indent_snippet_node
5local t = ls.text_node
6local i = ls.insert_node
7local f = ls.function_node
8local c = ls.choice_node
9local d = ls.dynamic_node
10local r = ls.restore_node
11local events = require("luasnip.util.events")
12local ai = require("luasnip.nodes.absolute_indexer")
13local extras = require("luasnip.extras")
14local l = extras.lambda
15local rep = extras.rep
16local p = extras.partial
17local m = extras.match
18local n = extras.nonempty
19local dl = extras.dynamic_lambda
20local fmt = require("luasnip.extras.fmt").fmt
21local fmta = require("luasnip.extras.fmt").fmta
22local conds = require("luasnip.extras.expand_conditions")
23local postfix = require("luasnip.extras.postfix").postfix
24local types = require("luasnip.util.types")
25local parse = require("luasnip.util.parser").parse_snippet
26local ms = ls.multi_snippet
27local k = require("luasnip.nodes.key_indexer").new_key
28local strftime = vim.fn.strftime
29
30local function clipboard()
31 local text = vim.fn.system({ 'wl-paste' })
32 local output = string.gsub(text, "^%s*(.-)%s*$", "%1")
33 return output
34end
35
36return {
37 s("datasrc",
38 {
39 t({ "= " }), i(1), t({ " =", "" }),
40 t({ "", "== Used By ==", "" }), i(2),
41 t({ "", "== URL ==", "" }), i(3),
42 t({ "", "== API ==", "" }), i(4),
43 t({ "", "=== Example ===", "" }), i(5),
44 t({ "", "== Cost ==", "" }), i(6),
45 t({ "", "== Limits ==", "" }), i(0),
46 }
47 ),
48 s("s",
49 {
50 t({ "- (" }),
51 t({ strftime("%F %R") }),
52 t({ ") " }),
53 i(1, clipboard()),
54 t({ " -- " }),
55 i(2, "Summary")
56
57 }
58 )
59}
60
diff --git a/.config/nvim/lua/plugins/cmp.lua b/.config/nvim/lua/plugins/cmp.lua
index 884e778..8e34264 100644
--- a/.config/nvim/lua/plugins/cmp.lua
+++ b/.config/nvim/lua/plugins/cmp.lua
@@ -176,6 +176,7 @@ return {
176 -- To enable auto expansion 176 -- To enable auto expansion
177 enable_autosnippets = true, 177 enable_autosnippets = true,
178 }) 178 })
179 require("luasnip.loaders.from_lua").lazy_load({ paths = "./lua/luasnippets" })
179 end 180 end
180 181
181 }, 182 },