Fork me on GitHub
#conjure
<
2022-05-05
>
barrell12:05:53

Hey there - I recently switched my entire config over to fennel. I’m using which-key to declare mappings, but I’m running into an issue where I can’t declare mappings over the conjure functions. Normally I’ll use this mapping to evaluate the form at column 3 (2 spaces in):

nmap <localleader>e2 3|<localleader>ee
However if I put this into whichkey as a string it doesn’t do anything for the <localleader>3. If I swap out <lovalleader>ee for :ConjureEvalCurrentForm<cr> it does work - however I have a lot of mappings that use marks and I don’t seem to see a :ConjureEvalMarkedForm that accepts a form as an argument. Does anyone know why these maps may not be executing the conjure mappings when used as mappings?

Olical12:05:04

So EvalMarkedForm will prompt the user for input when executed, so you run the command which then executes the Lua which prompts for the key. That could definitely be done in a more vim friendly way to allow you to map things differently. But generally what you want to do is somehow run ConjureEvalMarkedForm and then send the mark key as input. I don't know if that's possible.

Olical12:05:54

So the thing I'd recommend is executing this lua in your mapping instead require('conjure.eval')['marked-form']('q') for now.

🙌 1
Olical12:05:22

marked-form takes a mark or will prompt the user interactively for it.

Olical12:05:54

Onto the mapping to <localleader>ee, what happens if you substitute <localleader> for the actual character such as ,?

barrell12:05:47

It does, but I just found the issue

barrell12:05:00

Which-key sets noremap as a default, so I had to set that to false

🎉 1
barrell12:05:20

Good to know about the marked-form though, thank you for the info 😄

Olical12:05:03

I've found with Lua (not just fennel, since fennel is just a syntax on top of it, so really most questions in this area are LUA+NVIM questions, not fennel) I struggle to use the <foo> syntaxes to map to keys in some places. I think viml has some special magic that interprets those values in strings for you and translates them into some special thing at the right time. Kinda gross that it's all hidden, magic and implicit which tricks you into thinking "oh I can put these anywhere!", nope, VimL is special in some hard to find way. nvim in it's :h api does list some ways to translate these magic syntaxes of <something> into some other format which may work in more cases. It seems like this isn't your issue this time! But be aware, the escape char + some named character in strings sometimes works differently between lua and viml and it can be tricky to get it right.

Olical12:05:15

And yeah, don't be shy when reaching into Conjure's Lua and calling things directly. Most things will remain stable long into the future, I rarely if ever rename/break/remove stuff once it's in the interface.

barrell12:05:49

hehe well I’ve been using vim for 10 years but never bothered to learn vimscript, skipped lua and went straight to fennel

barrell12:05:59

so there are a couple gaps in my education 😅

barrell12:05:36

question as I’m just finding it and digging for info - I see some new conjureevalcommentcurrentform functons. Are these built in commands to evaluate nested forms inside comments?

Olical12:05:55

Same basically, I wrote Aniseed and then Conjure on top of it because I couldn't stand doing anything complex with VimL, or even Lua really. I like my lisps too much 🙂

🙌 2
barrell12:05:14

yes and thank you for that, being able to run commands with conjure from my editor has made it fun to learn - I’ve learned more about neovim this week than I have in 10 years thanks to your work ❤️

❤️ 1
Olical12:05:54

Oh damn, they're not in the docs, they're called by <prefix>ece etc, so there's comment variants of some eval mappings and commands to match up to them (they're just not listed in the help, oops). But that inserts the result of an eval into a comment, it doesn't evaluate comments.

🙌 1
Olical12:05:11

However, there is a way to get Conjure to treat comments as do blocks

🙌 1
Olical12:05:37

I can't implement "eval up to the root and count comment as a root" until everyone's on tree-sitter though really. So I might add that one day and warn if you try to use it without tree-sitter.

🙌 1
Olical12:05:58

Ah here: let g:conjure#eval#gsubs = {'do-comment': ['^%(comment[%s%c]', '(do ']}

🙌 1
Olical12:05:25

It's in :h g:conjure#eval#gsubs, that allows you to Lua subs all evals as they head out of Conjure. Kinda massively dangerously powerful, but lets you do whatever you want!

🙌 1
Olical12:05:32

Hooray for double edged chainsaws.

barrell12:05:21

Ah great! I’ve been using these mappings, which have gotten me 90% of the way there: I’ll give the new mappings a shot

barrell13:05:53

Is there a way to use cljs.test/run-tests as the test runner?

Olical13:05:53

Just added configuration for this, from :h conjure-client-clojure-nrepl

*g:conjure#client#clojure#nrepl#test#runner*
`g:conjure#client#clojure#nrepl#test#runner`
            Test runner to use for the various test mappings. The following
            are supported:
             * `"clojure"`
             * `"clojurescript" (cljs.test instead of clojure.test)`
             * `"kaocha"`
            More can be added through contributions where required.
            Default: `"clojure"
`

Olical13:05:35

You can now set that to clojurescript and it'll run the cljs.test functions instead. I thought they were aliased though so clojure.test and cljs.test was ALWAYS the same thing? I always use clojure.test in my clojurescript

Olical13:05:39

Or used to, when I wrote it

Olical13:05:45

This is on the develop branch of Conjure btw

Olical13:05:21

But added that config just in case you can't do that for some reason

barrell07:05:20

Yeah I’ve definitely run them before with Conjure, I’m not sure why they’re failing with that error now. Thanks for adding it 🙂