lsp: add settings to customize the logging location (#123)

This commit is contained in:
Tyler Wilding 2022-10-10 00:45:31 -04:00 committed by GitHub
parent 684d91b1f9
commit accf8e4224
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 12 deletions

View file

@ -211,18 +211,24 @@
"title": "LSP", "title": "LSP",
"properties": { "properties": {
"opengoal.launchLspOnStartup": { "opengoal.launchLspOnStartup": {
"type": [ "type": "boolean",
"boolean"
],
"default": true, "default": true,
"description": "Whether or not the LSP should be started automatically" "description": "Whether or not the LSP should be started automatically"
}, },
"opengoal.opengoalLspPath": { "opengoal.opengoalLspPath": {
"type": [ "type": "string",
"string"
],
"default": "", "default": "",
"description": "Hardcode a path to the LSP executable" "description": "Hardcode a path to the LSP executable"
},
"opengoal.opengoalLspLogPath": {
"type": "string",
"default": "",
"description": "Provide a path that the LSP should log it's debugging info to"
},
"opengoal.opengoalLspLogVerbose": {
"type": "boolean",
"default": "",
"description": "Should the LSP logging be verbose?"
} }
} }
}, },

View file

@ -7,6 +7,9 @@ export function getConfig() {
launchLspOnStartup: configOptions.get<boolean>("launchLspOnStartup"), launchLspOnStartup: configOptions.get<boolean>("launchLspOnStartup"),
opengoalLspVersion: configOptions.get<string>("opengoalLspVersion"), opengoalLspVersion: configOptions.get<string>("opengoalLspVersion"),
opengoalLspPath: configOptions.get<string>("opengoalLspPath"), opengoalLspPath: configOptions.get<string>("opengoalLspPath"),
opengoalLspLogPath: configOptions.get<string>("opengoalLspLogPath"),
opengoalLspLogVerbose: configOptions.get<boolean>("opengoalLspLogVerbose"),
eeManPagePath: configOptions.get<string>("eeManPagePath"), eeManPagePath: configOptions.get<string>("eeManPagePath"),
vuManPagePath: configOptions.get<string>("vuManPagePath"), vuManPagePath: configOptions.get<string>("vuManPagePath"),
decompilerPath: configOptions.get<string>("decompilerPath"), decompilerPath: configOptions.get<string>("decompilerPath"),

View file

@ -120,20 +120,23 @@ async function maybeDownloadLspServer(): Promise<void> {
} }
function createClient(lspPath: string): LanguageClient { function createClient(lspPath: string): LanguageClient {
const logPath =
getConfig().opengoalLspLogPath ??
path.join(extensionContext.extensionPath, "lsp.log");
const normalArgs = ["--log", logPath];
if (getConfig().opengoalLspLogVerbose) {
normalArgs.push("--verbose");
}
const serverOptions: ServerOptions = { const serverOptions: ServerOptions = {
run: { run: {
command: lspPath, command: lspPath,
transport: TransportKind.stdio, transport: TransportKind.stdio,
args: ["--log", path.join(extensionContext.extensionPath, "lsp.log")], args: normalArgs,
}, },
debug: { debug: {
command: lspPath, command: lspPath,
transport: TransportKind.stdio, transport: TransportKind.stdio,
args: [ args: ["--verbose", "--log", logPath],
"--verbose",
"--log",
path.join(extensionContext.extensionPath, "lsp.log"),
],
}, },
}; };
const clientOptions: LanguageClientOptions = { const clientOptions: LanguageClientOptions = {