diff options
Diffstat (limited to 'fnl')
-rw-r--r-- | fnl/aktersnurra.fnl | 1 | ||||
-rw-r--r-- | fnl/plugins/cmp.fnl | 33 | ||||
-rw-r--r-- | fnl/plugins/snippets/init.fnl | 31 | ||||
-rw-r--r-- | fnl/plugins/snippets/org.fnl | 13 |
4 files changed, 47 insertions, 31 deletions
diff --git a/fnl/aktersnurra.fnl b/fnl/aktersnurra.fnl index b0634a0..f86c2a2 100644 --- a/fnl/aktersnurra.fnl +++ b/fnl/aktersnurra.fnl @@ -7,6 +7,7 @@ (if (not= fname nil) (table.insert plugins (require (.. :plugins. fname)))))) (table.insert plugins (require :plugins.lsp)) + (table.insert plugins (require :plugins.snippets)) plugins)) (local icons (require :settings.icons)) diff --git a/fnl/plugins/cmp.fnl b/fnl/plugins/cmp.fnl index 2a8d280..f3c0211 100644 --- a/fnl/plugins/cmp.fnl +++ b/fnl/plugins/cmp.fnl @@ -6,14 +6,11 @@ :hrsh7th/cmp-cmdline :hrsh7th/cmp-path :onsails/lspkind.nvim - :rafamadriz/friendly-snippets :saadparwaiz1/cmp_luasnip]) (fn config [] (let [cmp (require :cmp) - lspkind (require :lspkind) - luasnip-vscode (require :luasnip.loaders.from_vscode)] - (luasnip-vscode.lazy_load) + lspkind (require :lspkind)] (lspkind.init) (cmp.setup {:snippet {:expand (lambda [args] (let [luasnip (require :luasnip)] @@ -60,32 +57,6 @@ {:mapping (cmp.mapping.preset.cmdline) :sources [{:name :path} {:name :cmdline - :option {:ignore_cmds [:Man "!"]}}]}) - (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 (ls.expand_or_jumpable) - (ls.expand_or_jump))) - {:silent true}) - (vim.keymap.set [:i :s] :<c-j> - (lambda [] - (when (ls.jumpable -1) - (ls.jump -1)) - {:silent true})) - (vim.keymap.set [:i] :<c-l> - (lambda [] - (when (ls.choice_active) - (ls.change_choice 1))) - {:silent true})))) + :option {:ignore_cmds [:Man "!"]}}]}))) {1 :hrsh7th/nvim-cmp : dependencies :event :InsertEnter : config} diff --git a/fnl/plugins/snippets/init.fnl b/fnl/plugins/snippets/init.fnl new file mode 100644 index 0000000..b586d76 --- /dev/null +++ b/fnl/plugins/snippets/init.fnl @@ -0,0 +1,31 @@ +;; Snippets functionality. + +(local dependencies [:rafamadriz/friendly-snippets]) + +(fn add-snippets [] + (let [org (require :plugins.snippets.org)] + (org.add-snippets))) + +(fn config [] + (let [ls (require :luasnip) + luasnip-vscode (require :luasnip.loaders.from_vscode)] + (luasnip-vscode.lazy_load) + (add-snippets) + (ls.config.set_config {:history false + :updateevents "TextChanged,TextChangedI"}) + (vim.keymap.set [:i :s] :<c-k> + (lambda [] + (when (ls.expand_or_jumpable) + (ls.expand_or_jump))) {:silent true}) + (vim.keymap.set [:i :s] :<c-j> + (lambda [] + (when (ls.jumpable -1) + (ls.jump -1)) + {:silent true})) + (vim.keymap.set [:i] :<c-l> + (lambda [] + (when (ls.choice_active) + (ls.change_choice 1))) + {:silent true}))) + +{1 :L3MON4D3/LuaSnip :event :InsertEnter : config : dependencies} diff --git a/fnl/plugins/snippets/org.fnl b/fnl/plugins/snippets/org.fnl new file mode 100644 index 0000000..a2b2e46 --- /dev/null +++ b/fnl/plugins/snippets/org.fnl @@ -0,0 +1,13 @@ +;; Snippets for org files. + +(fn add-snippets [] + (let [ls (require :luasnip) + fmt (require :luasnip.extras.fmt)] + (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)]))])))) + +{: add-snippets} |