Skip to content

Commit

Permalink
Elixir language support
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jul 10, 2024
1 parent 8308f68 commit af70d7a
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "submodules/chime-clojure"]
path = submodules/chime-clojure
url = [email protected]:ChimeHQ/chime-clojure.git
[submodule "submodules/chime-elixir"]
path = submodules/chime-elixir
url = [email protected]:ChimeHQ/chime-elixir.git
1 change: 1 addition & 0 deletions Configurations/NonSwiftWorkaround.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DI

// All the tree-sitter parsers
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterClojure.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterElixir.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGo.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdown.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterMarkdownInline.modulemap
Expand Down
2 changes: 2 additions & 0 deletions Dependencies/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ let package = Package(
],
dependencies: [
.package(url: "https://github.com/mattmassicotte/tree-sitter-clojure", branch: "feature/spm"),
.package(url: "https://github.com/elixir-lang/tree-sitter-elixir", branch: "main"),
.package(url: "https://github.com/tree-sitter/tree-sitter-go", branch: "master"),
.package(url: "https://github.com/tree-sitter-grammars/tree-sitter-markdown", branch: "split_parser"),
.package(url: "https://github.com/tree-sitter/tree-sitter-ocaml", branch: "master"),
Expand All @@ -23,6 +24,7 @@ let package = Package(
name: "TreeSitterParsers",
dependencies: [
.product(name: "TreeSitterClojure", package: "tree-sitter-clojure"),
.product(name: "TreeSitterElixir", package: "tree-sitter-elixir"),
.product(name: "TreeSitterGo", package: "tree-sitter-go"),
.product(name: "TreeSitterMarkdown", package: "tree-sitter-markdown"),
.product(name: "TreeSitterOCaml", package: "tree-sitter-ocaml"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@_exported import TreeSitterClojure
@_exported import TreeSitterElixir
@_exported import TreeSitterGo
@_exported import TreeSitterMarkdown
@_exported import TreeSitterMarkdownInline
Expand Down
118 changes: 117 additions & 1 deletion Edit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
C97C1FF52BCAA75200D133A7 /* LabelledTwoPartItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = C97C1FF42BCAA75200D133A7 /* LabelledTwoPartItem.swift */; };
C97C1FF92BCBF78500D133A7 /* SelectionViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C97C1FF82BCBF78500D133A7 /* SelectionViewModel.swift */; };
C97E86422BFA13700054BAB6 /* UserDefaults+Shared.swift in Sources */ = {isa = PBXBuildFile; fileRef = C97E86412BFA13700054BAB6 /* UserDefaults+Shared.swift */; };
C9818AB22C3EF5ED0032899D /* ElixirExtension.appex in Copy Extensions */ = {isa = PBXBuildFile; fileRef = C9818AAA2C3EF5ED0032899D /* ElixirExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
C9818AB92C3EF6E80032899D /* ElixirExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AB82C3EF6E80032899D /* ElixirExtension.swift */; };
C9818ABA2C3EF6E80032899D /* ElixirExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AB82C3EF6E80032899D /* ElixirExtension.swift */; };
C9818ABB2C3EF7000032899D /* ChimeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE52F42A7539B100CACA1A /* ChimeKit.framework */; };
C986F2492C3ED60800A62879 /* ClojureExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C986F2472C3ED60800A62879 /* ClojureExtension.swift */; };
C986F24A2C3ED67900A62879 /* ClojureExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C986F2472C3ED60800A62879 /* ClojureExtension.swift */; };
C9891AF82AFE996300C8F393 /* NSParagraphStyle+Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9891AF72AFE996300C8F393 /* NSParagraphStyle+Helpers.swift */; };
Expand Down Expand Up @@ -512,6 +516,20 @@
remoteGlobalIDString = C9B8A9DC2B31E43800C79606;
remoteInfo = TextSystem;
};
C9818AB02C3EF5ED0032899D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C9FE52912A7525D000CACA1A /* Project object */;
proxyType = 1;
remoteGlobalIDString = C9818AA92C3EF5ED0032899D;
remoteInfo = Elixir;
};
C9818ABC2C3EF7030032899D /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C9FE52912A7525D000CACA1A /* Project object */;
proxyType = 1;
remoteGlobalIDString = C9FE52F32A7539B100CACA1A;
remoteInfo = ChimeKit;
};
C9891AFE2AFEA3E400C8F393 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C9FE52912A7525D000CACA1A /* Project object */;
Expand Down Expand Up @@ -874,6 +892,7 @@
C93F72582BF26E9C0021ACF3 /* EditIntents.appex in Copy Extensions */,
C9E878092A9F53530018340C /* UIPlaceholderExtension.appex in Copy Extensions */,
C9BDB5502B00FD89009225FB /* SwiftExtension.appex in Copy Extensions */,
C9818AB22C3EF5ED0032899D /* ElixirExtension.appex in Copy Extensions */,
C9439A812C3EC4220020DDF5 /* ClojureExtension.appex in Copy Extensions */,
C942E67E2B67B78F00792DD4 /* UserScriptExtension.appex in Copy Extensions */,
C900A7D12A9F472E000556A6 /* Chime.appextensionpoint in Copy Extensions */,
Expand Down Expand Up @@ -1003,6 +1022,9 @@
C97C1FF42BCAA75200D133A7 /* LabelledTwoPartItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LabelledTwoPartItem.swift; sourceTree = "<group>"; };
C97C1FF82BCBF78500D133A7 /* SelectionViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SelectionViewModel.swift; sourceTree = "<group>"; };
C97E86412BFA13700054BAB6 /* UserDefaults+Shared.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UserDefaults+Shared.swift"; sourceTree = "<group>"; };
C9818AAA2C3EF5ED0032899D /* ElixirExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.extensionkit-extension"; includeInIndex = 0; path = ElixirExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
C9818AB62C3EF68B0032899D /* ElixirStandaloneExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElixirStandaloneExtension.swift; sourceTree = "<group>"; };
C9818AB82C3EF6E80032899D /* ElixirExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ElixirExtension.swift; path = "submodules/chime-elixir/Sources/ChimeElixir/ElixirExtension.swift"; sourceTree = SOURCE_ROOT; };
C986F2472C3ED60800A62879 /* ClojureExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ClojureExtension.swift; path = "submodules/chime-clojure/Sources/ChimeClojure/ClojureExtension.swift"; sourceTree = SOURCE_ROOT; };
C9891AF72AFE996300C8F393 /* NSParagraphStyle+Helpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSParagraphStyle+Helpers.swift"; sourceTree = "<group>"; };
C9891AF92AFE9A3900C8F393 /* NSFont+Measurements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSFont+Measurements.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1211,6 +1233,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C9818AA72C3EF5ED0032899D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C9818ABB2C3EF7000032899D /* ChimeKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C9891B112AFEC11A00C8F393 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1523,6 +1553,15 @@
path = AppKit;
sourceTree = "<group>";
};
C9818AAB2C3EF5ED0032899D /* Elixir */ = {
isa = PBXGroup;
children = (
C9818AB82C3EF6E80032899D /* ElixirExtension.swift */,
C9818AB62C3EF68B0032899D /* ElixirStandaloneExtension.swift */,
);
path = Elixir;
sourceTree = "<group>";
};
C9891AF62AFE994C00C8F393 /* AppKit */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1657,6 +1696,7 @@
isa = PBXGroup;
children = (
C9439A862C3EC4470020DDF5 /* Clojure */,
C9818AAB2C3EF5ED0032899D /* Elixir */,
C9E878062A9F53530018340C /* Extension.entitlements */,
C9BDB54C2B00FD89009225FB /* Info.plist */,
C9BDB5492B00FD89009225FB /* Swift */,
Expand Down Expand Up @@ -1735,6 +1775,7 @@
C9E0B9FC2BD27F0F007AF034 /* libDiagnostics.a */,
C93F72482BF26BDC0021ACF3 /* EditIntents.appex */,
C9439A792C3EC4220020DDF5 /* ClojureExtension.appex */,
C9818AAA2C3EF5ED0032899D /* ElixirExtension.appex */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -2318,6 +2359,24 @@
productReference = C979189E2A9D1D6D0046EAF1 /* libOpenQuickly.a */;
productType = "com.apple.product-type.library.static";
};
C9818AA92C3EF5ED0032899D /* Elixir */ = {
isa = PBXNativeTarget;
buildConfigurationList = C9818AB52C3EF5ED0032899D /* Build configuration list for PBXNativeTarget "Elixir" */;
buildPhases = (
C9818AA62C3EF5ED0032899D /* Sources */,
C9818AA72C3EF5ED0032899D /* Frameworks */,
C9818AA82C3EF5ED0032899D /* Resources */,
);
buildRules = (
);
dependencies = (
C9818ABD2C3EF7030032899D /* PBXTargetDependency */,
);
name = Elixir;
productName = Elixir;
productReference = C9818AAA2C3EF5ED0032899D /* ElixirExtension.appex */;
productType = "com.apple.product-type.extensionkit-extension";
};
C9891B122AFEC11A00C8F393 /* DocumentContent */ = {
isa = PBXNativeTarget;
buildConfigurationList = C9891B192AFEC11A00C8F393 /* Build configuration list for PBXNativeTarget "DocumentContent" */;
Expand Down Expand Up @@ -2533,6 +2592,7 @@
C92931472B80CC6700C64DDE /* PBXTargetDependency */,
C93F72512BF26BDC0021ACF3 /* PBXTargetDependency */,
C9439A802C3EC4220020DDF5 /* PBXTargetDependency */,
C9818AB12C3EF5ED0032899D /* PBXTargetDependency */,
);
name = Edit;
packageProductDependencies = (
Expand Down Expand Up @@ -2842,7 +2902,7 @@
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1600;
LastSwiftUpdateCheck = 1540;
LastUpgradeCheck = 1510;
TargetAttributes = {
C900A7B92A9E93FC000556A6 = {
Expand All @@ -2868,6 +2928,10 @@
C979189D2A9D1D6D0046EAF1 = {
CreatedOnToolsVersion = 15.0;
};
C9818AA92C3EF5ED0032899D = {
CreatedOnToolsVersion = 15.4;
LastSwiftMigration = 1540;
};
C9891B122AFEC11A00C8F393 = {
CreatedOnToolsVersion = 15.1;
};
Expand Down Expand Up @@ -3014,6 +3078,7 @@
C942E6752B67B78E00792DD4 /* UserScript */,
C9BDB5472B00FD89009225FB /* SwiftExtension */,
C9439A782C3EC4220020DDF5 /* Clojure */,
C9818AA92C3EF5ED0032899D /* Elixir */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -3048,6 +3113,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C9818AA82C3EF5ED0032899D /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
C9B8AA162B362DDD00C79606 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -3198,6 +3270,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C9818AA62C3EF5ED0032899D /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C9818ABA2C3EF6E80032899D /* ElixirExtension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C9891B102AFEC11A00C8F393 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -3472,6 +3552,7 @@
C92672FA2B039AA300B3CE2F /* SwiftExtension.swift in Sources */,
C9FE53E82A7A5B2000CACA1A /* LazyRemoteExtension.swift in Sources */,
C97919002A9E728F0046EAF1 /* ExtensionManager.swift in Sources */,
C9818AB92C3EF6E80032899D /* ElixirExtension.swift in Sources */,
C97918F82A9E5E520046EAF1 /* ExtensionRouter.swift in Sources */,
C97918FA2A9E5EAF0046EAF1 /* CompositeDocumentService.swift in Sources */,
C942E6AE2B69889F00792DD4 /* UserScriptExtension.swift in Sources */,
Expand Down Expand Up @@ -3762,6 +3843,16 @@
target = C9B8A9DC2B31E43800C79606 /* TextSystem */;
targetProxy = C97C1FF62BCBE60500D133A7 /* PBXContainerItemProxy */;
};
C9818AB12C3EF5ED0032899D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C9818AA92C3EF5ED0032899D /* Elixir */;
targetProxy = C9818AB02C3EF5ED0032899D /* PBXContainerItemProxy */;
};
C9818ABD2C3EF7030032899D /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C9FE52F32A7539B100CACA1A /* ChimeKit */;
targetProxy = C9818ABC2C3EF7030032899D /* PBXContainerItemProxy */;
};
C9891AFF2AFEA3E400C8F393 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C9FE53C72A77CC1E00CACA1A /* Theme */;
Expand Down Expand Up @@ -4219,6 +4310,20 @@
};
name = Release;
};
C9818AB32C3EF5ED0032899D /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C9E878112A9F53BB0018340C /* Extension.xcconfig */;
buildSettings = {
};
name = Debug;
};
C9818AB42C3EF5ED0032899D /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C9E878112A9F53BB0018340C /* Extension.xcconfig */;
buildSettings = {
};
name = Release;
};
C9891B1A2AFEC11A00C8F393 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C926738A2B078B0200B3CE2F /* WorkaroundModule.xcconfig */;
Expand Down Expand Up @@ -4363,13 +4468,15 @@
isa = XCBuildConfiguration;
baseConfigurationReference = C92673282B04046700B3CE2F /* Edit-Debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
};
name = Debug;
};
C9FE52C42A7525D300CACA1A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C9FE52CC2A752B4D00CACA1A /* Edit.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
};
name = Release;
};
Expand Down Expand Up @@ -4621,6 +4728,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C9818AB52C3EF5ED0032899D /* Build configuration list for PBXNativeTarget "Elixir" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C9818AB32C3EF5ED0032899D /* Debug */,
C9818AB42C3EF5ED0032899D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C9891B192AFEC11A00C8F393 /* Build configuration list for PBXNativeTarget "DocumentContent" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "ba844ec96bfdebc797744fae63b828fb6112a2d64a3f80033172abc0ed97bcd6",
"originHash" : "e7e174512a4cbf5c900b9b47cfbcd7730e05f04d11057492b2b5cb1750586fe9",
"pins" : [
{
"identity" : "asyncxpcconnection",
Expand Down Expand Up @@ -249,6 +249,15 @@
"revision" : "0a3d6ce7b48bae5e5d96af6bda9f47ec28e055bd"
}
},
{
"identity" : "tree-sitter-elixir",
"kind" : "remoteSourceControl",
"location" : "https://github.com/elixir-lang/tree-sitter-elixir",
"state" : {
"branch" : "main",
"revision" : "c7ae8b77e2749826dcf23df6514f08fdd68c66a3"
}
},
{
"identity" : "tree-sitter-go",
"kind" : "remoteSourceControl",
Expand Down
9 changes: 9 additions & 0 deletions Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ extension LanguageProfile {
return LanguageProfile.clojureProfile
}

if utType.conforms(to: .elixirSource) {
return LanguageProfile.elixirProfile
}

if utType.conforms(to: .markdown) {
return LanguageProfile.markdownProfile
}
Expand Down Expand Up @@ -46,6 +50,11 @@ extension LanguageProfile {
language: Language(tree_sitter_clojure())
)

static let elixirProfile = LanguageProfile(
RootLanguage.elixir,
language: Language(tree_sitter_elixir())
)

static let goProfile = LanguageProfile(
RootLanguage.go,
language: Language(tree_sitter_go())
Expand Down
6 changes: 6 additions & 0 deletions Edit/Modules/SyntaxService/RootLanguage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ChimeKit
/// This type must also be compiled into EditIntents, because the AppIntent infrastructure depends on having the type visible within the module.
public enum RootLanguage: Hashable, CaseIterable, Sendable {
case clojure
case elixir
case go
case markdown
case ocaml
Expand All @@ -17,6 +18,7 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable {
var typeIdentifier: UTType {
switch self {
case .clojure: .clojureSource
case .elixir: .elixirSource
case .go: .goSource
case .markdown: .markdown
case .ocaml: .ocamlSource
Expand All @@ -35,6 +37,8 @@ extension RootLanguage: RawRepresentable {
switch Self.normalizeLanguageName(rawValue) {
case "clojure":
self = .clojure
case "elixir":
self = .elixir
case "go":
self = .go
case "markdown":
Expand All @@ -54,6 +58,8 @@ extension RootLanguage: RawRepresentable {
switch self {
case .clojure:
"Clojure"
case .elixir:
"Elixir"
case .go:
"Go"
case .markdown:
Expand Down
Loading

0 comments on commit af70d7a

Please sign in to comment.