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

`(include mod)` depends on CWD / fennel.path value

Open rktjmp opened this issue 7 months ago • 1 comments

Hm..

test/macros.fnl does use include and builds without issues.

Using elsewhere seem fails to find the module.

  • Does fennel.include hit the regular infra or use its own file searcher?

rktjmp avatar Jan 06 '24 05:01 rktjmp

Seems it uses specials.search-module

(fn search-module [modulename ?pathstring]
  (let [pathsepesc (escapepat pkg-config.pathsep)
        pattern (: "([^%s]*)%s" :format pathsepesc pathsepesc)
        no-dot-module (modulename:gsub "%." pkg-config.dirsep)
        fullpath (.. (or ?pathstring utils.fennel-module.path)
                     pkg-config.pathsep)]
    (fn try-path [path]
      (let [filename (path:gsub (escapepat pkg-config.pathmark) no-dot-module)
            filename2 (path:gsub (escapepat pkg-config.pathmark) modulename)]
        (match (or (io.open filename) (io.open filename2))
          file (do
                 (file:close)
                 filename)
          _ (values nil (.. "no file '" filename "'")))))

Which uses utils.fennel-module.path, require("fennel").path == ./?.fnl;./?/init.fnl`

Testing include b from fnl/ does work, so its a fennel.path issue.

  • patch fennel.path to match package.path (really needs to match vim "rtp", package.path will not be sufficent) OR
  • ... cwd to match fnl/ when compiling? Probably not OR
  • patch fennel?

rktjmp avatar Jan 06 '24 05:01 rktjmp

We now just insert fnl/ into the relevant paths when compiling, then undo any change.

rktjmp avatar Aug 11 '24 15:08 rktjmp