Skip to content

Commit

Permalink
Remove omnisharp config generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Chizaruu committed Aug 6, 2023
1 parent 12e397c commit 48c53ed
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 141 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Code Editor Package for Visual Studio Code

## [1.4.7] - 2023-08-06

- Remove omnisharp config generation from package
- Clean up code and remove unused directives
- Update .gitignore to remove .omnisharp.json ignore

## [1.4.6] - 2023-08-06

- Added ignore IDE0051 to .editorconfig default configuration
Expand Down
64 changes: 1 addition & 63 deletions Editor/ConfigGeneration/ConfigGeneration.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,12 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security;
using System.Security.Cryptography;
using System.Text;
using System.Xml.Linq;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEngine;
using UnityEngine.Profiling;
using SR = System.Reflection;

namespace VSCodeEditor
{
public interface IConfigGenerator
{
string VSCodeSettings { get; set; }
string WorkspaceSettings { get; set; }
string OmniSharpSettings { get; set; }
string EditorConfigSettings { get; set; }
string ProjectDirectory { get; }
IFlagHandler FlagHandler { get; }
Expand Down Expand Up @@ -82,10 +70,7 @@ public class ConfigGeneration : IConfigGenerator
""ProjectSettings/"":true,
""temp/"":true,
""Temp/"":true
},
""omnisharp.useModernNet"": true,
""omnisharp.sdkIncludePrereleases"": false,
""omnisharp.organizeImportsOnFormat"": true
}
}";

const string k_DefaultWorkspaceJson =
Expand All @@ -98,24 +83,6 @@ public class ConfigGeneration : IConfigGenerator
]
}";

const string k_DefaultOmniSharpJson =
/*lang=json,strict*/
@"{
""RoslynExtensionsOptions"": {
""EnableAnalyzersSupport"": true,
""AnalyzeOpenDocumentsOnly"": true,
""DocumentAnalysisTimeoutMs"": 600000
},
""FormattingOptions"": {
""enableEditorConfigSupport"": true
},
""RenameOptions"": {
""RenameInComments"": true,
""RenameOverloads"": true,
""RenameInStrings"": true
}
}";

const string k_DefaultEditorConfig =
@"# EditorConfig is awesome: http://EditorConfig.org
Expand All @@ -139,7 +106,6 @@ public class ConfigGeneration : IConfigGenerator

string m_VSCodeSettings;
string m_WorkspaceSettings;
string m_OmniSharpSettings;
string m_EditorConfigSettings;

public string VSCodeSettings
Expand Down Expand Up @@ -176,23 +142,6 @@ public string WorkspaceSettings
}
}

public string OmniSharpSettings
{
get =>
m_OmniSharpSettings ??= EditorPrefs.GetString(
"vscode_omnisharpSettings",
k_DefaultOmniSharpJson
);
set
{
if (value == "")
value = k_DefaultOmniSharpJson;

m_OmniSharpSettings = value;
EditorPrefs.SetString("vscode_omnisharpSettings", value);
}
}

public string EditorConfigSettings
{
get =>
Expand Down Expand Up @@ -232,7 +181,6 @@ public void Sync()
{
WriteVSCodeSettingsFiles();
WriteWorkspaceFile();
WriteOmniSharpConfigFile();
WriteEditorConfigFile();
}

Expand Down Expand Up @@ -264,16 +212,6 @@ void WriteWorkspaceFile()
}
}

void WriteOmniSharpConfigFile()
{
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.OmniSharp))
{
var omniSharpConfig = Path.Combine(ProjectDirectory, "omnisharp.json");

m_FileIOProvider.WriteAllText(omniSharpConfig, OmniSharpSettings);
}
}

void WriteEditorConfigFile()
{
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.EditorConfig))
Expand Down
7 changes: 1 addition & 6 deletions Editor/Utils/FlagHandler.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEditor.Compilation;
using UnityEditor.PackageManager;

namespace VSCodeEditor
{
Expand All @@ -20,8 +16,7 @@ public enum ConfigFlag
None = 0,
VSCode = 1,
Workspace = 2,
OmniSharp = 4,
EditorConfig = 8,
EditorConfig = 4,
}

[Flags]
Expand Down
71 changes: 0 additions & 71 deletions Editor/VSCodeScriptEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Linq;
using Unity.CodeEditor;
using UnityEditor;
using UnityEditor.PackageManager;
using UnityEngine;

namespace VSCodeEditor
Expand All @@ -23,12 +22,10 @@ public class VSCodeScriptEditor : IExternalCodeEditor
bool m_ShowProjectSection = true;
bool m_ShowVSCodeSettingsSection = false;
bool m_ShowWorkspaceSection = false;
bool m_ShowOmniSharpSection = false;
bool m_ShowEditorConfigSection = false;

Vector2 m_VSCodeScrollPosition;
Vector2 m_WorkspaceScrollPosition;
Vector2 m_OmniSharpScrollPosition;
Vector2 m_EditorConfigScrollPosition;

readonly IDiscovery m_Discoverability;
Expand Down Expand Up @@ -114,52 +111,6 @@ bool ShowProjectSection
}
}

bool ShowVSCodeSettingsSection
{
get =>
m_ShowVSCodeSettingsSection
|| EditorPrefs.GetBool("vscode_showVSCodeSettingsSection", false);
set
{
m_ShowVSCodeSettingsSection = value;
EditorPrefs.SetBool("vscode_showVSCodeSettingsSection", value);
}
}

bool ShowWorkspaceSection
{
get =>
m_ShowWorkspaceSection || EditorPrefs.GetBool("vscode_showWorkspaceSection", false);
set
{
m_ShowWorkspaceSection = value;
EditorPrefs.SetBool("vscode_showWorkspaceSection", value);
}
}

bool ShowOmniSharpSection
{
get =>
m_ShowOmniSharpSection || EditorPrefs.GetBool("vscode_showOmniSharpSection", false);
set
{
m_ShowOmniSharpSection = value;
EditorPrefs.SetBool("vscode_showOmniSharpSection", value);
}
}

bool ShowEditorConfigSection
{
get =>
m_ShowEditorConfigSection
|| EditorPrefs.GetBool("vscode_showEditorConfigSection", false);
set
{
m_ShowEditorConfigSection = value;
EditorPrefs.SetBool("vscode_showEditorConfigSection", value);
}
}

static string[] DefaultExtensions
{
get
Expand Down Expand Up @@ -337,22 +288,6 @@ ref m_VSCodeScrollPosition
ref m_WorkspaceScrollPosition
);

FlagButton(
ConfigFlag.OmniSharp,
"OmniSharp",
"",
(handler, flag) => handler.ConfigFlag.HasFlag(flag),
(handler, flag) => handler.ToggleConfig(flag)
);

if (m_ConfigGeneration.FlagHandler.ConfigFlag.HasFlag(ConfigFlag.OmniSharp))
RenderSettingsSection(
ref m_ShowOmniSharpSection,
m_ConfigGeneration.OmniSharpSettings,
"OmniSharp",
ref m_OmniSharpScrollPosition
);

FlagButton(
ConfigFlag.EditorConfig,
"EditorConfig",
Expand Down Expand Up @@ -408,9 +343,6 @@ ref Vector2 scrollPosition
case "Workspace":
m_ConfigGeneration.WorkspaceSettings = settings;
break;
case "OmniSharp":
m_ConfigGeneration.OmniSharpSettings = settings;
break;
case "editorconfig":
m_ConfigGeneration.EditorConfigSettings = settings;
break;
Expand Down Expand Up @@ -556,9 +488,6 @@ void RegenerateButton(string guiMessage, string command = "")
case "Reset Workspace settings":
m_ConfigGeneration.WorkspaceSettings = "";
break;
case "Reset OmniSharp settings":
m_ConfigGeneration.OmniSharpSettings = "";
break;
case "Reset editorconfig settings":
m_ConfigGeneration.EditorConfigSettings = "";
break;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.tsk.ide.vscode",
"displayName": "TSK VSCode Editor",
"description": "Unofficial code editor integration for supporting Visual Studio Code as code editor for Unity. Adds support for generating csproj files for intellisense purposes, auto discovery of installations, etc.",
"version": "1.4.6",
"version": "1.4.7",
"unity": "2021.3",
"dependencies": {},
"author": {
Expand Down

0 comments on commit 48c53ed

Please sign in to comment.