Skip to content

Commit

Permalink
Adds backward compatibility with previous lsp versions (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgomez authored Sep 23, 2024
1 parent a842e7a commit 8ff58eb
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/nimLsp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,13 @@ proc startLanguageServer(tryInstall: bool, state: ExtensionState) {.async.} =
state.client.onNotification(
"extension/statusUpdate",
proc(params: JsObject) =
if params.projectErrors.isUndefined:
params.projectErrors = newSeq[ProjectError]()
if params.pendingRequests.isUndefined:
params.pendingRequests = newSeq[PendingRequestStatus]()
if params.extensionCapabilities.isUndefined:
params.extensionCapabilities = newSeq[cstring]()

let lspStatus = jsonStringify(params).jsonParse(NimLangServerStatus)
# outputLine("Received status update " & jsonStringify(params))
refreshLspStatus(state.statusProvider, lspStatus),
Expand Down Expand Up @@ -641,10 +648,10 @@ proc getChildrenImpl(
"Waiting for nimlangserver to init", "", "", TreeItemCollapsibleState_None
)
]
if element.label == "LSP Status":
var topElements =
if element.label == "LSP Status":
var topElements =
@[
newLspItem("Langserver", self.status.get.lspPath),
newLspItem("Langserver", self.status.get.lspPath),
newLspItem("Version", self.status.get.version),
newLspItem("NimSuggest Instances", "", "", TreeItemCollapsibleState_Expanded),
] &
Expand Down Expand Up @@ -782,6 +789,7 @@ proc newNimLangServerStatusProvider*(): NimLangServerStatusProvider =
proc refreshLspStatus*(
self: NimLangServerStatusProvider, lspStatus: NimLangServerStatus
) =
# console.log(lspStatus)
self.status = some(lspStatus)
self.emitter.fire(nil)
# console.log(lspStatus.projectErrors)
Expand Down

0 comments on commit 8ff58eb

Please sign in to comment.