Skip to content

Commit

Permalink
Expand AppIntent supported languages
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed May 15, 2024
1 parent 53781aa commit 8eabfa0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
9 changes: 9 additions & 0 deletions Edit/Modules/Editor/EditorScrollView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,12 @@ extension EditorScrollView {
super.scroll(clipView, to: point)
}
}

import SwiftUI

class NonSendable {
}

struct MyKey: EnvironmentKey {
static var defaultValue: NonSendable { NonSendable() }
}
1 change: 0 additions & 1 deletion Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import TreeSitterMarkdown
import TreeSitterMarkdownInline
import TreeSitterSwift


extension LanguageProfile {
static func profile(for utType: UTType) -> LanguageProfile {
if utType.conforms(to: .markdown) {
Expand Down
30 changes: 20 additions & 10 deletions EditIntents/HighlightIntent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,32 @@ import Theme
import TreeSitterClient
import UniformTypeIdentifiers

enum Language: String, Hashable, CaseIterable {
/// All types that are supported by EditIntents.
///
/// This must be defined within the same module as any AppIntent that uses it.
public enum RootLanguage: String, Hashable, CaseIterable, Sendable {
case swift = "Swift"
case go = "Go"
case markdown = "Markdown"

var typeIdentifier: UTType {
switch self {
case .swift:
.swiftSource
case .swift: .swiftSource
case .go: .goSource
case .markdown: .markdown
}
}
}

extension Language: AppEnum {
static let typeDisplayRepresentation: TypeDisplayRepresentation = "Language"
static let caseDisplayRepresentations: [Language: DisplayRepresentation] = [
.swift: "Swift",
]
extension RootLanguage: AppEnum {
public static var typeDisplayRepresentation: TypeDisplayRepresentation { "Language" }
public static var caseDisplayRepresentations: [RootLanguage: DisplayRepresentation] {
[
.swift: "Swift",
.go: "Go",
.markdown: "Markdown",
]
}
}

enum HighlightIntentError: Error {
Expand All @@ -30,14 +40,14 @@ enum HighlightIntentError: Error {

struct HighlightIntent: AppIntent {
nonisolated static let title: LocalizedStringResource = "Highlight Source Code"
static let description: IntentDescription = "Applies syntax highlighting to the input."
static var description: IntentDescription { "Applies syntax highlighting to the input." }
nonisolated static let openAppWhenRun = false

@Parameter(title: "Source", description: "The source code to be highlighted", inputConnectionBehavior: .connectToPreviousIntentResult)
var source: String

@Parameter(title: "Language")
var language: Language
var language: RootLanguage

nonisolated static var parameterSummary: some ParameterSummary {
Summary("Highlight \(\.$language) source code.")
Expand Down

0 comments on commit 8eabfa0

Please sign in to comment.