Skip to content

Commit

Permalink
Fixes nim check misleading errors in nimble files due to nimscriptapi (
Browse files Browse the repository at this point in the history
…#276)

- Disables autoinclude of nimscriptapi in nimsuggest due to nimsuggest crashes
  • Loading branch information
jmgomez authored Jan 8, 2025
1 parent 9aeb8d3 commit f5c145a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
7 changes: 4 additions & 3 deletions suggestapi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,10 @@ proc createNimsuggest*(
var extraArgs = newSeq[string]()
if isNimScript:
extraArgs.add("--import: system/nimscript")
if isNimble:
let nimScriptApiPath = getNimScriptAPITemplatePath()
extraArgs.add("--include: " & nimScriptApiPath)
#Nimsuggest crashes when including the file.
# if isNimble:
# let nimScriptApiPath = getNimScriptAPITemplatePath()
# extraArgs.add("--include: " & nimScriptApiPath)

let ns = Nimsuggest()
ns.requestQueue = Deque[SuggestCall]()
Expand Down
28 changes: 12 additions & 16 deletions templates/nimscriptapi.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ import system except getCommand, setCommand, switch, `--`
import strformat, strutils, tables, sequtils
export tables

when (NimMajor, NimMinor) < (1, 3):
when not defined(nimscript):
import os
else:
import os

var
packageName* = "" ## Set this to the package name. It
Expand All @@ -32,17 +27,17 @@ var
foreignDeps*: seq[string] = @[] ## The foreign dependencies. Only
## exported for 'distros.nim'.

nimbleTasks: seq[tuple[name, description: string]] = @[]
beforeHooks: seq[string] = @[]
afterHooks: seq[string] = @[]
flags: Table[string, seq[string]]
nimbleTasks*: seq[tuple[name, description: string]] = @[]
beforeHooks*: seq[string] = @[]
afterHooks*: seq[string] = @[]
flags*: Table[string, seq[string]]
namedBin*: Table[string, string]

command = "e"
project = ""
success = false
retVal = true
nimblePathsEnv = "__NIMBLE_PATHS"
command* = "e"
project* = ""
success* = false
retVal* = true
nimblePathsEnv* = "__NIMBLE_PATHS"

proc requires*(deps: varargs[string]) =
## Call this to set the list of requirements of your Nimble
Expand All @@ -58,11 +53,12 @@ proc taskRequires*(task: string, deps: varargs[string]) =

proc getParams(): tuple[scriptFile, projectFile, outFile, actionName: string,
commandLineParams: seq[string]] =
result = (scriptFile: "", projectFile: "", outFile: "", actionName: "", commandLineParams: @[])
# Called by nimscriptwrapper.nim:execNimscript()
# nim e --flags /full/path/to/file.nims /full/path/to/file.nimble /full/path/to/file.out action
for i in 2 .. paramCount():
for i in 2 .. nimscript.paramCount():
let
param = paramStr(i)
param = nimscript.paramStr(i)
if param[0] != '-':
if result.scriptFile.len == 0:
result.scriptFile = param
Expand Down

0 comments on commit f5c145a

Please sign in to comment.