I'm having trouble using the register method for which key to register key bindings for nvim-paredit. I can get most of them to work but when I want to register commands that normally take extra options upon setup I am having a hard time setting them without errors. For example in the nvim-paredit docs you see this example:
["af"] = {
paredit.api.select_around_form,
"Around form",
repeatable = false,
mode = { "o", "v" }
},
["if"] = {
paredit.api.select_in_form,
"In form",
repeatable = false,
mode = { "o", "v" }
},
["aF"] = {
paredit.api.select_around_top_level_form,
"Around top level form",
repeatable = false,
mode = { "o", "v" }
},
["iF"] = {
paredit.api.select_in_top_level_form,
"In top level form",
repeatable = false,
mode = { "o", "v" }
I am trying remap those keybindings with register and have tried something like this as a first pass and got errors (not surprised)
[{1 :julienvincent/nvim-paredit
:ft [:clojure :fennel]
:config (fn []
(let [paredit (require :nvim-paredit)
wk (require :which-key)]
(paredit.setup {:keys {}})))
:init (fn []
(let [paredit (require :nvim-paredit)
wk (require :which-key)]
(wk.register {:<leader> {
,,,
:a {:name "[a]round"
:f {1 paredit.api.select_around_form
2 "[f]orm"
:repeatable false
:mode [:o :v]}
:F {1 paredit.api.select_around_top_level_form
2 "top level [F]orm"
:repeatable false
:mode [:o :v]}
:e {1 paredit.api.select_element
2 "[e]lement"
:repeatable false
:mode [:o :v]}}
,,,
}})))}
{1 :julienvincentnvim-paredit-fennel
:dependencies [:julienvincent/nvim-paredit]
:lazy true
:ft [:fennel]
:config (fn []
(let [paredit-fnl (require :nvim-paredit-fennel)]
(paredit-fnl.setup)))}]
I know that I could do this with the setup method in the nvim-paredit suggested in the docs but I like being able to name my intermediate keys and would prefer to use the same method to map my keys across the board. Can anyone help me out?i don't know how which-key.register works, but I was able to do this using the nvim-paredit.setup function
my nvim-paredit config is still in lua: https://github.com/NoahTheDuke/dotfiles/blob/cdb687e1410cba2fb5637d5f0f31d99afa0ad625/nvim/lua/plugins/nvim-paredit.lua
i define some local functions and then call
...
paredit.setup({
use_default_keys = true,
filetypes = { "clojure", "scheme", "lisp", "fennel" },
cursor_behaviour = "follow",
keys = {
-- Wrap enclosing form in given type, enter insert mode at start or end
["i"] = {
enclosing_wrapper_maker({"( ", ")"}, "inner_start"),
"Wrap form round, insert head",
},
... adding the docstring makes it show up in which-key's pop-up, so maybe if you switch to using nvim-paredit.setup, it'll work for you?