Fork me on GitHub
#conjure
<
2022-07-01
>
practicalli-johnny18:07:44

I usually have multiple expressions in a (comment ,,,) form. Is there a way to evaluate just one form, rather than turning the whole (comment ,,,) form into a do expression? https://clojurians.slack.com/archives/CK143P6D7/p1651753198041279?thread_ts=1651752113.938689&amp;cid=CK143P6D7 For example, if I have the following comment form with functions to start / stop / restart various components, I only want to call one, not all of them

(comment 
  (mulog/set-global-context! {:app-name "awesome app" :version "0.1.0"}
  (go)
  (go :test)
  (reset)
  (halt))
I can use <leader>ee at the top level of each form which requires moving the cursor to the right place each time. If I evaluate to root though, then it evaluates the comment form (or a do if I use the substitution - I’ve tried to figure out a different substitution, but havent found anything useful yet). When I am designing functions and code, I’ll also use the (comment ,,,) for and have multi-line expressions within the individual forms I’m writing, so then I need to be able to jump the cursor to the top level of each individual form to evaluate it. I guess I should at least learn how to jump to the right place in the form as quickly as possible, perhaps jumping up nested forms. Unless I have missed something?

nate20:07:13

Having to move the cursor around in the forms in a comment block is the main reason I tend to use the #_(,,,) style for rich comments. That way, no matter where I am in the form, I can hit ,er to run the root form.

nate20:07:17

There was talk of making ,er find the second-to-top-level form when inside a comment block, but there was difficulty in doing that at the time.

nate20:07:44

When I do use comment forms (mostly when coworkers have added them), I tend to use the mark facility and “eval at mark” to run the code.

Olical09:07:21

So slight warning, I broke your workflow @U0510902N but I want to fix it. Since I'm now using tree-sitter correctly and selecting whole forms CORRECTLY... it means evaluating #_foo evaluates #_foo, including the comment prefix!

Olical09:07:32

So I want to make it so that you can have that workflow with tree sitter on the latest and greatest versions which may well be a good thing to tie into what John wants (actually many people have asked for this!) It's been a feature I could never offer realistically until tree sitter was widely adopted, I'm now in the space of treating tree sitter as the first class system and the older nvim regex syntax based one as the backup.

❤️ 2
Olical10:07:57

Did it, #_ is essentially stripped by Conjure on eval now (which I think is fine) and ,er _WITH TREESITTER ENABLED_ ignores the root comment block and allows you to eval forms inside comment blocks as if the surrounding comment doesn't exist.

👀 4
❤️ 3
practicalli-johnny10:07:32

I have :PackerSync on standby if you need a tester 😁

practicalli-johnny11:07:14

Looking great, thank you so much for this, it will make a huge difference.

Olical11:07:40

Glad to hear it! 😄

nate11:07:03

Oh this is so cool! I'll try this out as soon as I can, hopefully today.

nate12:07:13

Is getting “treesitter enabled” just a matter of having the latest nvim and installing https://github.com/nvim-treesitter/nvim-treesitter ?

nate12:07:05

Awesome! Thank you!!

practicalli-johnny12:07:12

I'm using Neovim 0.7.0 with the nvim-treesitter plugin added and it's worked okay. Just need a C compiler on your OS to compile the parsers for languages

nate12:07:45

Thank you for sharing your config @U05254DQM . Reading through it is inspiring me to finally take the leap and convert to lua/fennel.

nate12:07:39

Is there a fennel-for-neovim-config support group somewhere?

practicalli-johnny13:07:06

I get a lot of help from the #vim channel regarding fennel, as well as learning a lot from others.

practicalli-johnny13:07:30

I am starting to find it fairly easy to translate between lua config and fennel, especially where plugin developers have followed the plugin.setup approach.

practicalli-johnny13:07:17

Also take a look at https://github.com/rafaeldelboni/nvim-fennel-lsp-conjure-as-clojure-ide configuration, its where I learned most things from (and that repo learned a lot from Oli of course)

nate14:07:29

Cool. Thank you.

nate20:07:35

I've tried this out on linux (inside WSL), and on my mac and both times I couldn't evaluate #_() forms, and (comment ...) forms would work and then stop working once I edited the forms. Almost as if treesitter wasn't updating itself on edit

Olical10:07:07

That sounds like the same treesitter bug I've heard of when people have some other TS related plugins installed. There's reports of Conjure being unable to query the tree as if it's out of sync after the user makes some edits or uses some TS modifying plugin until they turn off TS Syntax support and turn it back on to force a re-parse. I think this is a Neovim bug and there's nothing I can do from my side 😞 It's as if I'm querying the DOM in a browser and the nodes don't reflect what's on screen. I would also recommend ensuring all of your TS language modules are fully up to date, but I suspect this is separate to that.

practicalli-johnny20:07:47

I can successfully evaluate code commented with #_ and (comment ,,,) form on my Linux and Mac Neovim 0.7.2 setup, with the above mentioned configuration. I did add configuration that automatically syncs parsers when nvim-treesitter is updated (I assume this is the same as manually running :TSUpdateSync), so this suggests issues may be related to outdated parsers. In the fnl/config/plugin/treesitter.fnl file I set the parsers to sync

(module config.plugin.treesitter
  {autoload {treesitter nvim-treesitter.configs}})

(treesitter.setup
  {:ensure_installed ["clojure" "fennel" "markdown" "org"]
   :sync_install true
   :highlight {:enable true}
   :indent    {:enable true}})

nate22:07:39

Hm, wonder if it might be because I'm using the 0.8.0 nightlies.

nate22:07:40

I had just installed the Clojure tree sitter parser, so I don't think out-of-date-ness was the issue. I’ll try updating it just in case.

practicalli-johnny19:07:08

On another note, I’ve https://github.com/practicalli/neovim-config-redux/blob/main/fnl/config/plugin/conjure.fnl which I think has all the many configuration options (let me know if I’ve missed any configuration sections)

Olical10:07:57
replied to a thread:I usually have multiple expressions in a `(comment ,,,)` form. Is there a way to evaluate just one form, rather than turning the whole `(comment ,,,)` form into a `do` expression? https://clojurians.slack.com/archives/CK143P6D7/p1651753198041279?thread_ts=1651752113.938689&amp;cid=CK143P6D7 For example, if I have the following comment form with functions to start / stop / restart various components, I only want to call one, not all of them (comment (mulog/set-global-context! {:app-name "awesome app" :version "0.1.0"} (go) (go :test) (reset) (halt)) I can use `&lt;leader&gt;ee` at the top level of each form which requires moving the cursor to the right place each time. If I evaluate to root though, then it evaluates the comment form (or a `do` if I use the substitution - I’ve tried to figure out a different substitution, but havent found anything useful yet). When I am designing functions and code, I’ll also use the `(comment ,,,)` for and have multi-line expressions within the individual forms I’m writing, so then I need to be able to jump the cursor to the top level of each individual form to evaluate it. I guess I should at least learn how to jump to the right place in the form as quickly as possible, perhaps jumping up nested forms. Unless I have missed something?

Did it, #_ is essentially stripped by Conjure on eval now (which I think is fine) and ,er _WITH TREESITTER ENABLED_ ignores the root comment block and allows you to eval forms inside comment blocks as if the surrounding comment doesn't exist.

👀 4
❤️ 3