Pangoraw / Neige.jl

☃️ Neovim Evaluator for Julia
MIT License
7 stars 1 forks source link

Improve code evaluation: skip inline comments #4

Open kataklasm opened 4 months ago

kataklasm commented 4 months ago

This will skip code evaluation if it finds the next node to be an inline comment. This fixes the issue of accidentally hiding the code evaluation result that is printed with VirtualText if an inline comment follows the code in the same line.

This is EXPERIMENTAL and should be tested more before merging. I've tried on multiple files of different code formatting and commenting behaviour and it worked well for me. WIP for #3

kataklasm commented 4 months ago

Just noticed I screwed up the PR/commit somehow... fixing it.

edit: works now.

It is still putting the cursor onto the inline comment for now, so it still requires two evals to go to the next line but the eval result won't disappear anymore. I will work on the cursor jumping later, out of time right now.

kataklasm commented 4 months ago

This PR now fixes the most egregious behaviour faults for node evaluation:

More detailed explanation can be found in the commit messages.

Pangoraw commented 4 months ago

I think we can just remove the first condition here to achieve the same effect?

https://github.com/Pangoraw/Neige.jl/blob/820dbd6a9a9a2672aa8fa7b252ebe9053fbd171e/lua/neige/init.lua#L180-L184

kataklasm commented 4 months ago

You mean remove the first <expr> or <expr> (node:type()) but keep the one with maybe_next:type()? If so, while that does fix the cursor jumping to the inline comment, it does not fix the fact that the VirtualText will show nothing but the success icon since the inline comment was still evaluated. My PR will skip the inline comment eval- and cursor-wise.