Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fox0430 committed Oct 20, 2024
1 parent 59c6838 commit fad6052
Show file tree
Hide file tree
Showing 11 changed files with 253 additions and 215 deletions.
4 changes: 2 additions & 2 deletions src/moepkg/callhierarchyviewer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ proc incomingCalls(status: var EditorStatus) =
let infoIndex =
currentMainWindowNode.currentLine - CallHierarchyViewHeaderLength

let r = status.lspClients[langId.get].textDocumentIncomingCalls(
let r = waitFor status.lspClients[langId.get].textDocumentIncomingCalls(
currentBufStatus.id,
currentBufStatus.callHierarchyInfo.items[infoIndex])
if r.isErr:
Expand All @@ -109,7 +109,7 @@ proc outgoingCalls(status: var EditorStatus) =
let infoIndex =
currentMainWindowNode.currentLine - CallHierarchyViewHeaderLength

let r = status.lspClients[langId.get].textDocumentOutgoingCalls(
let r = waitFor status.lspClients[langId.get].textDocumentOutgoingCalls(
currentBufStatus.id,
currentBufStatus.callHierarchyInfo.items[infoIndex])
if r.isErr:
Expand Down
26 changes: 13 additions & 13 deletions src/moepkg/editorstatus.nim
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ proc cancelLspForegroundRequest*(
if c.isInitialized:
let fgRes = c.getForegroundWaitingResponse(bufferId)
if fgRes.isSome:
let err = c.cancelForegroundRequest(bufferId)
let err = waitFor c.cancelForegroundRequest(bufferId)
if err.isOk:
return Result[LspMethod, string].ok fgRes.get.lspMethod
else:
Expand Down Expand Up @@ -342,15 +342,15 @@ proc lspInitialize*(

if not status.lspClients.contains(langId):
# Init a LSP client and start a LSP server.
var c = initLspClient(
var c = waitFor initLspClient(
$status.settings.lsp.languages[langId].command)
if c.isErr:
return Result[(), string].err c.error

status.lspClients[langId] = c.get

# Initialize request
let err = status.lspClients[langId].initialize(
let err = waitFor status.lspClients[langId].initialize(
status.bufStatus[^1].id,
initInitializeParams(
status.lspClients[langId].serverName,
Expand Down Expand Up @@ -446,7 +446,7 @@ proc addNewBuffer*(
status.settings.lsp.languages.contains(newBufStatus.langId):
if status.lspClients.contains(newBufStatus.langId):
# textDocument/didOpen notification
let err = lspClient.textDocumentDidOpen(
let err = waitFor lspClient.textDocumentDidOpen(
$newBufStatus.path.absolutePath,
newBufStatus.langId,
newBufStatus.buffer.toString)
Expand Down Expand Up @@ -689,15 +689,15 @@ proc sendLspSemanticTokenRequest*(c: var LspClient, b: BufferStatus) =

block:
# Cancel before completion request.
let err = c.cancelRequest(
let err = waitFor c.cancelRequest(
b.id,
LspMethod.textDocumentSemanticTokensFull)
if err.isErr:
error fmt"lsp: {err.error}"

block:
# Send a textDocument/semanticTokens request to the LSP server.
let err = c.textDocumentSemanticTokens(b.id, $b.absolutePath)
let err = waitFor c.textDocumentSemanticTokens(b.id, $b.absolutePath)
if err.isErr:
error fmt"lsp: {err.error}"

Expand All @@ -710,7 +710,7 @@ proc sendLspInlayHintRequest*(

block:
# Cancel before inlayHint request.
let err = c.cancelRequest(b.id, LspMethod.textDocumentInlayHint)
let err = waitFor c.cancelRequest(b.id, LspMethod.textDocumentInlayHint)
if err.isErr: error fmt"lsp: {err.error}"

# Calc range from all views.
Expand All @@ -731,7 +731,7 @@ proc sendLspInlayHintRequest*(
if b.buffer[last].high >= 0: b.buffer[last].high
else: 0

let err = c.textDocumentInlayHint(b.id, $b.absolutePath, hintRange)
let err = waitFor c.textDocumentInlayHint(b.id, $b.absolutePath, hintRange)
if err.isErr: error fmt"lsp: {err.error}"

b.inlayHints.range = Range(
Expand All @@ -747,7 +747,7 @@ proc sendLspInlineValueRequest*(

block:
# Cancel before inlineValue request.
let err = c.cancelRequest(b.id, LspMethod.textDocumentInlineValue)
let err = waitFor c.cancelRequest(b.id, LspMethod.textDocumentInlineValue)
if err.isErr: error fmt"lsp: {err.error}"

# Calc range from all views.
Expand All @@ -768,7 +768,7 @@ proc sendLspInlineValueRequest*(
if b.buffer[last].high >= 0: b.buffer[last].high
else: 0

let err = c.textDocumentInlineValue(b.id, $b.absolutePath, valueRange)
let err = waitFor c.textDocumentInlineValue(b.id, $b.absolutePath, valueRange)
if err.isErr: error fmt"lsp: {err.error}"

b.inlineValues.range = Range(
Expand All @@ -778,7 +778,7 @@ proc sendLspInlineValueRequest*(
proc sendLspCodeLens*(c: var LspClient, b: BufferStatus) =
## Send textDocument/codeLens requests to the LSP server.

let err = c.textDocumentCodeLens(b.id, $b.absolutePath)
let err = waitFor c.textDocumentCodeLens(b.id, $b.absolutePath)
if err.isErr:
error fmt"lsp: {err.error}"

Expand Down Expand Up @@ -832,7 +832,7 @@ proc updateSyntaxHighlightings(status: EditorStatus) =

if isSendDidChange():
# Send a textDocument/didChange notification to the LSP server.
let err = client.textDocumentDidChange(
let err = waitFor client.textDocumentDidChange(
b.version,
absPath,
b.buffer.toString)
Expand Down Expand Up @@ -1527,7 +1527,7 @@ proc autoSave(status: var EditorStatus) =

if bufStatus.isEditMode and status.lspClients.contains(bufStatus.langId):
# Send textDocument/didSave notify to the LSP server.
let err = status.lspClients[bufStatus.langId].textDocumentDidSave(
let err = waitFor status.lspClients[bufStatus.langId].textDocumentDidSave(
bufStatus.version,
$bufStatus.path.absolutePath,
$bufStatus.buffer)
Expand Down
14 changes: 7 additions & 7 deletions src/moepkg/exmode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ proc writeCommand(status: var EditorStatus, path: Runes) =

if status.lspClients.contains(currentBufStatus.langId):
# Send textDocument/didSave notify to the LSP server.
let err = lspClient.textDocumentDidSave(
let err = waitFor lspClient.textDocumentDidSave(
currentBufStatus.version,
$currentBufStatus.path.absolutePath,
$currentBufStatus.buffer)
Expand Down Expand Up @@ -874,7 +874,7 @@ proc writeAndQuitCommand(status: var EditorStatus) =

if status.lspClients.contains(currentBufStatus.langId):
# Send textDocument/didSave notify to the LSP server.
let err = lspClient.textDocumentDidSave(
let err = waitFor lspClient.textDocumentDidSave(
currentBufStatus.version,
$currentBufStatus.path.absolutePath,
$currentBufStatus.buffer)
Expand Down Expand Up @@ -1133,7 +1133,7 @@ proc lspExecuteCommand(status: var EditorStatus, command: seq[Runes]) =
status.commandLine.writeLspExecuteCommandError("unknow command")
return

let r = lspClient.workspaceExecuteCommand(
let r = waitFor lspClient.workspaceExecuteCommand(
currentBufStatus.id,
lspCommand,
%*command[1 .. ^1].mapIt($it))
Expand All @@ -1154,7 +1154,7 @@ proc lspFoldingRange(status: var EditorStatus) =
"folding range is unavailable")
return

let r = lspClient.textDocumentFoldingRange(
let r = waitFor lspClient.textDocumentFoldingRange(
currentBufStatus.id,
$currentBufStatus.absolutePath)
if r.isErr:
Expand All @@ -1167,7 +1167,7 @@ proc lspRestartClient(status: var EditorStatus) =
status.commandLine.writeLspError("Client not found")
return

let r = lspClient.restart
let r = waitFor lspClient.restart
if r.isOk:
status.commandLine.writeStandard(fmt"lsp: restarted client: {lspClient.serverName}")
else:
Expand All @@ -1176,7 +1176,7 @@ proc lspRestartClient(status: var EditorStatus) =
let langId = currentBufStatus.langId
for b in status.bufStatus:
if b.langId == langId:
let r = lspClient.initialize(
let r = waitFor lspClient.initialize(
status.bufStatus[^1].id,
initInitializeParams(
lspClient.serverName,
Expand All @@ -1200,7 +1200,7 @@ proc lspDocumentFormatting(status: var EditorStatus) =
insertSpaces: true,
insertFinalNewline: some(true))

let r = lspClient.textDocumentFormatting(
let r = waitFor lspClient.textDocumentFormatting(
currentBufStatus.id,
$currentBufStatus.absolutePath,
options)
Expand Down
6 changes: 3 additions & 3 deletions src/moepkg/insertmode.nim
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ proc sendDidChangeNotify(status: var EditorStatus): Result[(), string] =
first: currentMainWindowNode.bufferPosition,
last: currentMainWindowNode.bufferPosition)

let err = lspClient.textDocumentDidChange(
let err = waitFor lspClient.textDocumentDidChange(
currentBufStatus.version,
$currentBufStatus.path.absolutePath,
currentBufStatus.buffer.toString,
Expand All @@ -111,7 +111,7 @@ proc sendCompletionRequest(
block:
let isIncompleteTrigger = status.completionWindow.isSome

let err = lspClient.textDocumentCompletion(
let err = waitFor lspClient.textDocumentCompletion(
currentBufStatus.id,
$currentBufStatus.path.absolutePath,
currentMainWindowNode.bufferPosition,
Expand Down Expand Up @@ -141,7 +141,7 @@ proc sendSignatureHelpRequest(
if r.isSome: SignatureHelpTriggerKind.TriggerCharacter
else: SignatureHelpTriggerKind.Invoked

let err = lspClient.textDocumentSignatureHelp(
let err = waitFor lspClient.textDocumentSignatureHelp(
currentBufStatus.id,
$currentBufStatus.path.absolutePath,
currentMainWindowNode.bufferPosition,
Expand Down
Loading

0 comments on commit fad6052

Please sign in to comment.