rktjmp / hotpot.nvim

:stew: Carl Weathers #1 Neovim Plugin.
MIT License
357 stars 9 forks source link

Recompilation via `require` fails silently #131

Closed bR3iN closed 6 months ago

bR3iN commented 6 months ago

Hi. First of all, thank you for your work on the plugin, it has worked great so far for me. However, I recently noticed that errors during recompilation of previously compiled modules are no longer shown.

Steps to reproduce:

Until recently, the last require would've produced an error displaying the error description produced by fennel. But now it just fails silently, loading the last succesfully compiled Lua file. When changing test.fnl without any syntax erros, the last require correctly picks up the changes.

I'll have to admit that I haven't read all the API documentation yet, so I can't say for sure if this is the intended way to do this, I only noted the regression; if there is another more "correct" way to recompile a module, I'd appreciate a pointer in the right direction.

rktjmp commented 6 months ago

Thanks for the report. I'm pretty sure I have already fixed this in an upcoming release which I just need some time to tidy up.

For now you could use this global function to unrequire a module, which also clears the cache.

(fn _G.__unrequire [...]
  (let [hotpot (require :hotpot)]
    (hotpot.api.cache.clear-cache))
  (each [module _ (pairs package.loaded)]
    (for [i 1 (select :# ...)]
      (let [unreq (select i ...)]
        (if (string.match module unreq)
          (do
            (print :unreq module)
            (tset package.loaded module nil)))))))
:=__unrequire("my.mod") -- unrequires my.mod my.mod.x my.mod.y etc etc

It will ask for confirmation to clear the cache and it clears the whole cache so its a pretty blunt instrument, but I will add an option in the upcoming to skip the prompt too.

rktjmp commented 6 months ago

Should be fixed in 87d2c346b940438388ec48e376f92d944fcb7efc with according regression test in ebc9bfc3484fa2e040f2cbb2ac9ca1b45cc8b2c6.

bR3iN commented 5 months ago

Hi. Sorry for not coming back to you earlier. It now works again as expected. Thanks!