From 4f4994edf930dcd7d9bca4bfc0c6b759c48f5f6a Mon Sep 17 00:00:00 2001 From: Thiago Holanda Date: Thu, 21 Nov 2024 22:55:56 +0100 Subject: [PATCH] Add support to Rust (#22) * Add support to Rust * Fix crash when loading language configuration that may not exist --- Edit/Modules/SyntaxService/LanguageDataStore.swift | 2 +- .../Modules/SyntaxService/LanguageProfile+Profiles.swift | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Edit/Modules/SyntaxService/LanguageDataStore.swift b/Edit/Modules/SyntaxService/LanguageDataStore.swift index c22bb6f..80d274c 100644 --- a/Edit/Modules/SyntaxService/LanguageDataStore.swift +++ b/Edit/Modules/SyntaxService/LanguageDataStore.swift @@ -85,7 +85,7 @@ extension LanguageDataStore { } Task { - _ = try! await loadLanguageConfiguration(with: utType, identifier: identifier) + _ = try? await loadLanguageConfiguration(with: utType, identifier: identifier) } return nil diff --git a/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift b/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift index 18d0c88..f94ff92 100644 --- a/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift +++ b/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift @@ -55,6 +55,10 @@ extension LanguageProfile { if utType.conforms(to: .rubyScript) { return LanguageProfile.rubyProfile } + + if utType.conforms(to: .rustSource) { + return LanguageProfile.rustProfile + } if utType.conforms(to: .swiftSource) { return LanguageProfile.swiftProfile @@ -142,6 +146,11 @@ extension LanguageProfile { language: Language(tree_sitter_swift()) ) + static let rustProfile = LanguageProfile( + RootLanguage.rust, + language: Language(tree_sitter_rust()) + ) + static let genericProfile = LanguageProfile( name: "generic", language: nil,