Skip to content

Commit

Permalink
fixed windows opening when running other processes
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Aug 20, 2023
1 parent caad217 commit f4d0c87
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 20 deletions.
29 changes: 18 additions & 11 deletions Absytree.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ requires "https://github.com/Nimaoth/boxy >= 0.4.2"
requires "https://github.com/Nimaoth/nimscripter >= 1.0.18"
requires "https://github.com/Nimaoth/nimtreesitter-api >= 0.1.3"

import strformat
import strformat, strutils

task createScriptingDocs, "Build the documentation for the scripting API":
exec "nim doc --project --index:on --git.url:https://github.com/Nimaoth/Absytree/ --git.commit:main ./scripting/absytree_runtime.nim"
Expand All @@ -43,33 +43,40 @@ echo fmt"extension: {exe}"

const crossCompileWinArgs = "--gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc --os:windows --cpu:amd64 -d:crossCompileToWindows"

proc getCommandLineParams(): string =
defer:
echo fmt"Additional command line params: {result}"
if commandLineParams.len < 3:
return ""
return commandLineParams[3..^1].join(" ")

task buildDesktop, "Build the desktop version":
selfExec fmt"c -o:ast{exe} -d:exposeScriptingApi ./src/absytree.nim"
selfExec fmt"c -o:ast{exe} -d:exposeScriptingApi {getCommandLineParams()} ./src/absytree.nim"

task buildDesktopWindows, "Build the desktop version for windows":
selfExec fmt"c -o:ast.exe {crossCompileWinArgs} -d:exposeScriptingApi ./src/absytree.nim"
selfExec fmt"c -o:ast.exe {crossCompileWinArgs} -d:exposeScriptingApi {getCommandLineParams()} ./src/absytree.nim"

task buildWorkspaceServer, "Build the server for hosting workspaces":
selfExec fmt"c -o:workspace-server{exe} ./src/servers/workspace_server.nim"
selfExec fmt"c -o:workspace-server{exe} {getCommandLineParams()} ./src/servers/workspace_server.nim"

task buildLanguagesServer, "Build the server for hosting languages servers":
selfExec fmt"c -o:languages-server{exe} ./src/servers/languages_server.nim"
selfExec fmt"c -o:languages-server{exe} {getCommandLineParams()} ./src/servers/languages_server.nim"

task buildAbsytreeServer, "Build the server for hosting workspaces and language servers":
selfExec fmt"c -o:absytree-server{exe} ./src/servers/absytree_server.nim"
selfExec fmt"c -o:absytree-server{exe} {getCommandLineParams()} ./src/servers/absytree_server.nim"

task buildAbsytreeServerWindows, "Build the server for hosting workspaces and language servers":
selfExec fmt"c -o:absytree-server.exe {crossCompileWinArgs} ./src/servers/absytree_server.nim"
selfExec fmt"c -o:absytree-server.exe {crossCompileWinArgs} {getCommandLineParams()} ./src/servers/absytree_server.nim"

task buildNimsuggestWS, "Build the server for hosting workspaces and language servers":
selfExec fmt"c -o:nimsuggest-ws{exe} ./nimsuggest_ws.nim"
selfExec fmt"c -o:nimsuggest-ws{exe} {getCommandLineParams()} ./nimsuggest_ws.nim"

task buildNimsuggestWSWindows, "Build the server for hosting workspaces and language servers":
selfExec fmt"c -o:nimsuggest-ws.exe {crossCompileWinArgs} ./nimsuggest_ws.nim"
selfExec fmt"c -o:nimsuggest-ws.exe {crossCompileWinArgs} {getCommandLineParams()} ./nimsuggest_ws.nim"

task buildBrowser, "Build the browser version":
selfExec "js -o:ast.js -d:exposeScriptingApi -d:vmathObjBased -d:enableTableIdCacheChecking --boundChecks:on --rangeChecks:on ./src/absytree_js.nim"
selfExec fmt"js -o:ast.js -d:exposeScriptingApi -d:vmathObjBased -d:enableTableIdCacheChecking --boundChecks:on --rangeChecks:on {getCommandLineParams()} ./src/absytree_js.nim"

task buildNimConfigWasm, "Compile the nim script config file to wasm":
withDir "config":
selfExec "c -d:release -o:./absytree_config_wasm.wasm ./absytree_config_wasm.nim"
selfExec fmt"c -d:release -o:./absytree_config_wasm.wasm {getCommandLineParams()} ./absytree_config_wasm.nim"
Binary file modified config/absytree_config_wasm.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions config/languages.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import absytree_runtime
setOption "editor.text.languages-server.url", "localhost"
setOption "editor.text.languages-server.port", 3001
setOption "editor.text.lsp.zig.path", "zls"
setOption "editor.text.lsp.rust.path", "C:/Users/nimao/.vscode/extensions/rust-lang.rust-analyzer-0.3.1325-win32-x64/server/rust-analyzer.exe"
setOption "editor.text.lsp.rust.path", "C:/Users/nimao/.vscode/extensions/rust-lang.rust-analyzer-0.3.1623-win32-x64/server/rust-analyzer.exe"
setOption "editor.text.treesitter.rust.dll", "D:/dev/Nim/nimtreesitter/treesitter_rust/treesitter_rust/rust.dll"
setOption "editor.text.treesitter.zig.dll", "D:/dev/Nim/nimtreesitter/treesitter_zig/treesitter_zig/zig.dll"
setOption "editor.text.treesitter.javascript.dll", "D:/dev/Nim/nimtreesitter/treesitter_javascript/treesitter_javascript/javascript.dll"
Expand Down Expand Up @@ -43,7 +43,7 @@ setOption "editor.text.language.typescript", %*{

setOption "editor.text.language.rust", %*{
"tabWidth": 4,
"indent": "tab",
"indent": "spaces",
"indentAfter": [":", "=", "(", "{", "["],
"lineComment": "//",
"blockComment": ["/*", "*/"],
Expand Down
2 changes: 1 addition & 1 deletion nimsuggest_ws.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ for arg in commandLineParams():

echo fmt"Exposing 'nimsuggest {forwardedArgs}' under ws://localhost:{port}"

let process = startProcess(nimsuggestPath, args = forwardedArgs)
let process = startProcess(nimsuggestPath, args = forwardedArgs, options={poUsePath, poDaemon})

var server = newAsyncHttpServer()

Expand Down
2 changes: 1 addition & 1 deletion src/absytree.nim
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if backend.isNone:
assert backend.isSome

block: ## Enable loggers
if backend.get == Terminal or logToFile:
if backend.get == Terminal or logToFile or defined(forceLogToFile):
logger.enableFileLogger()
if backend.get != Terminal:
logger.enableConsoleLogger()
Expand Down
4 changes: 2 additions & 2 deletions src/async_process.nim
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ proc startAsyncProcess*(name: string, args: openArray[string] = [], autoRestart

inc startCounter

log(lvlInfo, "[process] start")
process.process = startProcess(process.name, args=process.args)
log(lvlInfo, fmt"[process] start {process.name} {process.args}")
process.process = startProcess(process.name, args=process.args, options={poUsePath, poDaemon})

process.readerFlowVar = spawn(readInput(process.inputStreamChannel, process.serverDiedNotifications, process.input.chan, process.output.chan))
process.inputStreamChannel[].send process.process.outputStream()
Expand Down
2 changes: 1 addition & 1 deletion src/language/language_server_nimsuggest.nim
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ proc newLanguageServerNimSuggest*(filename: string, languagesServer: Option[(str
let parts = filename.splitFile
server.port = getFreePort()
server.tempFilename = genTempPath("absytree_", "_" & parts.name & parts.ext).replace('\\', '/')
let process = startProcess("nimsuggest", args = ["--port:" & $server.port.int, filename])
let process = startProcess("nimsuggest", args = ["--port:" & $server.port.int, filename], options={poUsePath, poDaemon})
if process.isNil:
raise newException(IOError, "Failed to start process nimguggest")
server.impl = LanguageServerImpl(kind: Process, process: process)
Expand Down
3 changes: 2 additions & 1 deletion src/scripting/scripting_nim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ proc myFindNimStdLib(): string =
## Returns "" on failure.

try:
let nimdump = execProcess("nim --verbosity:0 dump --dump.format:json .", ".", [])
log lvlInfo, "Searching for nim std lib directory using 'nim --verbosity:0 dump --dump.format:json .'"
let nimdump = execProcess("nim", ".", ["--verbosity:0", "dump", "--dump.format:json", "."], options={poUsePath, poDaemon})
let nimdumpJson = nimdump.parseJson()
return nimdumpJson["libpath"].getStr ""
except OSError, ValueError:
Expand Down
2 changes: 1 addition & 1 deletion src/servers/languages_server.nim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ proc callback(req: Request): Future[void] {.async.} =
echo fmt"start {nimsuggestPath} on localhost:{port} for '{fullPath}'"

let nimsuggest = getCurrentDir() / "nimsuggest-ws.exe"
let process = startProcess(nimsuggest, args=[fmt"--port:{port}", fmt"--nimsuggest:{nimsuggestPath}", "--", fullPath])
let process = startProcess(nimsuggest, args=[fmt"--port:{port}", fmt"--nimsuggest:{nimsuggestPath}", "--", fullPath], options={poUsePath, poDaemon})

{.gcsafe.}:
processes.add process
Expand Down

0 comments on commit f4d0c87

Please sign in to comment.