Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul LSP Client #752

Merged
merged 21 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,21 +296,6 @@
"default": false,
"description": "Whether extra space should be removed from function parameter lists"
},
"godotTools.lsp.serverProtocol": {
"type": [
"string"
],
"enum": [
"ws",
"tcp"
],
"default": "tcp",
"enumDescriptions": [
"Use the WebSocket protocol to connect to Godot 3.2 and Godot 3.2.1",
"Use the TCP protocol to connect to Godot 3.2.2 and newer versions"
],
"description": "The server protocol of the GDScript language server.\nYou must restart VSCode after changing this value."
},
"godotTools.lsp.serverHost": {
"type": "string",
"default": "127.0.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function copy_resource_path(uri: vscode.Uri) {
}

async function list_classes() {
await globals.lsp.client.list_classes();
await globals.docsProvider.list_native_classes();
}

async function switch_scene_script() {
Expand Down
23 changes: 11 additions & 12 deletions src/lsp/ClientConnectionManager.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import * as vscode from "vscode";
import GDScriptLanguageClient, { ClientStatus, TargetLSP } from "./GDScriptLanguageClient";

import {
createLogger,
get_configuration,
get_free_port,
get_project_dir,
get_project_version,
set_context,
register_command,
set_configuration,
createLogger,
set_context,
verify_godot_version,
} from "../utils";
import { prompt_for_godot_executable, prompt_for_reload, select_godot_executable } from "../utils/prompts";
import { subProcess, killSubProcesses } from "../utils/subspawn";
import { killSubProcesses, subProcess } from "../utils/subspawn";
import GDScriptLanguageClient, { ClientStatus, TargetLSP } from "./GDScriptLanguageClient";

const log = createLogger("lsp.manager", { output: "Godot LSP" });

Expand All @@ -38,10 +39,8 @@ export class ClientConnectionManager {
private connectedVersion = "";

constructor(private context: vscode.ExtensionContext) {
this.context = context;

this.client = new GDScriptLanguageClient(context);
this.client.watch_status(this.on_client_status_changed.bind(this));
this.client = new GDScriptLanguageClient();
this.client.events.on("status", this.on_client_status_changed.bind(this));

setInterval(() => {
this.retry_callback();
Expand All @@ -60,7 +59,7 @@ export class ClientConnectionManager {
this.start_language_server();
this.reconnectionAttempts = 0;
this.target = TargetLSP.HEADLESS;
this.client.connect_to_server(this.target);
this.client.connect(this.target);
}),
register_command("stopLanguageServer", this.stop_language_server.bind(this)),
register_command("checkStatus", this.on_status_item_click.bind(this)),
Expand All @@ -81,7 +80,7 @@ export class ClientConnectionManager {
}

this.reconnectionAttempts = 0;
this.client.connect_to_server(this.target);
this.client.connect(this.target);
}

private stop_language_server() {
Expand Down Expand Up @@ -269,7 +268,7 @@ export class ClientConnectionManager {
this.reconnectionAttempts = 0;
set_context("connectedToLSP", true);
this.status = ManagerStatus.CONNECTED;
if (!this.client.started) {
if (this.client.needsStart()) {
this.context.subscriptions.push(this.client.start());
}
break;
Expand Down Expand Up @@ -305,7 +304,7 @@ export class ClientConnectionManager {
const maxAttempts = get_configuration("lsp.autoReconnect.attempts");
if (autoRetry && this.reconnectionAttempts <= maxAttempts - 1) {
this.reconnectionAttempts++;
this.client.connect_to_server(this.target);
this.client.connect(this.target);
this.retry = true;
return;
}
Expand Down
Loading
Loading