From 91482a00bb5e9635637fc69c193aca40ff0f6c68 Mon Sep 17 00:00:00 2001 From: "John J. Donna II" Date: Wed, 1 Sep 2021 18:56:19 -0400 Subject: [PATCH] LSP: Add support for custom host setting You can now configure host in the `language_server` settings in the editor settings. (cherry picked from commit be6da39b8af5f95d3086deeceb5d3c38f1ab1717) --- .../language_server/gdscript_language_server.cpp | 10 +++++++--- .../language_server/gdscript_language_server.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/gdscript/language_server/gdscript_language_server.cpp b/modules/gdscript/language_server/gdscript_language_server.cpp index 12ed56a5687..f121b01b299 100644 --- a/modules/gdscript/language_server/gdscript_language_server.cpp +++ b/modules/gdscript/language_server/gdscript_language_server.cpp @@ -38,9 +38,11 @@ GDScriptLanguageServer::GDScriptLanguageServer() { thread_running = false; started = false; - use_thread = false; + host = "127.0.0.1"; port = 6008; + + _EDITOR_DEF("network/language_server/remote_host", host); _EDITOR_DEF("network/language_server/remote_port", port); _EDITOR_DEF("network/language_server/enable_smart_resolve", true); _EDITOR_DEF("network/language_server/show_native_symbols_in_editor", false); @@ -61,9 +63,10 @@ void GDScriptLanguageServer::_notification(int p_what) { } } break; case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { + String host = String(_EDITOR_GET("network/language_server/remote_host")); int port = (int)_EDITOR_GET("network/language_server/remote_port"); bool use_thread = (bool)_EDITOR_GET("network/language_server/use_thread"); - if (port != this->port || use_thread != this->use_thread) { + if (host != this->host || port != this->port || use_thread != this->use_thread) { this->stop(); this->start(); } @@ -81,9 +84,10 @@ void GDScriptLanguageServer::thread_main(void *p_userdata) { } void GDScriptLanguageServer::start() { + host = String(_EDITOR_GET("network/language_server/remote_host")); port = (int)_EDITOR_GET("network/language_server/remote_port"); use_thread = (bool)_EDITOR_GET("network/language_server/use_thread"); - if (protocol.start(port, IP_Address("127.0.0.1")) == OK) { + if (protocol.start(port, IP_Address(host)) == OK) { EditorNode::get_log()->add_message("--- GDScript language server started ---", EditorLog::MSG_TYPE_EDITOR); if (use_thread) { thread_running = true; diff --git a/modules/gdscript/language_server/gdscript_language_server.h b/modules/gdscript/language_server/gdscript_language_server.h index 7b7837a4636..14c50909e07 100644 --- a/modules/gdscript/language_server/gdscript_language_server.h +++ b/modules/gdscript/language_server/gdscript_language_server.h @@ -44,6 +44,7 @@ class GDScriptLanguageServer : public EditorPlugin { bool thread_running; bool started; bool use_thread; + String host; int port; static void thread_main(void *p_userdata);