diff options
author | Yigit Sever | 2024-08-26 11:07:42 +0200 |
---|---|---|
committer | Yigit Sever | 2024-08-26 11:07:42 +0200 |
commit | 36c316b53476fff406db292a54f3c88b07b4b944 (patch) | |
tree | 411f66376b88f86d87fd567a6dd3f820686b85a3 /.config/nvim/lua | |
parent | f588b6d660b6481c7b47e0a12d29372d0aa8ae8d (diff) | |
download | dotfiles-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
Diffstat (limited to '.config/nvim/lua')
-rw-r--r-- | .config/nvim/lua/luasnippets/PKGBUILD.lua | 36 | ||||
-rw-r--r-- | .config/nvim/lua/luasnippets/mail.lua | 36 | ||||
-rw-r--r-- | .config/nvim/lua/luasnippets/vimwiki.lua | 60 | ||||
-rw-r--r-- | .config/nvim/lua/plugins/cmp.lua | 1 |
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 @@ | |||
1 | local ls = require("luasnip") | ||
2 | local s = ls.snippet | ||
3 | local sn = ls.snippet_node | ||
4 | local isn = ls.indent_snippet_node | ||
5 | local t = ls.text_node | ||
6 | local i = ls.insert_node | ||
7 | local f = ls.function_node | ||
8 | local c = ls.choice_node | ||
9 | local d = ls.dynamic_node | ||
10 | local r = ls.restore_node | ||
11 | local events = require("luasnip.util.events") | ||
12 | local ai = require("luasnip.nodes.absolute_indexer") | ||
13 | local extras = require("luasnip.extras") | ||
14 | local l = extras.lambda | ||
15 | local rep = extras.rep | ||
16 | local p = extras.partial | ||
17 | local m = extras.match | ||
18 | local n = extras.nonempty | ||
19 | local dl = extras.dynamic_lambda | ||
20 | local fmt = require("luasnip.extras.fmt").fmt | ||
21 | local fmta = require("luasnip.extras.fmt").fmta | ||
22 | local conds = require("luasnip.extras.expand_conditions") | ||
23 | local postfix = require("luasnip.extras.postfix").postfix | ||
24 | local types = require("luasnip.util.types") | ||
25 | local parse = require("luasnip.util.parser").parse_snippet | ||
26 | local ms = ls.multi_snippet | ||
27 | local k = require("luasnip.nodes.key_indexer").new_key | ||
28 | local strftime = vim.fn.strftime | ||
29 | |||
30 | return { | ||
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 @@ | |||
1 | local ls = require("luasnip") | ||
2 | local s = ls.snippet | ||
3 | local sn = ls.snippet_node | ||
4 | local isn = ls.indent_snippet_node | ||
5 | local t = ls.text_node | ||
6 | local i = ls.insert_node | ||
7 | local f = ls.function_node | ||
8 | local c = ls.choice_node | ||
9 | local d = ls.dynamic_node | ||
10 | local r = ls.restore_node | ||
11 | local events = require("luasnip.util.events") | ||
12 | local ai = require("luasnip.nodes.absolute_indexer") | ||
13 | local extras = require("luasnip.extras") | ||
14 | local l = extras.lambda | ||
15 | local rep = extras.rep | ||
16 | local p = extras.partial | ||
17 | local m = extras.match | ||
18 | local n = extras.nonempty | ||
19 | local dl = extras.dynamic_lambda | ||
20 | local fmt = require("luasnip.extras.fmt").fmt | ||
21 | local fmta = require("luasnip.extras.fmt").fmta | ||
22 | local conds = require("luasnip.extras.expand_conditions") | ||
23 | local postfix = require("luasnip.extras.postfix").postfix | ||
24 | local types = require("luasnip.util.types") | ||
25 | local parse = require("luasnip.util.parser").parse_snippet | ||
26 | local ms = ls.multi_snippet | ||
27 | local k = require("luasnip.nodes.key_indexer").new_key | ||
28 | local strftime = vim.fn.strftime | ||
29 | |||
30 | return { | ||
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 @@ | |||
1 | local ls = require("luasnip") | ||
2 | local s = ls.snippet | ||
3 | local sn = ls.snippet_node | ||
4 | local isn = ls.indent_snippet_node | ||
5 | local t = ls.text_node | ||
6 | local i = ls.insert_node | ||
7 | local f = ls.function_node | ||
8 | local c = ls.choice_node | ||
9 | local d = ls.dynamic_node | ||
10 | local r = ls.restore_node | ||
11 | local events = require("luasnip.util.events") | ||
12 | local ai = require("luasnip.nodes.absolute_indexer") | ||
13 | local extras = require("luasnip.extras") | ||
14 | local l = extras.lambda | ||
15 | local rep = extras.rep | ||
16 | local p = extras.partial | ||
17 | local m = extras.match | ||
18 | local n = extras.nonempty | ||
19 | local dl = extras.dynamic_lambda | ||
20 | local fmt = require("luasnip.extras.fmt").fmt | ||
21 | local fmta = require("luasnip.extras.fmt").fmta | ||
22 | local conds = require("luasnip.extras.expand_conditions") | ||
23 | local postfix = require("luasnip.extras.postfix").postfix | ||
24 | local types = require("luasnip.util.types") | ||
25 | local parse = require("luasnip.util.parser").parse_snippet | ||
26 | local ms = ls.multi_snippet | ||
27 | local k = require("luasnip.nodes.key_indexer").new_key | ||
28 | local strftime = vim.fn.strftime | ||
29 | |||
30 | local function clipboard() | ||
31 | local text = vim.fn.system({ 'wl-paste' }) | ||
32 | local output = string.gsub(text, "^%s*(.-)%s*$", "%1") | ||
33 | return output | ||
34 | end | ||
35 | |||
36 | return { | ||
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 | }, |