Skip to content

Commit f5c145a

Browse files
authored
Fixes nim check misleading errors in nimble files due to nimscriptapi (#276)
- Disables autoinclude of nimscriptapi in nimsuggest due to nimsuggest crashes
1 parent 9aeb8d3 commit f5c145a

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

suggestapi.nim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,9 +355,10 @@ proc createNimsuggest*(
355355
var extraArgs = newSeq[string]()
356356
if isNimScript:
357357
extraArgs.add("--import: system/nimscript")
358-
if isNimble:
359-
let nimScriptApiPath = getNimScriptAPITemplatePath()
360-
extraArgs.add("--include: " & nimScriptApiPath)
358+
#Nimsuggest crashes when including the file.
359+
# if isNimble:
360+
# let nimScriptApiPath = getNimScriptAPITemplatePath()
361+
# extraArgs.add("--include: " & nimScriptApiPath)
361362
362363
let ns = Nimsuggest()
363364
ns.requestQueue = Deque[SuggestCall]()

templates/nimscriptapi.nim

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import system except getCommand, setCommand, switch, `--`
77
import strformat, strutils, tables, sequtils
88
export tables
99

10-
when (NimMajor, NimMinor) < (1, 3):
11-
when not defined(nimscript):
12-
import os
13-
else:
14-
import os
1510

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

35-
nimbleTasks: seq[tuple[name, description: string]] = @[]
36-
beforeHooks: seq[string] = @[]
37-
afterHooks: seq[string] = @[]
38-
flags: Table[string, seq[string]]
30+
nimbleTasks*: seq[tuple[name, description: string]] = @[]
31+
beforeHooks*: seq[string] = @[]
32+
afterHooks*: seq[string] = @[]
33+
flags*: Table[string, seq[string]]
3934
namedBin*: Table[string, string]
4035

41-
command = "e"
42-
project = ""
43-
success = false
44-
retVal = true
45-
nimblePathsEnv = "__NIMBLE_PATHS"
36+
command* = "e"
37+
project* = ""
38+
success* = false
39+
retVal* = true
40+
nimblePathsEnv* = "__NIMBLE_PATHS"
4641

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

5954
proc getParams(): tuple[scriptFile, projectFile, outFile, actionName: string,
6055
commandLineParams: seq[string]] =
56+
result = (scriptFile: "", projectFile: "", outFile: "", actionName: "", commandLineParams: @[])
6157
# Called by nimscriptwrapper.nim:execNimscript()
6258
# nim e --flags /full/path/to/file.nims /full/path/to/file.nimble /full/path/to/file.out action
63-
for i in 2 .. paramCount():
59+
for i in 2 .. nimscript.paramCount():
6460
let
65-
param = paramStr(i)
61+
param = nimscript.paramStr(i)
6662
if param[0] != '-':
6763
if result.scriptFile.len == 0:
6864
result.scriptFile = param

0 commit comments

Comments
 (0)