forked from JetBrains/godot-support
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GDScript LSP support (JetBrains#120)
* provide a settings page with some LSP options * optimized icon * provide cor runtimeType for run scene - fix JetBrains#117 * fix bug updating path of Godot4 exe * fix JetBrains#106 Run-configurations for Godot without C# * working on settings * ++ * ++ * stats for pure GDScript solutions * default UseDynamicPort to false * wip LspServerSupportProvider and indent options * working lsp * live templates * fix bug with specifying --lsp-port * cleanup * avoid multiple startServersIfNeeded * support dynamic port for Godot 4.3+ * disable lsp by default, disable and hide port when "Use a random free port" is checked * close lang server on disabling the setting * add comment * extract isMatchingFile logic * merge queue for starting lsp servers * fix merge
- Loading branch information
Showing
29 changed files
with
868 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using JetBrains.Application.Settings; | ||
using JetBrains.ReSharper.Resources.Settings; | ||
using JetBrains.Rider.Model.Godot.FrontendBackend; | ||
|
||
namespace JetBrains.ReSharper.Plugins.Godot.Application.Settings | ||
{ | ||
[SettingsKey(typeof(CodeEditingSettings), "Godot plugin settings")] | ||
public class GodotSettings | ||
{ | ||
// LSP | ||
[SettingsEntry(LanguageServerConnectionMode.Never, "Different ways to connect LSP")] | ||
public LanguageServerConnectionMode LanguageServerConnectionMode; | ||
|
||
[SettingsEntry("127.0.0.1", "RemoteHost")] | ||
public string RemoteHost; | ||
|
||
[SettingsEntry(6005, "Remote host port")] | ||
public int RemoteHostPort; | ||
|
||
[SettingsEntry(false, "Use a random free port, supported with Godot 4.3+")] | ||
public bool UseDynamicPort; | ||
|
||
// Debugging | ||
[SettingsEntry(true, "Enable debugger extensions")] | ||
public bool EnableDebuggerExtensions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#nullable enable | ||
|
||
using System; | ||
using System.Linq.Expressions; | ||
using JetBrains.Application.Settings; | ||
using JetBrains.Application.UI.Options; | ||
using JetBrains.Application.UI.Options.OptionsDialog; | ||
using JetBrains.Application.UI.Options.OptionsDialog.SimpleOptions; | ||
using JetBrains.Application.UI.Options.OptionsDialog.SimpleOptions.ViewModel; | ||
using JetBrains.DataFlow; | ||
using JetBrains.IDE.UI.Options; | ||
using JetBrains.Lifetimes; | ||
using JetBrains.ReSharper.Feature.Services.OptionPages.CodeEditing; | ||
using JetBrains.ReSharper.Plugins.Godot.Application.Settings; | ||
using JetBrains.Rider.Model.Godot.FrontendBackend; | ||
using JetBrains.Rider.Model.UIAutomation; | ||
using JetBrains.UI.ThemedIcons; | ||
|
||
namespace JetBrains.ReSharper.Plugins.Godot.Application.UI.Options | ||
{ | ||
[OptionsPage(PID, Name, typeof(QydowydThemedIconsThemedIcons.Godot), ParentId = CodeEditingPage.PID, | ||
HelpKeyword = "Settings_Godot_Engine")] | ||
public class GodotOptionsPage : BeSimpleOptionsPage | ||
{ | ||
public const string PID = "GodotPluginSettings"; | ||
public const string Name = "Godot Engine"; | ||
|
||
private static readonly Expression<Func<GodotSettings, LanguageServerConnectionMode>> ourLanguageServerConnectionMode = | ||
s => s.LanguageServerConnectionMode; | ||
|
||
private static readonly Expression<Func<GodotSettings, bool>> ourUseDynamicPort = s => s.UseDynamicPort; | ||
|
||
private static readonly Expression<Func<GodotSettings, int>> ourHostPortAccessor = | ||
s => s.RemoteHostPort; | ||
|
||
public GodotOptionsPage(Lifetime lifetime, | ||
OptionsPageContext pageContext, | ||
OptionsSettingsSmartContext settingsStore) | ||
: base(lifetime, pageContext, settingsStore) | ||
{ | ||
AddNetworkSection(); | ||
} | ||
|
||
private void AddNetworkSection() | ||
{ | ||
AddHeader("Network"); | ||
using (Indent()) | ||
{ | ||
AddComboOption((GodotSettings s) => s.LanguageServerConnectionMode, | ||
"Connecting LSP server:", string.Empty, string.Empty, | ||
new RadioOptionPoint(LanguageServerConnectionMode.StartEditorHeadless, "Automatically start headless LSP server"), | ||
// new RadioOptionPoint(LanguageServerConnectionMode.ConnectRunningEditor, "Attempt to connect the running Godot Editor"), // todo: commented because need some tricky waiting and probing the port | ||
new RadioOptionPoint(LanguageServerConnectionMode.Never, "Never use LSP") | ||
); | ||
AddKeyword("Language server"); | ||
|
||
// AddTextBox(ourHostNameAccessor, "Host"); // host is always localhot, lets not allow changing it. | ||
|
||
// Godot 4.3 and later | ||
var useDynamic = AddBoolOption(ourUseDynamicPort, "Use a random free port (supported in Godot 4.3+)", | ||
toolTipText: "Only supported by the Godot 4.3+"); | ||
|
||
var portOption = AddIntOption(ourHostPortAccessor, "Port"); | ||
|
||
// AddBinding(portOption, BindingStyle.IsEnabledProperty, ourUseDynamicPort, enable => !enable); | ||
|
||
var sourceProperty = OptionsSettingsSmartContext.GetValueProperty(Lifetime, ourUseDynamicPort); | ||
sourceProperty | ||
.Change.Advise(Lifetime, () => | ||
{ | ||
// RIDER-104651 Visibility of a BeControl based on other settings works inconsistently | ||
portOption.Enabled.Value = !sourceProperty.Value; // this always works | ||
portOption.Visible.Value = sourceProperty.Value ? ControlVisibility.Collapsed: ControlVisibility.Visible; // this doesn't work initially, but starts working when you change sourceProperty back and forth | ||
}); | ||
|
||
// AddBinding(portOption, BindingStyle.IsEnabledProperty, ourLanguageServerConnectionMode, | ||
// mode => mode is not LanguageServerConnectionMode.Never); | ||
AddBinding(useDynamic, BindingStyle.IsEnabledProperty, ourLanguageServerConnectionMode, | ||
mode => mode is LanguageServerConnectionMode.StartEditorHeadless); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.