rktjmp / hotpot.nvim

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

`include` path behavior should match `require` behavior #98

Closed shaunsingh closed 1 year ago

shaunsingh commented 1 year ago

When requiring a file under the fnl/ folder, e.g. fnl/core.fnl you can simply go (require :core). However, if you want to inline require (include) you have to write (include :fnl.core).

Not sure if this is a bug or intended behavior, just wanted to get clarification

rktjmp commented 1 year ago

include should not hit any hotpot infra as it's all internal to fennel and does its own "modname→modpath" searching AFAICT.

It looks like require but really it just has the same interface - require returns a function that returns a module where as include needs actual source code - so it will read that it itself.

I use it for hotpots loading, and must manually set fnl/?.fnl in the fennel path for it to find the files because lua/ is a nvim convention that we just extend to fennel in hotpot. Normally it just looks in the current dir/package.path.

https://github.com/rktjmp/hotpot.nvim/blob/1002bcdea7af06c5a7bfce0536d96bc4b03ab42e/fnl/hotpot.fnl#L7

https://github.com/rktjmp/hotpot.nvim/blob/1002bcdea7af06c5a7bfce0536d96bc4b03ab42e/build#L9-L12

What you can look at is adjusting fennel's fennel-path var (or whatever it would be called) after loading hotpot. Check the fennel API docs first. Depending on what you're doing though - you might have to add a lot of paths to it for everything in nvim to be found - it might be easier to just live with the prefix.

I'd also be careful of your cwd, as it's probably just working because ./?.lua is in the package.path and you might get unexpected failures running from other dirs.

shaunsingh commented 1 year ago

Thanks, looks like it is indeed easier to just live with the prefix