Skip to content

Commit

Permalink
Verily, the package doth cease to taketh configuration upon importati…
Browse files Browse the repository at this point in the history
…on. (#71)

* Remove TSKDoNotDelete Generation

- No longer can one's configuration be taken from them on import of this package.
- User must use `Preferences > External Tools > Generate config files for:` to generate their config files.

* Update README
  • Loading branch information
Chizaruu authored Aug 1, 2023
1 parent 31c3915 commit 520eb26
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 43 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TSK VSCode Editor

[![Discord](https://img.shields.io/discord/1106106269837819914?color=D1495B&logo=discord&logoColor=FFFFFF&style=flat)](https://discord.gg/VU8EhUY7bX) [![openupm](https://img.shields.io/badge/dynamic/json?color=brightgreen&label=downloads&query=%24.downloads&suffix=%2Fmonth&url=https%3A%2F%2Fpackage.openupm.com%2Fdownloads%2Fpoint%2Flast-month%2Fcom.tsk.ide.vscode)](https://openupm.com/packages/com.tsk.ide.vscode/) [![openupm](https://img.shields.io/npm/v/com.tsk.ide.vscode?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.tsk.ide.vscode/)
[![Discord](https://img.shields.io/discord/1106106269837819914?color=D1495B&logo=discord&logoColor=FFFFFF&style=flat)](https://discord.gg/VU8EhUY7bX) [![openupm](https://img.shields.io/badge/dynamic/json?color=brightgreen&label=downloads&query=%24.downloads&suffix=%2Fmonth&url=https%3A%2F%2Fpackage.openupm.com%2Fdownloads%2Fpoint%2Flast-month%2Fcom.tsk.ide.vscode)](https://openupm.com/packages/com.tsk.ide.vscode/) [![openupm](https://img.shields.io/npm/v/com.tsk.ide.vscode?label=openupm&registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.tsk.ide.vscode/)

Unity Code editor integration for VSCode. **(2021.3+)**

Expand All @@ -26,17 +26,17 @@ The `com.tsk.ide.vscode` package ensures a seamless build process by guaranteein

In addition to its core features, this package includes seamless integration with the Microsoft.Unity.Analyzers library. This integration provides you with access to a wide range of code analysis and validation tools specifically designed for Unity projects. With the support of these analyzers, you can enhance code quality, identify potential issues, and adhere to best practices, ultimately improving the overall robustness and maintainability of your Unity projects.

### Automated Configuration Setup
### Streamlined Configuration Setup and Customization

The `com.tsk.ide.vscode` package provides a professional solution for effortlessly setting up Visual Studio Code to seamlessly integrate with Unity. It automates the generation of essential configuration files, namely omnisharp.json and .editorconfig, sparing you valuable time and effort that would otherwise be spent on manual setup.
The com.tsk.ide.vscode package presents a proficient solution designed for streamlined integration of Visual Studio Code with Unity. This package significantly simplifies the setup process by generating essential configuration files, namely omnisharp.json and .editorconfig. This not only conserves valuable time but also boosts your efficiency by minimizing the potential for setup errors.

### Enable the Full Potential of Modern .NET
To utilize this feature, navigate to `Preferences > External Tools > Generate config files for:` and select the appropriate options to create the configuration files. After this, merely click on the `Regenerate` button.

By eliminating the need to disable the use of ModernNet, you can effortlessly access the complete range of modern .NET features within your Unity projects. This seamless integration unlocks a multitude of benefits, including enhanced performance and improved stability, empowering you to optimize your projects like never before.
Beyond simplifying setup, the com.tsk.ide.vscode package introduces a dedicated configuration section within External Tools. This component provides unprecedented control over the settings files generated, enabling manual customization in accordance with individual preferences and unique project requirements. This level of flexibility allows you to customize your development environment for the best possible productivity and outcome.

### Customization Options with Externals Tools
### Enable the Full Potential of Modern .NET

Furthermore, the package introduces a dedicated configuration section within External Tools. This empowers users to exercise complete control over the settings files generated by the package, allowing for manual customization to accommodate individual preferences and project-specific requirements. With this added flexibility, you can fine-tune your development environment to achieve optimal results.
By eliminating the need to disable the use of ModernNet, you can effortlessly access the complete range of modern .NET features within your Unity projects. This seamless integration unlocks a multitude of benefits, including enhanced performance and improved stability, empowering you to optimize your projects like never before.

## Prerequisites

Expand Down
46 changes: 15 additions & 31 deletions com.tsk.ide.vscode/Editor/ConfigGeneration/ConfigGeneration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public interface IConfigGenerator
string EditorConfigSettings { get; set; }
string ProjectDirectory { get; }
IFlagHandler FlagHandler { get; }
bool TskFileExists();
void Sync(bool force = false);
void Sync();
}

public class ConfigGeneration : IConfigGenerator
Expand Down Expand Up @@ -86,7 +85,7 @@ public class ConfigGeneration : IConfigGenerator
},
""omnisharp.useModernNet"": true,
""omnisharp.sdkIncludePrereleases"": false,
""omnisharp.organizeImportsOnFormat"": true,
""omnisharp.organizeImportsOnFormat"": true
}";

const string k_DefaultWorkspaceJson =
Expand Down Expand Up @@ -225,32 +224,17 @@ IFileIO fileIOProvider
m_FileIOProvider = new FileIOProvider();
}

public bool TskFileExists()
public void Sync()
{
var doNotDelete = Path.Combine(ProjectDirectory, "TSKDoNotDelete.txt");

if (m_FileIOProvider.Exists(doNotDelete))
return true;

m_FileIOProvider.WriteAllText(
doNotDelete,
"This file is used by the TSK VSCode Editor package. Deleting it will cause your configuration to be overwritten."
);

return false;
}

public void Sync(bool canForce = false)
{
WriteVSCodeSettingsFiles(canForce);
WriteWorkspaceFile(canForce);
WriteOmniSharpConfigFile(canForce);
WriteEditorConfigFile(canForce);
WriteVSCodeSettingsFiles();
WriteWorkspaceFile();
WriteOmniSharpConfigFile();
WriteEditorConfigFile();
}

void WriteVSCodeSettingsFiles(bool canForce = false)
void WriteVSCodeSettingsFiles()
{
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.VSCode) || canForce)
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.VSCode))
{
var vsCodeDirectory = Path.Combine(ProjectDirectory, ".vscode");

Expand All @@ -263,9 +247,9 @@ void WriteVSCodeSettingsFiles(bool canForce = false)
}
}

void WriteWorkspaceFile(bool canForce = false)
void WriteWorkspaceFile()
{
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.Workspace) || canForce)
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.Workspace))
{
var workspaceFile = Path.Combine(
ProjectDirectory,
Expand All @@ -276,19 +260,19 @@ void WriteWorkspaceFile(bool canForce = false)
}
}

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

m_FileIOProvider.WriteAllText(omniSharpConfig, OmniSharpSettings);
}
}

void WriteEditorConfigFile(bool canForce = false)
void WriteEditorConfigFile()
{
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.EditorConfig) || canForce)
if (m_FlagHandler.ConfigFlag.HasFlag(ConfigFlag.EditorConfig))
{
var editorConfig = Path.Combine(ProjectDirectory, ".editorconfig");

Expand Down
5 changes: 0 additions & 5 deletions com.tsk.ide.vscode/Editor/VSCodeScriptEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,6 @@ public void CreateIfDoesntExist()
{
m_ProjectGeneration.Sync();
}

if (!m_ConfigGeneration.TskFileExists())
{
m_ConfigGeneration.Sync(true);
}
}

public void SyncIfNeeded(
Expand Down

0 comments on commit 520eb26

Please sign in to comment.