diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-07-29 00:03:28 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2024-07-29 00:03:28 +0200 |
commit | beb3ed1effdc5dbd047c583598b83615075363b7 (patch) | |
tree | 5e49355bd20ac94c1dc19530e0605e6dc6c487bb /fnl | |
parent | 66f7949711425dc20bfb7612a68d81b5af30b8e9 (diff) |
Update how lsp, snippets and plugins are loaded
Diffstat (limited to 'fnl')
-rw-r--r-- | fnl/aktersnurra.fnl | 17 | ||||
-rw-r--r-- | fnl/plugins/lsp.fnl (renamed from fnl/plugins/lsp/init.fnl) | 0 | ||||
-rw-r--r-- | fnl/plugins/snippets.fnl (renamed from fnl/plugins/snippets/init.fnl) | 20 | ||||
-rw-r--r-- | fnl/util/load.fnl | 8 |
4 files changed, 26 insertions, 19 deletions
diff --git a/fnl/aktersnurra.fnl b/fnl/aktersnurra.fnl index f86c2a2..898c454 100644 --- a/fnl/aktersnurra.fnl +++ b/fnl/aktersnurra.fnl @@ -1,17 +1,16 @@ ;; Load plugins with lazy. -(local plugins (let [plugins [] - path (.. (vim.fn.stdpath :config) :/fnl/plugins)] - (each [fname (vim.fs.dir path)] - (let [fname (fname:match "^(.*)%.fnl$")] - (if (not= fname nil) - (table.insert plugins (require (.. :plugins. fname)))))) - (table.insert plugins (require :plugins.lsp)) - (table.insert plugins (require :plugins.snippets)) - plugins)) +(λ load-plugin [tbl name] + (table.insert tbl (require (.. :plugins. name)))) (local icons (require :settings.icons)) +(local {: load-and-apply} (require :util.load)) + +(local plugins (let [tbl {}] + (load-and-apply :/fnl/plugins (partial load-plugin tbl)) + tbl)) + (local opts {:install {:colorscheme [:no-clown-fiesta]} :debug false :defaults {:lazy false} diff --git a/fnl/plugins/lsp/init.fnl b/fnl/plugins/lsp.fnl index f04ba86..f04ba86 100644 --- a/fnl/plugins/lsp/init.fnl +++ b/fnl/plugins/lsp.fnl diff --git a/fnl/plugins/snippets/init.fnl b/fnl/plugins/snippets.fnl index 016b3b6..91865d6 100644 --- a/fnl/plugins/snippets/init.fnl +++ b/fnl/plugins/snippets.fnl @@ -2,29 +2,29 @@ (local dependencies [:rafamadriz/friendly-snippets]) -(fn add-snippets [] - (let [org (require :plugins.snippets.org) - workflow (require :plugins.snippets.workflow)] - (org.add-snippets) - (workflow.add-snippets))) +(λ add-snippets [name] + (let [snippets (require (.. :plugins.snippets. name))] + (snippets.add-snippets))) -(fn config [] +(local {: load-and-apply} (require :util.load)) + +(λ config [] (let [ls (require :luasnip) luasnip-vscode (require :luasnip.loaders.from_vscode)] (luasnip-vscode.lazy_load) - (add-snippets) + (load-and-apply :/fnl/plugins/snippets add-snippets) (ls.config.set_config {:history false :updateevents "TextChanged,TextChangedI"}) - (vim.keymap.set [:i :s] :<c-k> + (vim.keymap.set [:i :s] :<c-u> (lambda [] (when (ls.expand_or_jumpable) (ls.expand_or_jump))) {:silent true}) - (vim.keymap.set [:i :s] :<c-j> + (vim.keymap.set [:i :s] :<c-l> (lambda [] (when (ls.jumpable -1) (ls.jump -1)) {:silent true})) - (vim.keymap.set [:i] :<c-l> + (vim.keymap.set [:i] :<c-j> (lambda [] (when (ls.choice_active) (ls.change_choice 1))) diff --git a/fnl/util/load.fnl b/fnl/util/load.fnl new file mode 100644 index 0000000..fef9b6e --- /dev/null +++ b/fnl/util/load.fnl @@ -0,0 +1,8 @@ +;; Load file with function + +(λ load-and-apply [path f] + (each [fname type (vim.fs.dir (.. (vim.fn.stdpath :config) path))] + (when (= type :file) + (f (fname:match "^(.*)%.fnl$"))))) + +{: load-and-apply} |