diff options
| author | 2024-07-24 19:19:26 +0200 | |
|---|---|---|
| committer | 2024-07-24 19:19:26 +0200 | |
| commit | 01586921b3d5f2ac1ccf8196d3ad9b4b3ddd31f3 (patch) | |
| tree | d740ac5e8943e48ee4132efc4633051d6cdf1d48 /dot_config/nvim/fnl/toast/macros.fnl | |
| parent | nvim: ignore lazy-lock.json (diff) | |
nvim: rewrite config in fennel
One file isn't done, and there's also the question of ftplugin and co.
One step at a time though, eh?
Diffstat (limited to '')
| -rw-r--r-- | dot_config/nvim/fnl/toast/macros.fnl | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/dot_config/nvim/fnl/toast/macros.fnl b/dot_config/nvim/fnl/toast/macros.fnl new file mode 100644 index 0000000..bb4375b --- /dev/null +++ b/dot_config/nvim/fnl/toast/macros.fnl @@ -0,0 +1,29 @@ +;; [nfnl-macro] + +(local {: inc + : drop + : group} (require :toast.core)) +(local {: from-pairs + : insert} (require :toast.table)) + +(fn tbl [...] + "Generate a mixed table. + The format is (tbl 1 2 3 & :a :b) to produce {1; 2; 3; a = 'b'}. + This macro simply expands to the correct data during compile-time." + (let [args [...] + pre (accumulate [out [] + _ v (ipairs args) + &until (= v '&)] + (insert out v)) + post (drop (inc (length pre)) args)] + (from-pairs (group 2 post) pre))) + +(fn recc [reqspec key ...] + "A common lua pattern is `require 'something'.call(arg1, arg2)`. + The fennel equivalent is ((require :something).call arg1 arg2) + This macro makes it easier to do this elegantly. + The equivalent call is (recc :something :call arg1 arg2)" + `((. (require ,reqspec) ,key) ,...)) + +{: tbl + : recc} |
