From 01586921b3d5f2ac1ccf8196d3ad9b4b3ddd31f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Vulquin?= Date: Wed, 24 Jul 2024 19:19:26 +0200 Subject: 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? --- dot_config/nvim/fnl/toast/macros.fnl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 dot_config/nvim/fnl/toast/macros.fnl (limited to 'dot_config/nvim/fnl/toast/macros.fnl') 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} -- cgit v1.2.3