hotpot.nvim icon indicating copy to clipboard operation
hotpot.nvim copied to clipboard

Few feature requests

Open monkoose opened this issue 1 year ago • 10 comments

Hello again. I have done converting from anissed. Have a lot of improvements during this road. And really like how cache and AOT works.

Still can think of some improvements to other parts of hotpot:

  • make Fnl command works the same as :lua which can accept = before the command to convert it to print(vim.inspect(expr)). More info :h :lua. Not sure if it worth the effort to parse = maybe new command Fnl! would be better?
  • Could be reflection api suffixed with some provided form (injected) from the user input that would evaluate after selected block? Something like add the form with command lets say :HotpotReflectionForm (func-name arg1 arg2) or just lua function that accepts string (and let user leverage how to get it). For sure it can be added as the last form of the reflection range, but if reflection range took few+ pages length it is not so convenient to jump to this location and edit the form then jump back even with markers. And it pollute buffer/file with sometime forgotten lines. I guess it's the workflow for such repl like style anyway to see evaluation of the thing you are working on and if it is correct, no?

Anyway thank you so much for your hard work on this plugin.

monkoose avatar Sep 14 '22 04:09 monkoose

I agree about the :lua = mirroring, I had thought that myself. Have not looked into how hard it would be to duplicate but """"probably"""" easy enough just to if str.starts_with("=") then print else dont print.

Can you explain a bit more on your second point? Do you mean something like :

(fn post-process [code opts something something]
  "prepend line number to given string"
  (icollect [line, num in code] (.. num ": " line))
(api.reflect.set-reflect-into post-process)

Then your reflect output would have each line have an attached line number? That kind of idea?

What kind of results were you looking to achieve?

I think the idea is fine but probably needs some thought work, without really checking, we can probably pass back:

  • lua code as a string
  • lua code as a function (??)
  • result-values from evaluation (so the actual number, table, string, function that the code results in)

Passing back a lua-code-as-function is probably pretty useless as you could just use the fennel result-values in the same way, or if you really want a function you can loadstring with "lua code as string".

I wonder how well this would fit with the existing API, where instead of reflect.attach-output buf you might do reflect.attach-pipe func, which may or may not then leave the buffer-writing to the user. Probably simplest if each call replaced the last "pipe", but you could pass in an array of functions to route through in sequence.

There are some complications with stuff like outputting printed statements and the source-location information in the buffer when doing that.

I am guessing that you already do a bit of what you describe, most curious about your actual use case.

rktjmp avatar Sep 14 '22 06:09 rktjmp

Can you explain a bit more on your second point?

I think you do get it mostly. Yes, some kind of post-process function that would add some arbitrary code block (or at least just ONE form) which is evaluated as last form and it's result (if no errors) would be visible in reflect buffer. This arbitrary block could be added by something like vim.input or just ordinary vim command with argument. And i think it doesn't need to do something with compile mode, only in eval mode. I'm not sure it should even be post-process (if you say it's hard to impement with current implementation), why not just before reflect do it thing on a range in a buffer append to this range (not sure how it implemented and if this is possible)?

monkoose avatar Sep 14 '22 06:09 monkoose

Offtopic questions.

  • Can i reach you somewhere or some hotpot/neovim fennel community for different questions?
  • Would it still be valuable to use impatient.nvim even though hotpot use some kind of bytecode cache? Removed it before switching and not sure should i try it and test again.

monkoose avatar Sep 14 '22 06:09 monkoose

@monkoose there's discourse server which hosted by Aniseed/Conjure author. Also you could go to #fennel matrix to talk everything related to Fennel :) I removed impatient.nvim because of the reason you already mentioned. See no big difference about startup time at all!

bangedorrunt avatar Sep 14 '22 06:09 bangedorrunt

@babygau maybe rktjmp could create some matrix channel for hotpot if he uses it, do you want to do this @rktjmp ?

monkoose avatar Sep 14 '22 06:09 monkoose

@babygau maybe rktjmp could create some matrix channel for hotpot if he uses it, do you want to do this @rktjmp ?

Just worry that we don't have much participants 😅

bangedorrunt avatar Sep 14 '22 07:09 bangedorrunt

@babygau maybe rktjmp could create some matrix channel for hotpot if he uses it, do you want to do this @rktjmp ?

Just worry that we don't have much participants sweat_smile

Don't think it does matter much. Just chat in time when there is activity and ask your questions in that period thats all. But definitely it would be dead at the beginning anyway.

monkoose avatar Sep 14 '22 07:09 monkoose

well, it takes nothing to give it a go, right 🍭

bangedorrunt avatar Sep 14 '22 07:09 bangedorrunt

Support for :Fnl= added in a71c37feb8fe878d54f15135ddea0d2b3ea04a44.

impatient

You should be fine to drop impatient, hotpot has what should be equivalent functionality.

matrix/etc

I don't really have the energy or inclination to manage a channel, and I think it is mostly already covered by the neovim and fennel channels.

There isn't - our shouldn't be - really much specific hotpot things to talk about really outside of setup issues which is better discussed in a more open format like these issues , or fixed in the documentation. I do hang around in those channels when I have time but not so much lately.

Also I don't want to offload support into Aniseeds/olical but generally any sort of "nvim ++ fennel macro/function" kind of questions should be pretty transportable between the two projects - perhaps after manually porting over a macro or two.

The community is probably better served by a #neovim-fennel channel that can congregate all the "runtimes" (and people who just fennel -c *.fnl!) together into one place as they all share probably 90% of the same ideals.

reflect

I am still a bit vague on the usecase of the reflect idea, can you give an example from your config? It seems that you really want to inject actual code that has access to all values in scope? Not just operate on the final values of evaluating the selected range?

rktjmp avatar Sep 17 '22 13:09 rktjmp

@rktjmp I have made some self made function that just puts form before ending reflect extmark. So it works some what i wanted. So if you still not sure about how reflect should look and behave in general. I guess this issue can be closed.

monkoose avatar Sep 17 '22 15:09 monkoose

So should i close this? As i previously mentioned i did implement some hacky solution that do what i want. Or you are still considering implementing something like this?

monkoose avatar Sep 24 '22 18:09 monkoose

Not against improving the reflect api, quite the opposite! Just still a bit lost about the end goal of the request.

I saw you have a nvim-fennel repo online, does that include any example of your usage?

rktjmp avatar Sep 26 '22 04:09 rktjmp