diff options
Diffstat (limited to 'Scripts/main.js')
| -rw-r--r-- | Scripts/main.js | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/Scripts/main.js b/Scripts/main.js index 1058dfe..6f0a54e 100644 --- a/Scripts/main.js +++ b/Scripts/main.js | |||
| @@ -12,6 +12,7 @@ const CONFIG_KEYS = { | |||
| 12 | zlsEnabled: `${EXTENSION_ID}.zls.enabled`, | 12 | zlsEnabled: `${EXTENSION_ID}.zls.enabled`, |
| 13 | zlsBuildOnSave: `${EXTENSION_ID}.zls.build-on-save`, | 13 | zlsBuildOnSave: `${EXTENSION_ID}.zls.build-on-save`, |
| 14 | zlsDebug: `${EXTENSION_ID}.zls.debug`, | 14 | zlsDebug: `${EXTENSION_ID}.zls.debug`, |
| 15 | lldbDapDebug: `${EXTENSION_ID}.debug-adapter.debug`, | ||
| 15 | }; | 16 | }; |
| 16 | 17 | ||
| 17 | let languageServer = null; | 18 | let languageServer = null; |
| @@ -264,7 +265,7 @@ function lldbDapProxyPath() { | |||
| 264 | } | 265 | } |
| 265 | 266 | ||
| 266 | function debugAdapterLogPath() { | 267 | function debugAdapterLogPath() { |
| 267 | return "/tmp/zig-lldb-dap-proxy.log"; | 268 | return nova.path.join(nova.extension.globalStoragePath, "lldb-dap-proxy.log"); |
| 268 | } | 269 | } |
| 269 | 270 | ||
| 270 | function issueNormalizerScriptPath() { | 271 | function issueNormalizerScriptPath() { |
| @@ -475,6 +476,21 @@ class ZigLanguageServer { | |||
| 475 | clientOptions | 476 | clientOptions |
| 476 | ); | 477 | ); |
| 477 | 478 | ||
| 479 | client.onNotification("window/logMessage", ({ type, message }) => { | ||
| 480 | // type: 1=Error, 2=Warning, 3=Info, 4=Log | ||
| 481 | const enriched = | ||
| 482 | message === "ParseError" | ||
| 483 | ? "ParseError — ZLS could not fully parse the Zig source (normal while editing)" | ||
| 484 | : message; | ||
| 485 | if (type === 1) { | ||
| 486 | console.error(`[ZLS] ${enriched}`); | ||
| 487 | } else if (type === 2) { | ||
| 488 | console.warn(`[ZLS] ${enriched}`); | ||
| 489 | } else if (debugLogs) { | ||
| 490 | console.log(`[ZLS] ${enriched}`); | ||
| 491 | } | ||
| 492 | }); | ||
| 493 | |||
| 478 | this.clientStopDisposable = client.onDidStop((error) => { | 494 | this.clientStopDisposable = client.onDidStop((error) => { |
| 479 | if (error) { | 495 | if (error) { |
| 480 | console.error(`[${LANGUAGE_CLIENT_ID}] ${error.message}`); | 496 | console.error(`[${LANGUAGE_CLIENT_ID}] ${error.message}`); |
| @@ -806,12 +822,24 @@ class ZigTaskAssistant { | |||
| 806 | const action = new TaskDebugAdapterAction("zig-lldb-dap"); | 822 | const action = new TaskDebugAdapterAction("zig-lldb-dap"); |
| 807 | action.transport = "stdio"; | 823 | action.transport = "stdio"; |
| 808 | action.command = "/usr/bin/perl"; | 824 | action.command = "/usr/bin/perl"; |
| 809 | action.args = [lldbDapProxyPath(), lldbDapPath, debugAdapterLogPath()]; | 825 | const debugLog = getBooleanConfigValue(CONFIG_KEYS.lldbDapDebug, false); |
| 826 | let logPath; | ||
| 827 | if (debugLog) { | ||
| 828 | try { | ||
| 829 | const p = debugAdapterLogPath(); | ||
| 830 | const dir = nova.path.dirname(p); | ||
| 831 | if (!nova.fs.stat(dir)) nova.fs.mkdir(dir); | ||
| 832 | logPath = p; | ||
| 833 | } catch (_) {} | ||
| 834 | } | ||
| 835 | action.args = logPath | ||
| 836 | ? [lldbDapProxyPath(), lldbDapPath, logPath] | ||
| 837 | : [lldbDapProxyPath(), lldbDapPath]; | ||
| 810 | action.debugRequest = "launch"; | 838 | action.debugRequest = "launch"; |
| 811 | action.env = { | 839 | action.env = { |
| 812 | DYLD_FRAMEWORK_PATH: lldbFrameworkPaths().join(":"), | 840 | DYLD_FRAMEWORK_PATH: lldbFrameworkPaths().join(":"), |
| 813 | NOVA_ZIG_LLDB_DAP_PATH: lldbDapPath, | 841 | NOVA_ZIG_LLDB_DAP_PATH: lldbDapPath, |
| 814 | NOVA_ZIG_DEBUG_LOG: debugAdapterLogPath(), | 842 | ...(logPath ? { NOVA_ZIG_DEBUG_LOG: logPath } : {}), |
| 815 | }; | 843 | }; |
| 816 | action.debugArgs = { | 844 | action.debugArgs = { |
| 817 | program: programPath, | 845 | program: programPath, |
