beef331 / nimscripter

Quick and easy Nim <-> Nimscript interop
MIT License
149 stars 8 forks source link

Nimscripter should require "compiler" #12

Closed PMunch closed 1 year ago

PMunch commented 2 years ago

Just added nimscripter as a dependency to my package and noticed that it failed to build with the error:

/home/peter/.nimble/pkgs/nimscripter-1.0.12/nimscripter.nim:(1, 17) Error: cannot open file: compiler/nimeval

Adding requires "compiler" fixes it, but shouldn't this be done in nimscripter instead?

beef331 commented 2 years ago

Add --path:"$nim" so it uses the Nim compiler's lib that you're compiling with, requires "compiler" is tedious to maintain since it does not force the api to match the compiler version.

bung87 commented 2 years ago

why not use mImport like nimlsp does.

macro mImport(path: static[string]): untyped =
  result = newNimNode(nnkStmtList)
  result.add(quote do:
    import `path`
  )

https://github.com/PMunch/nimlsp/blob/2d9ecc661da179d5b0b81477890046c075e25f61/src/nimlsppkg/suggestlib.nim#L5

PMunch commented 2 years ago

I think this might be related to this issue: https://github.com/PMunch/ratel/issues/12

beef331 commented 2 years ago

@PMunch yea it's probably related, I still just dont like any of the possible solutions. Guess I need to grow up and just choose one.

PMunch commented 2 years ago

This is a problem for NimLSP as well. In fact it's a problem for any package that tries to use the Nim compiler. The fact that the compiler package doesn't actually work to build things with the compiler is a shame.

beef331 commented 1 year ago

Closed by https://github.com/beef331/nimscripter/commit/a76d785bf1d4aea064a5f08066949ba063f5fbe3 (v1.0.21) apparently one can do import "$nim"/compiler/module

See this PR for reference. https://github.com/nim-lang/Nim/pull/21662/files