Skip to content

Commit

Permalink
chache nim dump results
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgomez committed May 30, 2024
1 parent 7ee193e commit 73489e9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions nimlangserver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type
isShutdown*: bool
storageDir*: string
cmdLineClientProcessId: Option[int]
nimDumpCache: Table[string, NimbleDumpInfo] #path to NimbleDumpInfo

Certainty = enum
None,
Expand Down Expand Up @@ -143,6 +144,8 @@ proc supportSignatureHelp(cc: ClientCapabilities): bool =
caps.isSome and caps.get.signatureHelp.isSome

proc getNimbleDumpInfo(ls: LanguageServer, nimbleFile: string): NimbleDumpInfo =
if nimbleFile in ls.nimDumpCache:
return ls.nimDumpCache[nimbleFile]
let info = execProcess("nimble dump " & nimbleFile)
for line in info.splitLines:
if line.startsWith("srcDir"):
Expand All @@ -154,6 +157,12 @@ proc getNimbleDumpInfo(ls: LanguageServer, nimbleFile: string): NimbleDumpInfo =
if line.startsWith("nimblePath"):
result.nimblePath = some line[(1 + line.find '"')..^2]

var nimbleFile = nimbleFile
if nimbleFile == "" and result.nimblePath.isSome:
nimbleFile = result.nimblePath.get
if nimbleFile != "":
ls.nimDumpCache[nimbleFile] = result

proc getProjectFileAutoGuess(ls: LanguageServer, fileUri: string): string =
let file = fileUri.decodeUrl
result = file
Expand Down

0 comments on commit 73489e9

Please sign in to comment.