diff options
| author | aktersnurra <gustaf@gustafrydholm.xyz> | 2026-04-18 00:52:28 +0200 |
|---|---|---|
| committer | aktersnurra <gustaf@gustafrydholm.xyz> | 2026-04-20 22:58:39 +0200 |
| commit | 11d50dc8934a5b9e9be73d0445789e005843dfc2 (patch) | |
| tree | c87c84806ab5fcd48f191c765650b91e1e52ce6f /fnl/macros.fnlm | |
| parent | 0f3690bd084ba3b47b4c356089b03a6df763572c (diff) | |
Diffstat (limited to 'fnl/macros.fnlm')
| -rw-r--r-- | fnl/macros.fnlm | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/fnl/macros.fnlm b/fnl/macros.fnlm index 8267518..edfca30 100644 --- a/fnl/macros.fnlm +++ b/fnl/macros.fnlm @@ -33,4 +33,43 @@ (table.insert out `(tset vim.opt ,k ,v))) out)) -{: autocmd : autocmds : user-cmd : user-cmds : keymap : keymaps : set-opts} +(fn ts-selects [...] + "Generate treesitter select keymaps. Each entry: [key query ?group]. + Modes are always [:x :o]. Assumes `select` is in scope." + (let [out `(do)] + (each [_ entry (ipairs [...])] + (let [key (. entry 1) + query (. entry 2) + group (or (. entry 3) :textobjects)] + (table.insert out + `(vim.keymap.set [:x :o] ,key + (λ [] (select.select_textobject ,query ,group)) {})))) + out)) + +(fn ts-swaps [...] + "Generate treesitter swap keymaps. Each entry: [key method query]. + Mode is always :n. method is a symbol like swap.swap_next." + (let [out `(do)] + (each [_ entry (ipairs [...])] + (let [key (. entry 1) + method (. entry 2) + query (. entry 3)] + (table.insert out + `(vim.keymap.set :n ,key (λ [] (,method ,query)) {})))) + out)) + +(fn ts-moves [...] + "Generate treesitter move keymaps. Each entry: [key method query ?group]. + Modes are always [:n :x :o]. method is a symbol like move.goto_next_start." + (let [out `(do)] + (each [_ entry (ipairs [...])] + (let [key (. entry 1) + method (. entry 2) + query (. entry 3) + group (or (. entry 4) :textobjects)] + (table.insert out + `(vim.keymap.set [:n :x :o] ,key (λ [] (,method ,query ,group)) {})))) + out)) + +{: autocmd : autocmds : user-cmd : user-cmds : keymap : keymaps : set-opts + : ts-selects : ts-swaps : ts-moves} |