This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,50 @@
using TextMateSharp.Grammars;
using Unity.CodeEditor;
using Unity.CodeEditor.Rendering;
using Unity.CodeEditor.TextMate;
using UnityEditor;
using XDiffGui.Options;
namespace Unity.PlasticSCM.Editor.Diff.SyntaxHighlight
{
internal static class TextMateExtensions
{
internal static void SetLanguage(
this TextMate.Installation textMateInstallation,
XDiffGui.Options.Language language)
{
RegistryOptions registryOptions = (RegistryOptions)textMateInstallation.RegistryOptions;
if (IsMinifiedDocument(textMateInstallation.EditorModel))
{
textMateInstallation.SetGrammar(null);
return;
}
string languageId = TextMateLanguageId.Get(language);
textMateInstallation.SetGrammar(
registryOptions.GetScopeByLanguageId(languageId));
}
internal static TextMate.Installation InstallTextMate(this TextEditor editor)
{
ThemeName defaultTheme = EditorGUIUtility.isProSkin ?
ThemeName.DarkPlus : ThemeName.LightPlus;
return editor.InstallTextMate(
new RegistryOptions(defaultTheme),
false);
}
static bool IsMinifiedDocument(TextEditorModel textEditorModel)
{
if (textEditorModel == null)
return false;
// we consider a document minified if it has only one line and it's longer than 3000 characters
return textEditorModel.GetNumberOfLines() == 1 &&
textEditorModel.GetLineLength(0) > VisualLine.LENGTH_LIMIT;
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 02d69df45bb94c3c8a653cabb22c064b
timeCreated: 1772560216
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using XDiffGui.Options;
namespace Unity.PlasticSCM.Editor.Diff.SyntaxHighlight
{
internal static class UnitySyntaxLanguages
{
internal static readonly Dictionary<string, Language> AdditionalExtensions =
BuildExtensions();
static Dictionary<string, Language> BuildExtensions()
{
Dictionary<string, Language> result = new Dictionary<string, Language>(
StringComparer.OrdinalIgnoreCase);
foreach (string ext in DiffViewerDataExtensions.SERIALIZED_EXTENSIONS)
result[ext] = Language.YAML;
// the .anim is not included in
// serialized extensions, but we want
// to syntax hightlight them as yaml
result[".anim"] = Language.YAML;
return result;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3e6a332b6d9424412a0562bbf15ab9b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: