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

Restructure and rename settings #376

Merged
merged 14 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@
],
"configuration": {
"type": "object",
"title": "Godot Tools configuration",
"title": "Godot Tools",
"properties": {
"godot_tools.gdscript_lsp_server_protocol": {
"godot-tools.lsp.serverProtocol": {
"type": [
"string"
],
Expand All @@ -116,52 +116,52 @@
],
"default": "tcp",
"enumDescriptions": [
"Using WebSocket protocol to connect to Godot 3.2 and Godot 3.2.1",
"Using TCP protocol to connect to Godot 3.2.2 and newer versions"
"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 have restart VSCode editor after change this value."
"description": "The server protocol of the GDScript language server.\nYou must restart VSCode after changing this value."
},
"godot_tools.gdscript_lsp_server_host": {
"godot-tools.lsp.serverHost": {
"type": "string",
"default": "127.0.0.1",
"description": "The server host of the GDScript language server"
},
"godot_tools.gdscript_lsp_server_port": {
"godot-tools.lsp.serverPort": {
"type": "number",
"default": 6008,
"description": "The server port of the GDScript language server"
},
"godot_tools.editor_path": {
"godot-tools.editorPath": {
"type": "string",
"default": "",
"description": "The absolute path to the Godot editor executable"
},
"godot_tools.scene_file_config": {
"godot-tools.sceneFileConfig": {
"type": "string",
"default": "",
"description": "The scene file to run"
},
"godot_tools.reconnect_automatically": {
"godot-tools.lsp.autoReconnect.enabled": {
"type": "boolean",
"default": true,
"description": "Whether the plugin should attempt to reconnect"
"description": "Whether the plugin should attempt to reconnect to the GDScript language server"
},
"godot_tools.reconnect_cooldown": {
"godot-tools.lsp.autoReconnect.cooldown": {
"type": "number",
"default": 3000,
"description": "The number of milliseconds to wait before attempting to reconnect"
},
"godot_tools.reconnect_attempts": {
"godot-tools.lsp.autoReconnect.attempts": {
"type": "number",
"default": 10,
"description": "How many times the client will attempt to reconnect"
},
"godot_tools.force_visible_collision_shapes": {
"godot-tools.forceVisibleCollisionShapes": {
"type": "boolean",
"default": false,
"description": "Force the project to run with visible collision shapes"
},
"godot_tools.force_visible_nav_mesh": {
"godot-tools.forceVisibleNavMesh": {
"type": "boolean",
"default": false,
"description": "Force the project to run with visible navigation meshes"
Expand Down
2 changes: 1 addition & 1 deletion src/debugger/debug_session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export class GodotDebugSession extends LoggingDebugSession {
args.port,
args.launch_game_instance,
args.launch_scene,
get_configuration("scene_file_config", "") || args.scene_file,
get_configuration("sceneFileConfig", "") || args.scene_file,
]);

this.sendResponse(response);
Expand Down
6 changes: 3 additions & 3 deletions src/debugger/server_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export class ServerController {
this.debug_data = debug_data;

if (launch_instance) {
let godot_path: string = utils.get_configuration("editor_path", "godot");
const force_visible_collision_shapes = utils.get_configuration("force_visible_collision_shapes", false);
const force_visible_nav_mesh = utils.get_configuration("force_visible_nav_mesh", false);
let godot_path: string = utils.get_configuration("editorPath", "godot");
const force_visible_collision_shapes = utils.get_configuration("forceVisibleCollisionShapes", false);
const force_visible_nav_mesh = utils.get_configuration("forceVisibleNavMesh", false);

let executable_line = `"${godot_path}" --path "${project_path}" --remote-debug ${address}:${port}`;

Expand Down
27 changes: 13 additions & 14 deletions src/godot-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as fs from 'fs';
import GDScriptLanguageClient, { ClientStatus } from "./lsp/GDScriptLanguageClient";
import { get_configuration, set_configuration } from "./utils";

const CONFIG_CONTAINER = "godot_tools";
const TOOL_NAME = "GodotTools";

export class GodotTools {
Expand All @@ -27,7 +26,7 @@ export class GodotTools {

setInterval(() => {
this.retry_callback();
}, get_configuration("reconnect_cooldown", 3000));
}, get_configuration("lsp.autoReconnect.cooldown", 3000));
}

public activate() {
Expand Down Expand Up @@ -89,7 +88,7 @@ export class GodotTools {
if (!this.project_dir) {
return;
}

if (!uri) {
uri = vscode.window.activeTextEditor.document.uri
}
Expand All @@ -103,15 +102,15 @@ export class GodotTools {

private set_scene_file(uri: vscode.Uri) {
let right_clicked_scene_path = uri.fsPath
let scene_config = get_configuration("scene_file_config");
let scene_config = get_configuration("sceneFileConfig");
if (scene_config == right_clicked_scene_path) {
scene_config = ""
}
else {
scene_config = right_clicked_scene_path
}

set_configuration("scene_file_config", scene_config);
set_configuration("sceneFileConfig", scene_config);
}

private run_editor(params = "") {
Expand Down Expand Up @@ -176,7 +175,7 @@ export class GodotTools {
resolve();
};

let editorPath = get_configuration("editor_path", "");
let editorPath = get_configuration("editorPath", "");
editorPath = editorPath.replace("${workspaceRoot}", this.workspace_dir);
if (!fs.existsSync(editorPath) || !fs.statSync(editorPath).isFile()) {
vscode.window.showOpenDialog({
Expand All @@ -201,8 +200,8 @@ export class GodotTools {
}

private check_client_status() {
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.serverPort", "localhost");
let port = get_configuration("lsp.serverHost", 6008);
switch (this.client.status) {
case ClientStatus.PENDING:
vscode.window.showInformationMessage(`Connecting to the GDScript language server at ${host}:${port}`);
Expand All @@ -217,8 +216,8 @@ export class GodotTools {
}

private on_client_status_changed(status: ClientStatus) {
let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.serverHost", "localhost");
let port = get_configuration("lsp.serverPort", 6008);
switch (status) {
case ClientStatus.PENDING:
this.connection_status.text = `$(sync) Connecting`;
Expand Down Expand Up @@ -256,8 +255,8 @@ export class GodotTools {
}

private retry_connect_client() {
const auto_retry = get_configuration("reconnect_automatically", true);
const max_attempts = get_configuration("reconnect_attempts", 10);
const auto_retry = get_configuration("lsp.autoReconnect.enabled", true);
const max_attempts = get_configuration("lsp.autoReconnect.attempts", 10);
if (auto_retry && this.reconnection_attempts <= max_attempts) {
this.reconnection_attempts++;
this.client.connect_to_server();
Expand All @@ -270,8 +269,8 @@ export class GodotTools {
this.connection_status.text = `$(x) Disconnected`;
this.connection_status.tooltip = `Disconnected from the GDScript language server.`;

let host = get_configuration("gdscript_lsp_server_host", "localhost");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.ServerHost", "localhost");
let port = get_configuration("lsp.ServerPort", 6008);
let message = `Couldn't connect to the GDScript language server at ${host}:${port}. Is the Godot editor running?`;
vscode.window.showErrorMessage(message, 'Open Godot Editor', 'Retry', 'Ignore').then(item => {
if (item == 'Retry') {
Expand Down
6 changes: 3 additions & 3 deletions src/lsp/GDScriptLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const CUSTOM_MESSAGE = "gdscrip_client/";

export default class GDScriptLanguageClient extends LanguageClient {

public readonly io: MessageIO = (get_configuration("gdscript_lsp_server_protocol", "tcp") == "ws") ? new WebsocktMessageIO() : new TCPMessageIO();
public readonly io: MessageIO = (get_configuration("lsp.serverProtocol", "tcp") == "ws") ? new WebsocktMessageIO() : new TCPMessageIO();

private context: vscode.ExtensionContext;
private _started : boolean = false;
Expand Down Expand Up @@ -74,8 +74,8 @@ export default class GDScriptLanguageClient extends LanguageClient {

connect_to_server() {
this.status = ClientStatus.PENDING;
let host = get_configuration("gdscript_lsp_server_host", "127.0.0.1");
let port = get_configuration("gdscript_lsp_server_port", 6008);
let host = get_configuration("lsp.serverHost", "127.0.0.1");
let port = get_configuration("lsp.serverPort", 6008);
this.io.connect_to_language_server(host, port);
}

Expand Down
2 changes: 1 addition & 1 deletion src/lsp/NativeDocumentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export default class NativeDocumentManager extends EventEmitter {

private inspect_native_symbol(params: NativeSymbolInspectParams) {
let json_data = "";
if (get_configuration("gdscript_lsp_server_protocol", "tcp") == "ws") {
if (get_configuration("lsp.serverProtocol", "tcp") == "ws") {
json_data = JSON.stringify({
id: -1,
jsonrpc: "2.0",
Expand Down
8 changes: 6 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as vscode from "vscode";

const CONFIG_CONTAINER = "godot_tools";
const CONFIG_CONTAINER = "godot-tools";

export function get_configuration(name: string, default_value: any = null) {
return vscode.workspace.getConfiguration(CONFIG_CONTAINER).get(name, default_value) || default_value;
let config_value = vscode.workspace.getConfiguration(CONFIG_CONTAINER).get(name, null);
if (config_value === null) {
return default_value;
}
return config_value;
}

export function set_configuration(name: string, value: any) {
Expand Down