Olical / aniseed

Neovim configuration and plugins in Fennel (Lisp compiled to Lua)
https://discord.gg/wXAMr8F
The Unlicense
610 stars 28 forks source link

aniseed initialization issue #137

Closed randomizedthinking closed 1 year ago

randomizedthinking commented 1 year ago

This is a subtle issue, and I will use an example to show it. Suppose the aniseed configuration is as follows that the aniseed init entry point is aniseed_init.fnl.

vim.g["aniseed#env"] = {
  module = "aniseed_init",
  compile = true
}

Yet, if I launch nvim in any folder with aniseed_init.lua file, then aniseed will use it as the initialization file. I think the issue is that aniseed (or maybe fennel) add the current directory to the search path: it might be fine for fennel coding but not for nvim.

Olical commented 1 year ago

We can't work around this, you need to use a more specific init module name, maybe prefix it with something. This is not Fennel or Aniseed at work here but the Lua package.path and require system. You should think of all of the lua directories on your system that are under the package.path as one big merged directory. So you shouldn't put things directly under lua/*.lua with generic names that may collide with other files from other directories.

I recommend prefixing everything like so: https://github.com/Olical/dotfiles/blob/main/stowed/.config/nvim/fnl/dotfiles/init.fnl

I keep my init under dotfiles.init which will end up in lua/dotfiles/init.lua which shouldn't conflict with anything else unless something else has a file called lua/dotfiles/init.lua. This is a core tenant of Lua and something devs will just have to deal with I'm afraid.