Skip to content

Commit cef1af9

Browse files
authored
chache nim dump results (#202)
1 parent 7ee193e commit cef1af9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

nimlangserver.nim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type
8787
isShutdown*: bool
8888
storageDir*: string
8989
cmdLineClientProcessId: Option[int]
90+
nimDumpCache: Table[string, NimbleDumpInfo] #path to NimbleDumpInfo
9091

9192
Certainty = enum
9293
None,
@@ -143,6 +144,8 @@ proc supportSignatureHelp(cc: ClientCapabilities): bool =
143144
caps.isSome and caps.get.signatureHelp.isSome
144145
145146
proc getNimbleDumpInfo(ls: LanguageServer, nimbleFile: string): NimbleDumpInfo =
147+
if nimbleFile in ls.nimDumpCache:
148+
return ls.nimDumpCache[nimbleFile]
146149
let info = execProcess("nimble dump " & nimbleFile)
147150
for line in info.splitLines:
148151
if line.startsWith("srcDir"):
@@ -154,6 +157,12 @@ proc getNimbleDumpInfo(ls: LanguageServer, nimbleFile: string): NimbleDumpInfo =
154157
if line.startsWith("nimblePath"):
155158
result.nimblePath = some line[(1 + line.find '"')..^2]
156159

160+
var nimbleFile = nimbleFile
161+
if nimbleFile == "" and result.nimblePath.isSome:
162+
nimbleFile = result.nimblePath.get
163+
if nimbleFile != "":
164+
ls.nimDumpCache[nimbleFile] = result
165+
157166
proc getProjectFileAutoGuess(ls: LanguageServer, fileUri: string): string =
158167
let file = fileUri.decodeUrl
159168
result = file

0 commit comments

Comments
 (0)