fix: implement cljnim compiler recommendations (10 fixes)

- #1: Support docstrings in defn/defn-
- #2: Support multi-arity defn with dispatch by args.len
- #3: (:key map) keyword-as-function syntax (cljGet)
- #4: & rest parameters in defn/defn-
- #5: Nim interop name mangling for nim/ module calls
- #6: getLibPath() checks CLJNIM_LIB_PATH env and cwd first
- #7: Parse :paths from deps.edn
- #8: loop+if/else discard fix with loopResult variable
- #10: emitProgramLib skips when isMainModule guard
This commit is contained in:
2026-05-12 00:42:17 +03:00
parent 32dbd1fc5d
commit e36bf4e362
3 changed files with 270 additions and 31 deletions
+7 -2
View File
@@ -3,13 +3,18 @@ import os, osproc, strutils, times
import reader, emitter, types, repl, macros, deps, ai_assist, tui
proc getLibPath(): string =
# Check environment variable first
let envPath = getEnv("CLJNIM_LIB_PATH", "")
if envPath.len > 0 and dirExists(envPath):
return envPath
# Check current directory's lib first (project-local libs)
let candidate0 = getCurrentDir() / "lib"
if dirExists(candidate0): return candidate0
let appDir = getAppDir()
let candidate1 = appDir / "lib"
let candidate2 = appDir.parentDir / "lib"
let candidate3 = getCurrentDir() / "lib"
if dirExists(candidate1): return candidate1
if dirExists(candidate2): return candidate2
if dirExists(candidate3): return candidate3
return "lib"
proc resolveNsToPath(nsName: string, searchPaths: seq[string]): string =