Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Adds extension capabilities to status. Fixes a race condition in che… #233

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions ls.nim
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ type
onMainReadSignal*: ThreadSignalPtr #used by the main thread to notify it read the value from the signal
value*: cstring

LspExtensionCapability* = enum #List of extensions this server support. Useful for clients
excRestartSuggest = "RestartSuggest"

LanguageServer* = ref object
clientCapabilities*: ClientCapabilities
extensionCapabilities*: set[LspExtensionCapability]
Expand Down Expand Up @@ -269,6 +266,7 @@ proc showMessage*(ls: LanguageServer, message: string, typ: MessageType) {.raise

proc getLspStatus*(ls: LanguageServer): NimLangServerStatus {.raises: [].} =
result.version = LSPVersion
result.extensionCapabilities = ls.extensionCapabilities.toSeq
for projectFile, futNs in ls.projectFiles:
let futNs = ls.projectFiles.getOrDefault(projectFile, nil)
if futNs.finished:
Expand All @@ -279,7 +277,7 @@ proc getLspStatus*(ls: LanguageServer): NimLangServerStatus {.raises: [].} =
capabilities: ns.capabilities.toSeq,
version: ns.version,
path: ns.nimsuggestPath,
port: ns.port,
port: ns.port
)
for open in ns.openFiles:
nsStatus.openFiles.add open
Expand Down Expand Up @@ -764,12 +762,13 @@ proc checkFile*(ls: LanguageServer, uri: string): Future[void] {.async.} =
let
path = uriToPath(uri)
ns = await ls.tryGetNimsuggest(uri)

let diagnostics = ns.get()
.chkFile(path, ls.uriToStash(uri))
.await()

ls.progress(token, "end")

ls.sendDiagnostics(diagnostics, path)

if ns.isSome:
let diagnostics = ns.get()
.chkFile(path, ls.uriToStash(uri))
.await()
ls.progress(token, "end")
ls.sendDiagnostics(diagnostics, path)
else:
ls.progress(token, "end")

4 changes: 4 additions & 0 deletions protocol/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -986,10 +986,14 @@ type
openFiles*: seq[string]
unknownFiles*: seq[string]

LspExtensionCapability* = enum #List of extensions this server support. Useful for clients
excRestartSuggest = "RestartSuggest"

NimLangServerStatus* = object
version*: string
nimsuggestInstances*: seq[NimSuggestStatus]
openFiles*: seq[string]
extensionCapabilities*: seq[LspExtensionCapability]

NimLangServerStatusParams* = object

Expand Down
Loading