From 1e9c8fc43aac93d04c6cb2f0506e066329b4722b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=B0=86=E2=B0=8B=E2=B0=82=E2=B0=91=E2=B0=94=E2=B0=8E?= =?UTF-8?q?=E2=B0=80=E2=B0=82=20=C5=BDivoslav?= Date: Thu, 2 Oct 2025 17:01:20 +0200 Subject: [PATCH] corrected capitalization --- ls.nim | 68 +++++++++++++++++++++++----------------------- lstransports.nim | 2 +- nim.cfg | 2 +- protocol/types.nim | 2 +- routes.nim | 12 ++++---- suggestapi.nim | 44 +++++++++++++++--------------- utils.nim | 4 +-- 7 files changed, 67 insertions(+), 67 deletions(-) diff --git a/ls.nim b/ls.nim index 4197049..4e1b498 100644 --- a/ls.nim +++ b/ls.nim @@ -81,7 +81,7 @@ type projectMapping*: OptionalSeq[NlsNimsuggestConfig] workingDirectoryMapping*: OptionalSeq[NlsWorkingDirectoryMaping] checkOnSave*: Option[bool] - nimsuggestPath*: Option[string] + nimSuggestPath*: Option[string] timeout*: Option[int] autoRestart*: Option[bool] autoCheckFile*: Option[bool] @@ -152,7 +152,7 @@ type inlayHintsRefreshRequest*: Future[JsonNode] didChangeConfigurationRegistrationRequest*: Future[JsonNode] filesWithDiags*: HashSet[string] - lastNimsuggest*: Future[Nimsuggest] + lastNimsuggest*: Future[NimSuggest] childNimsuggestProcessesStopped*: bool isShutdown*: bool storageDir*: string @@ -391,7 +391,7 @@ proc getLspStatus*(ls: LanguageServer): NimLangServerStatus {.raises: [].} = projectFile: project.file, capabilities: ns.capabilities.toSeq, version: ns.version, - path: ns.nimsuggestPath, + path: ns.nimSuggestPath, port: ns.port, ) for open in ns.openFiles: @@ -492,23 +492,23 @@ proc getNimSuggestPathAndVersion( let nimbleDumpInfo = await ls.getNimbleDumpInfo("") let nimDir = nimbleDumpInfo.nimDir.get "" - var nimsuggestPath = expandTilde(conf.nimsuggestPath.get("")) + var nimSuggestPath = expandTilde(conf.nimSuggestPath.get("")) var nimVersion = "" - if nimsuggestPath == "": + if nimSuggestPath == "": if nimDir != "" and nimDir.dirExists: nimVersion = getNimVersion(nimDir) & " from " & nimDir - nimsuggestPath = nimDir / "nimsuggest" + nimSuggestPath = nimDir / "nimsuggest" else: nimVersion = getNimVersion("") - nimsuggestPath = findExe "nimsuggest" + nimSuggestPath = findExe "nimsuggest" else: - nimVersion = getNimVersion(nimsuggestPath.parentDir) + nimVersion = getNimVersion(nimSuggestPath.parentDir) # ls.showMessage(fmt "Using {nimVersion}", MessageType.Info) debug "Using {nimVersion}", nimVersion = nimVersion - (nimsuggestPath, nimVersion) + (nimSuggestPath, nimVersion) proc getNimPath*(conf: NlsConfig): Option[string] = - if conf.nimSuggestPath.isSome and conf.nimsuggestPath.get().fileExists(): + if conf.nimSuggestPath.isSome and conf.nimSuggestPath.get().fileExists(): some(conf.nimSuggestPath.get.parentDir / "nim") else: let path = findExe "nim" @@ -597,7 +597,7 @@ proc workDoneProgressCreate*(ls: LanguageServer, token: string) = if ls.progressSupported: discard ls.call("window/workDoneProgress/create", %ProgressParams(token: token)) -proc cancelPendingFileChecks*(ls: LanguageServer, nimsuggest: Nimsuggest) = +proc cancelPendingFileChecks*(ls: LanguageServer, nimsuggest: NimSuggest) = # stop all checks on file level if we are going to run checks on project # level. for uri in nimsuggest.openFiles: @@ -678,7 +678,7 @@ proc toDiagnostic(suggest: Suggest): Diagnostic = let node = %*{ - "uri": pathToUri(filepath), + "uri": pathToUri(filePath), "range": range(line - 1, column, line - 1, endColumn), "severity": case forth @@ -741,7 +741,7 @@ proc sendDiagnostics*( ls.filesWithDiags.excl path proc warnIfUnknown*( - ls: LanguageServer, ns: Nimsuggest, uri: string, projectFile: string + ls: LanguageServer, ns: NimSuggest, uri: string, projectFile: string ): Future[void] {.async, gcsafe.} = let path = uri.uriToPath let isFileKnown = await ns.isKnown(path) @@ -756,7 +756,7 @@ proc createOrRestartNimsuggest*( ls: LanguageServer, projectFile: string, uri = "" ) {.gcsafe, raises: [].} -proc getNimsuggestInner(ls: LanguageServer, uri: string): Future[Nimsuggest] {.async.} = +proc getNimsuggestInner(ls: LanguageServer, uri: string): Future[NimSuggest] {.async.} = assert uri in ls.openFiles, "File not open" let projectFile = await ls.openFiles[uri].projectFile @@ -795,7 +795,7 @@ proc getNimsuggestInner(ls: LanguageServer, uri: string): Future[Nimsuggest] {.a proc tryGetNimsuggest*( ls: LanguageServer, uri: string -): Future[Option[Nimsuggest]] {.raises: [], gcsafe.} +): Future[Option[NimSuggest]] {.raises: [], gcsafe.} proc checkFile*(ls: LanguageServer, uri: string): Future[void] {.raises: [], gcsafe.} @@ -852,7 +852,7 @@ proc didOpenFile*( ls.openFiles[uri].fingerTable.add line.createUTFMapping() file.writeLine line file.close() - let ns = await ls.tryGetNimSuggest(uri) + let ns = await ls.tryGetNimsuggest(uri) if ns.isSome: discard ls.warnIfUnknown(ns.get(), uri, projectFile) @@ -867,7 +867,7 @@ proc didOpenFile*( proc tryGetNimsuggest*( ls: LanguageServer, uri: string -): Future[Option[Nimsuggest]] {.async.} = +): Future[Option[NimSuggest]] {.async.} = if uri in ls.idleOpenFiles: let idleFile = ls.idleOpenFiles[uri] await didOpenFile(ls, idleFile.textDocument) @@ -885,10 +885,10 @@ proc tryGetNimsuggest*( # If nimsuggest is nil, wait a bit and retry inc retryCount if retryCount < maxRetries: - debug "Nimsuggest not ready, retrying...", uri = uri, attempt = retryCount + debug "NimSuggest not ready, retrying...", uri = uri, attempt = retryCount await sleepAsync(10000 * retryCount) # Exponential backoff - debug "Nimsuggest not found after retries", uri = uri + debug "NimSuggest not found after retries", uri = uri return none(NimSuggest) proc checkProject*(ls: LanguageServer, uri: string): Future[void] {.async, gcsafe.} = @@ -935,7 +935,7 @@ proc checkProject*(ls: LanguageServer, uri: string): Future[void] {.async, gcsaf return debug "Running diagnostics", uri = uri - let ns = await ls.tryGetNimSuggest(uri) + let ns = await ls.tryGetNimsuggest(uri) if ns.isNone: return let nimsuggest = ns.get @@ -955,13 +955,13 @@ proc checkProject*(ls: LanguageServer, uri: string): Future[void] {.async, gcsaf ls.progress(token, "end") proc getFilepath(s: Suggest): string = - s.filepath + s.filePath let diagnostics = nimsuggest.chk(uriToPath(uri), ls.uriToStash(uri)).await().filter( - sug => sug.filepath != "???" + sug => sug.filePath != "???" ) - filesWithDiags = diagnostics.map(s => s.filepath).toHashSet + filesWithDiags = diagnostics.map(s => s.filePath).toHashSet ls.progress(token, "end") @@ -1003,7 +1003,7 @@ proc onErrorCallback(args: (LanguageServer, string), project: Project) = ) except CatchableError as ex: error "An error has ocurred while handling nimsuggest err", msg = ex.msg - writeStacktrace(ex) + writeStackTrace(ex) finally: if project.file != "": ls.projectErrors.add ProjectError( @@ -1021,9 +1021,9 @@ proc createOrRestartNimsuggest*( let configuration = ls.getWorkspaceConfiguration().waitFor() workingDir = ls.getWorkingDir(projectFile).waitFor() - (nimsuggestPath, version) = ls.getNimSuggestPathAndVersion(configuration, workingDir).waitFor() + (nimSuggestPath, version) = ls.getNimSuggestPathAndVersion(configuration, workingDir).waitFor() timeout = configuration.timeout.get(REQUEST_TIMEOUT) - restartCallback = proc(ns: Nimsuggest) {.gcsafe, raises: [].} = + restartCallback = proc(ns: NimSuggest) {.gcsafe, raises: [].} = warn "Restarting the server due to requests being to slow", projectFile = projectFile ls.showMessage( @@ -1037,7 +1037,7 @@ proc createOrRestartNimsuggest*( debug "Creating new nimsuggest project", projectFile = projectFile let projectNext = waitFor createNimsuggest( projectFile, - nimsuggestPath, + nimSuggestPath, version, timeout, restartCallback, @@ -1052,17 +1052,17 @@ proc createOrRestartNimsuggest*( project.stop() ls.projectFiles[projectFile] = projectNext - projectNext.ns.addCallback do(fut: Future[Nimsuggest]): + projectNext.ns.addCallback do(fut: Future[NimSuggest]): if fut.failed: let msg = fut.error.msg - error "Nimsuggest initialization failed", projectFile = projectFile, error = msg + error "NimSuggest initialization failed", projectFile = projectFile, error = msg ls.showMessage( - fmt "Nimsuggest initialization for {projectFile} failed with: {msg}", + fmt "NimSuggest initialization for {projectFile} failed with: {msg}", MessageType.Error, ) else: - debug "Nimsuggest initialized successfully", projectFile = projectFile - ls.showMessage(fmt "Nimsuggest initialized for {projectFile}", MessageType.Info) + debug "NimSuggest initialized successfully", projectFile = projectFile + ls.showMessage(fmt "NimSuggest initialized for {projectFile}", MessageType.Info) traceAsyncErrors ls.checkProject(uri) fut.read().openFiles.incl uri ls.sendStatusChanged() @@ -1263,7 +1263,7 @@ proc removeIdleNimsuggests*(ls: LanguageServer) {.async.} = ls.projectFiles.del(project.file) ls.showMessage( - fmt"Nimsuggest for {project.file} was stopped because it was idle for too long", + fmt"NimSuggest for {project.file} was stopped because it was idle for too long", MessageType.Info, ) @@ -1275,4 +1275,4 @@ proc tick*(ls: LanguageServer): Future[void] {.async.} = ls.sendStatusChanged except CatchableError as ex: error "Error in tick", msg = ex.msg - writeStacktrace(ex) + writeStackTrace(ex) diff --git a/lstransports.nim b/lstransports.nim index 8e5c493..cc74a75 100644 --- a/lstransports.nim +++ b/lstransports.nim @@ -127,7 +127,7 @@ proc readStdin*(ctx: ptr ReadStdinContext) {.thread.} = while true: let str = processContentLength(inputStream) & CRLF ctx.value = cast[cstring](createShared(char, str.len + 1)) - copymem(ctx.value[0].addr, str[0].addr, str.len) + copyMem(ctx.value[0].addr, str[0].addr, str.len) discard ctx.onStdReadSignal.fireSync() discard ctx.onMainReadSignal.waitSync() diff --git a/nim.cfg b/nim.cfg index 599f653..6c91cf6 100644 --- a/nim.cfg +++ b/nim.cfg @@ -2,7 +2,7 @@ --define:"async_backend=asyncdispatch" --define:"chronicles_default_output_device=stderr" --define:"chronicles_colors=None" ---define:"chronicles_disable_thread_id" +--define:"chronicles_thread_ids=no" --define:"debugLogging" #--define:"chronicles_log_level=TRACE" --define:"chronicles_log_level=DEBUG" diff --git a/protocol/types.nim b/protocol/types.nim index d77e312..3c909ab 100644 --- a/protocol/types.nim +++ b/protocol/types.nim @@ -173,7 +173,7 @@ type dynamicRegistration*: Option[bool] symbolKind*: Option[WorkspaceSymbolClientCapabilities_symbolKind] tagSupport*: Option[WorkspaceSymbolClientCapabilities_tagSupport] - resolveSupport*: Option[WorkspaceSymbolClientCapabilities_ResolveSupport] + resolveSupport*: Option[WorkspaceSymbolClientCapabilities_resolveSupport] ExecuteCommandClientCapabilities* = ref object of RootObj dynamicRegistration*: Option[bool] diff --git a/routes.nim b/routes.nim index 4a2af47..cccbacf 100644 --- a/routes.nim +++ b/routes.nim @@ -154,7 +154,7 @@ proc completion*( result = completions.map(toCompletionItem) if ls.clientCapabilities.supportSignatureHelp() and - nsCon in nimSuggest.get.capabilities: + nsCon in nimsuggest.get.capabilities: #show only unique overloads if we support signatureHelp var unique = initTable[string, CompletionItem]() for completion in result: @@ -164,7 +164,7 @@ proc completion*( proc toLocation*(suggest: Suggest): Location = return - Location %* {"uri": pathToUri(suggest.filepath), "range": toLabelRange(suggest)} + Location %* {"uri": pathToUri(suggest.filePath), "range": toLabelRange(suggest)} proc definition*( ls: LanguageServer, params: TextDocumentPositionParams, id: int @@ -305,7 +305,7 @@ proc typeDefinition*( ): Future[seq[Location]] {.async.} = with (params.position, params.textDocument): asyncSpawn ls.addProjectFileToPendingRequest(id.uint, uri) - let ns = await ls.tryGetNimSuggest(uri) + let ns = await ls.tryGetNimsuggest(uri) if ns.isNone: return @[] let ch = ls.getCharacter(uri, line, character) @@ -321,7 +321,7 @@ proc toSymbolInformation*(suggest: Suggest): SymbolInformation = return SymbolInformation %* { "location": toLocation(suggest), - "kind": nimSymToLSPSymbolKind(suggest.symKind).int, + "kind": nimSymToLSPSymbolKind(suggest.symkind).int, "name": suggest.name, } @@ -370,7 +370,7 @@ proc scheduleFileCheck(ls: LanguageServer, uri: string) {.gcsafe, raises: [].} = proc toMdLinks(s: string): string = result = s let matches = s.findAll(re2"`([^`<]*?)<([^`>]*?)>`_") - for i in countDown(matches.high, matches.low): + for i in countdown(matches.high, matches.low): let match = matches[i] result[match.boundaries] = fmt"[{s[match.captures[0]]}]({s[match.captures[1]]})" @@ -692,7 +692,7 @@ proc signatureHelp*( let nimsuggest = await ls.tryGetNimsuggest(uri) if nimsuggest.isNone: return none[SignatureHelp]() - if nsCon notin nimSuggest.get.capabilities: + if nsCon notin nimsuggest.get.capabilities: #support signatureHelp only if the current version of NimSuggest supports it. return none[SignatureHelp]() let ch = ls.getCharacter(uri, line, character) diff --git a/suggestapi.nim b/suggestapi.nim index 7fcfa49..5170a0c 100644 --- a/suggestapi.nim +++ b/suggestapi.nim @@ -45,7 +45,7 @@ type ideType ideExpand - NimsuggestCallback* = proc(self: Nimsuggest): void {.gcsafe, raises: [].} + NimsuggestCallback* = proc(self: NimSuggest): void {.gcsafe, raises: [].} ProjectCallback* = proc(self: Project): void {.gcsafe, raises: [].} Suggest* = ref object @@ -117,7 +117,7 @@ type lastCmd*: string lastCmdDate*: Option[DateTime] -func canHandleUnknown*(ns: Nimsuggest): bool = +func canHandleUnknown*(ns: NimSuggest): bool = nsUnknownFile in ns.capabilities template benchmark(benchmarkName: string, code: untyped) = @@ -130,7 +130,7 @@ template benchmark(benchmarkName: string, code: untyped) = debug "CPU Time", benchmark = benchmarkName, time = elapsedStr func nimSymToLSPKind*(suggest: Suggest): CompletionItemKind = - case suggest.symKind + case suggest.symkind of "skConst": CompletionItemKind.Value of "skEnumField": CompletionItemKind.Enum of "skForVar": CompletionItemKind.Variable @@ -166,7 +166,7 @@ func nimSymToLSPSymbolKind*(suggest: string): SymbolKind = else: SymbolKind.Function func nimSymDetails*(suggest: Suggest): string = - case suggest.symKind + case suggest.symkind of "skConst": "const " & suggest.qualifiedPath.join(".") & ": " & suggest.forth of "skEnumField": @@ -233,7 +233,7 @@ proc parseSuggestDef*(line: string): Option[Suggest] = column: parseInt(tokens[6]), doc: tokens[7].unescape(), forth: tokens[3], - symKind: tokens[1], + symkind: tokens[1], section: parseEnum[IdeCmd]("ide" & capitalizeAscii(tokens[0])), ) if tokens.len == 11: @@ -351,12 +351,12 @@ proc createNimsuggest*( var extraArgs = newSeq[string]() if isNimScript: extraArgs.add("--import: system/nimscript") - #Nimsuggest crashes when including the file. + #NimSuggest crashes when including the file. if isNimble: let nimScriptApiPath = getNimScriptAPITemplatePath() extraArgs.add("--include: " & nimScriptApiPath) - let ns = Nimsuggest() + let ns = NimSuggest() ns.requestQueue = Deque[SuggestCall]() ns.root = root ns.timeout = timeout @@ -378,7 +378,7 @@ proc createNimsuggest*( if enableLog: args.add("--log") ns.capabilities = getNimsuggestCapabilities(nimsuggestPath) - debug "Nimsuggest Capabilities", capabilities = ns.capabilities + debug "NimSuggest Capabilities", capabilities = ns.capabilities if nsExceptionInlayHints in ns.capabilities: if enableExceptionInlayHints: args.add("--exceptionInlayHints:on") @@ -391,16 +391,16 @@ proc createNimsuggest*( stdoutHandle = AsyncProcess.Pipe, stderrHandle = AsyncProcess.Pipe, ) - debug "Nimsuggest started with args", args = args + debug "NimSuggest started with args", args = args asyncSpawn logNsError(result) let portLine = await result.process.stdoutStream.readLine(sep = "\n") - debug "Nimsuggest port", portLine = portLine + debug "NimSuggest port", portLine = portLine try: ns.port = portLine.parseInt except ValueError: error "Failed to parse nimsuggest port", portLine = portLine let nextLine = await result.process.stdoutStream.readLine(sep = "\n") - error "Nimsuggest nextLine", nextLine = nextLine + error "NimSuggest nextLine", nextLine = nextLine result.markFailed "Failed to parse nimsuggest port" result.ns.complete(ns) else: @@ -414,18 +414,18 @@ proc createNimsuggest*(root: string): Future[Project] {.gcsafe.} = "nimsuggest", "", REQUEST_TIMEOUT, - proc(ns: Nimsuggest) = + proc(ns: NimSuggest) = discard, proc(pr: Project) = discard, ) -proc toString*(bytes: openarray[byte]): string = +proc toString*(bytes: openArray[byte]): string = result = newString(bytes.len) if bytes.len > 0: copyMem(result[0].addr, bytes[0].unsafeAddr, bytes.len) -proc processQueue(self: Nimsuggest): Future[void] {.async.} = +proc processQueue(self: NimSuggest): Future[void] {.async.} = debug "processQueue", size = self.requestQueue.len while self.requestQueue.len != 0: let req = self.requestQueue.popFirst @@ -436,7 +436,7 @@ proc processQueue(self: Nimsuggest): Future[void] {.async.} = if req.future.finished: debug "Call cancelled before executed", command = req.command elif self.project.failed: - debug "Nimsuggest is not working, returning empty result...", port = self.port + debug "NimSuggest is not working, returning empty result...", port = self.port req.future.complete @[] else: benchmark req.commandString: @@ -495,7 +495,7 @@ proc processQueue(self: Nimsuggest): Future[void] {.async.} = self.project.lastCmdDate = some(now()) proc call*( - self: Nimsuggest, + self: NimSuggest, command: string, file: string, dirtyFile: string, @@ -519,21 +519,21 @@ proc call*( template createFullCommand(command: untyped) {.dirty.} = proc command*( - self: Nimsuggest, file: string, dirtyfile = "", line: int, col: int, tag = "" + self: NimSuggest, file: string, dirtyfile = "", line: int, col: int, tag = "" ): Future[seq[Suggest]] = return self.call(astToStr(command), file, dirtyfile, line, col, tag) template createFileOnlyCommand(command: untyped) {.dirty.} = - proc command*(self: Nimsuggest, file: string, dirtyfile = ""): Future[seq[Suggest]] = + proc command*(self: NimSuggest, file: string, dirtyfile = ""): Future[seq[Suggest]] = return self.call(astToStr(command), file, dirtyfile, 0, 0) template createGlobalCommand(command: untyped) {.dirty.} = - proc command*(self: Nimsuggest): Future[seq[Suggest]] = + proc command*(self: NimSuggest): Future[seq[Suggest]] = return self.call(astToStr(command), "-", "", 0, 0) template createRangeCommand(command: untyped) {.dirty.} = proc command*( - self: Nimsuggest, + self: NimSuggest, file: string, dirtyfile = "", startLine, startCol, endLine, endCol: int, @@ -567,11 +567,11 @@ createGlobalCommand(recompile) createRangeCommand(inlayHints) proc `mod`*( - nimsuggest: Nimsuggest, file: string, dirtyfile = "" + nimsuggest: NimSuggest, file: string, dirtyfile = "" ): Future[seq[Suggest]] = return nimsuggest.call("ideMod", file, dirtyfile, 0, 0) -proc isKnown*(nimsuggest: Nimsuggest, filePath: string): Future[bool] {.async.} = +proc isKnown*(nimsuggest: NimSuggest, filePath: string): Future[bool] {.async.} = let res = await withTimeout(nimsuggest.known(filePath)) if res.isNone: debug "Timeout reached running [isKnown], assuming the file is not known", diff --git a/utils.nim b/utils.nim index 4231142..9764063 100644 --- a/utils.nim +++ b/utils.nim @@ -184,7 +184,7 @@ iterator groupBy*[T, U]( var t = initTable[U, seq[T]]() for x in s: let fx = f(x) - t.mGetOrPut(fx, @[]).add(x) + t.mgetOrPut(fx, @[]).add(x) for x in t.pairs: yield x @@ -347,7 +347,7 @@ proc getNimScriptAPITemplatePath*(): string = proc shutdownChildProcess*(p: AsyncProcessRef): Future[void] {.async.} = try: - debug "Shutting down process with pid: ", pid = p.processID() + debug "Shutting down process with pid: ", pid = p.processId() let exitCode = await p.terminateAndWaitForExit(2.seconds) # debug "Process terminated with exit code: ", exitCode except CatchableError: try: