Olical / aniseed

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

Improve macro.fnl file support #62

Closed Olical closed 2 years ago

Olical commented 3 years ago

Right now I think files called macros.fnl are the only ones copied over to the lua dir on compilation which ensures they end up on the path. That path is used when requiring the macros, so if your macro file isn't named appropriately it either won't be copied into the right place or Ansieed will try to compile it which will error since macro files can't be compiled.

There's no way to tell that something contains macros without prior knowledge, so we still have to make assumptions. I think the best bet is defaulting to finding anything ending in macros.fnl and making it easily reconfigurable. Then maybe don't copy them, but just add them to an exclude pattern then add the fnl dir to the macros path. (which is new in the latest fennel version!)

datwaft commented 3 years ago

I was just having this issue while trying to separate my macros into multiple files.

I was trying to do something like:

.
├── fnl
│   └── core
│       ├── init.fnl
│       └── macros
│           ├── core-macros.fnl
│           ├── pack-macros.fnl
│           └── vim-macros.fnl
└── init.lua
Olical commented 3 years ago

Out of interest, does it work fine on the develop branch? I couldn't actually spot any issues but I've done some work around this area and written some more tests so I may have caught it now 🤔

I've made a LOT of changes on develop so the module macros compile to much more efficient / minimal Lua and there's a few issues around interactive evaluation that I'm still working out https://github.com/Olical/aniseed/issues/63

So bearing in mind there's other issues I'm fixing, it might still be worth checking if the macro file problem is fixed. I've tried this myself on developand fnl/dotfiles/plugin/some-macros.fnl worked fine for me 🤔 although I think I did have to restart nvim for it to work.

datwaft commented 3 years ago

Doesn't seem to work. It gives this error:

E5108: Error executing lua ...m/site/pack/packer/start/aniseed/lua/aniseed/compile.lua:73: Could not open file: /home/datwaft/.config/nvim.main/lua/core/macros/core-macros.fnl: No such file or directory

Here is the tree view:

fnl/core
├── autocmd.fnl
├── globals.fnl
├── init.fnl
├── lsp.fnl
├── macros
│   ├── core-macros.fnl
│   └── vim-macros.fnl
├── mapping.fnl
├── options.fnl
├── plugin
│   ├── anywise-reg.fnl
│   ├── camel-case-motion.fnl
│   ├── colorscheme.fnl
│   ├── compe.fnl
│   ├── conjure.fnl
│   ├── devicons.fnl
│   ├── file-explorer.fnl
│   ├── gitsigns.fnl
│   ├── hexokinase.fnl
│   ├── hlslens.fnl
│   ├── indent-blankline.fnl
│   ├── lightbulb.fnl
│   ├── lspkind.fnl
│   ├── lspsaga.fnl
│   ├── navigator.fnl
│   ├── nrpattern.fnl
│   ├── slime.fnl
│   ├── spellsitter.fnl
│   ├── statusline.fnl
│   ├── telescope.fnl
│   ├── tmux.fnl
│   ├── traces.fnl
│   ├── treesitter.fnl
│   ├── trouble.fnl
│   ├── which-key.fnl
│   ├── wilder.fnl
│   └── window.fnl
├── plugin.fnl
└── utils
    └── io.fnl
Olical commented 3 years ago

Hm, so odd, I can't reproduce that but I'll try to some time soon. I'm clearly missing something since it works absolutely fine for me, so maybe I'm doing something extra that I forgot about.

Do you have some config for aniseed#env that moves the default fnl/lua directory paths?

datwaft commented 3 years ago

This is my init.lua file:

local execute = vim.api.nvim_command
local fn = vim.fn
local fmt = string.format
local pack_path = fn.stdpath("data") .. "/site/pack"
local function ensure(user, repo)
  local install_path = fmt("%s/packer/start/%s", pack_path, repo, repo)
  if fn.empty(fn.glob(install_path)) > 0 then
    execute(fmt("!git clone https://github.com/%s/%s %s", user, repo,
                install_path))
    execute(fmt("packadd %s", repo))
  end
end
ensure("wbthomason", "packer.nvim")
ensure("Olical", "aniseed")
vim.g["aniseed#env"] = {module = "core.init"}

As you can see I am doing vim.g["aniseed#env"] = {module = "core.init"} as per the documentation (at least the documentation of when I created the configuration).

datwaft commented 3 years ago

Even with let g:aniseed#env = v:true it fails.

Olical commented 2 years ago

This is actually working fine for me now so I think I fixed it a while back in other changes? Please reopen if not!