summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md6
-rw-r--r--fnl/plugins/cmp.fnl27
2 files changed, 23 insertions, 10 deletions
diff --git a/README.md b/README.md
index ea9090d..4d474f2 100644
--- a/README.md
+++ b/README.md
@@ -39,3 +39,9 @@ cargo install tree-sitter-cli
```
Select and run `:Fnl`
+
+# Snippets
+
+## Todo
+
+-[ ] add snippets in a separate folder
diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl
index 3b8c1da..2a8d280 100644
--- a/fnl/plugins/cmp.fnl
+++ b/fnl/plugins/cmp.fnl
@@ -61,24 +61,31 @@
:sources [{:name :path}
{:name :cmdline
:option {:ignore_cmds [:Man "!"]}}]})
- (let [luasnip (require :luasnip)]
- (luasnip.config.set_config {:history false
- :updateevents "TextChanged,TextChangedI"})
- (luasnip.add_snippets :org [(luasnip.parser.parse_snippet :be "#+begin_src $1\n$2\n#+end_src")])
+ (let [ls (require :luasnip)
+ fmt (require :luasnip.extras.fmt)]
+ (ls.config.set_config {:history false
+ :updateevents "TextChanged,TextChangedI"})
+ (let [s ls.s
+ i ls.insert_node
+ fmt fmt.fmt]
+ (ls.add_snippets :org
+ [(s :be
+ (fmt "#+begin_src {}\n{}\n#+end_src"
+ [(i 1) (i 2)]))]))
(vim.keymap.set [:i :s] :<c-k>
(lambda []
- (when (luasnip.expand_or_jumpable)
- (luasnip.expand_or_jump)))
+ (when (ls.expand_or_jumpable)
+ (ls.expand_or_jump)))
{:silent true})
(vim.keymap.set [:i :s] :<c-j>
(lambda []
- (when (luasnip.jumpable -1)
- (luasnip.jump -1))
+ (when (ls.jumpable -1)
+ (ls.jump -1))
{:silent true}))
(vim.keymap.set [:i] :<c-l>
(lambda []
- (when (luasnip.choice_active)
- (luasnip.change_choice 1)))
+ (when (ls.choice_active)
+ (ls.change_choice 1)))
{:silent true}))))
{1 :hrsh7th/nvim-cmp : dependencies :event :InsertEnter : config}