Skip to content

Commit

Permalink
Python support for #20
Browse files Browse the repository at this point in the history
  • Loading branch information
mattmassicotte committed Jul 11, 2024
1 parent eeccf63 commit 756c53c
Show file tree
Hide file tree
Showing 14 changed files with 340 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@
[submodule "submodules/chime-go"]
path = submodules/chime-go
url = [email protected]:ChimeHQ/chime-go.git
[submodule "submodules/chime-python"]
path = submodules/chime-python
url = [email protected]:ChimeHQ/chime-python.git
1 change: 1 addition & 0 deletions Configurations/NonSwiftWorkaround.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DI
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
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterOCaml.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterPython.modulemap
OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterSwift.modulemap
2 changes: 2 additions & 0 deletions Dependencies/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let package = Package(
.package(url: "https://github.com/mattmassicotte/tree-sitter-go-work", branch: "feature/spm"),
.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"),
.package(url: "https://github.com/tree-sitter/tree-sitter-python", branch: "master"),
.package(url: "https://github.com/alex-pinkus/tree-sitter-swift", branch: "with-generated-files"),
],
targets: [
Expand All @@ -34,6 +35,7 @@ let package = Package(
.product(name: "TreeSitterGoWork", package: "tree-sitter-go-work"),
.product(name: "TreeSitterMarkdown", package: "tree-sitter-markdown"),
.product(name: "TreeSitterOCaml", package: "tree-sitter-ocaml"),
.product(name: "TreeSitterPython", package: "tree-sitter-python"),
.product(name: "TreeSitterSwift", package: "tree-sitter-swift"),
]
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@
@_exported import TreeSitterMarkdown
@_exported import TreeSitterMarkdownInline
@_exported import TreeSitterOCaml
@_exported import TreeSitterPython
@_exported import TreeSitterSwift
115 changes: 115 additions & 0 deletions Edit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
C900A7C82A9E94AE000556A6 /* libPreferencesWindow.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C900A7BA2A9E93FC000556A6 /* libPreferencesWindow.a */; };
C900A7CA2A9E94B4000556A6 /* ExtendableHost in Frameworks */ = {isa = PBXBuildFile; productRef = C900A7C92A9E94B4000556A6 /* ExtendableHost */; };
C900A7D12A9F472E000556A6 /* Chime.appextensionpoint in Copy Extensions */ = {isa = PBXBuildFile; fileRef = C900A7CF2A9F46EF000556A6 /* Chime.appextensionpoint */; };
C92631AD2C40002F00C0AE07 /* PythonExtension.appex in Copy Extensions */ = {isa = PBXBuildFile; fileRef = C92631A52C40002F00C0AE07 /* PythonExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
C92631B22C40005800C0AE07 /* PythonStandaloneExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C92631B12C40005200C0AE07 /* PythonStandaloneExtension.swift */; };
C92672F82B0399D800B3CE2F /* SwiftExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C92672F72B0399D800B3CE2F /* SwiftExtension.swift */; };
C92672FA2B039AA300B3CE2F /* SwiftExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C92672F72B0399D800B3CE2F /* SwiftExtension.swift */; };
C92673452B05500500B3CE2F /* RegionLabellingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C92673442B05500500B3CE2F /* RegionLabellingView.swift */; };
Expand Down Expand Up @@ -150,6 +152,9 @@
C99491C52B153051002DC2AC /* TextMetrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99491C42B153051002DC2AC /* TextMetrics.swift */; };
C995EA6A2C3EC7A900D3ED4C /* ChimeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE52F42A7539B100CACA1A /* ChimeKit.framework */; };
C995EA752C3ED52900D3ED4C /* ClojureStandaloneExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C995EA742C3ED52900D3ED4C /* ClojureStandaloneExtension.swift */; };
C99A8DF92C40011100D8F599 /* PythonExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99A8DF82C40011100D8F599 /* PythonExtension.swift */; };
C99A8DFA2C40011100D8F599 /* PythonExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99A8DF82C40011100D8F599 /* PythonExtension.swift */; };
C99A8DFD2C40017200D8F599 /* ChimeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE52F42A7539B100CACA1A /* ChimeKit.framework */; };
C99D75F42B5DB42E0028E3B0 /* TextMetrics+ChimeKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = C99D75F32B5DB42E0028E3B0 /* TextMetrics+ChimeKit.swift */; };
C9B8A9812B1B836C00C79606 /* TextMetricsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B8A9802B1B836C00C79606 /* TextMetricsTests.swift */; };
C9B8A9D62B30613300C79606 /* DocumentCursorsMonitorModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9B8A9D52B30613300C79606 /* DocumentCursorsMonitorModifier.swift */; };
Expand Down Expand Up @@ -259,6 +264,13 @@
remoteGlobalIDString = C900A7B92A9E93FC000556A6;
remoteInfo = PreferencesWindow;
};
C92631AB2C40002F00C0AE07 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C9FE52912A7525D000CACA1A /* Project object */;
proxyType = 1;
remoteGlobalIDString = C92631A42C40002F00C0AE07;
remoteInfo = Python;
};
C92673482B055DD700B3CE2F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C9FE52912A7525D000CACA1A /* Project object */;
Expand Down Expand Up @@ -623,6 +635,13 @@
remoteGlobalIDString = C9FE52F32A7539B100CACA1A;
remoteInfo = ChimeKit;
};
C99A8DFB2C40016E00D8F599 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C9FE52912A7525D000CACA1A /* Project object */;
proxyType = 1;
remoteGlobalIDString = C9FE52F32A7539B100CACA1A;
remoteInfo = ChimeKit;
};
C99D76162B5FE1530028E3B0 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = C9FE52912A7525D000CACA1A /* Project object */;
Expand Down Expand Up @@ -918,6 +937,7 @@
C9BDB5502B00FD89009225FB /* SwiftExtension.appex in Copy Extensions */,
C9818AB22C3EF5ED0032899D /* ElixirExtension.appex in Copy Extensions */,
C9439A812C3EC4220020DDF5 /* ClojureExtension.appex in Copy Extensions */,
C92631AD2C40002F00C0AE07 /* PythonExtension.appex in Copy Extensions */,
C942E67E2B67B78F00792DD4 /* UserScriptExtension.appex in Copy Extensions */,
C900A7D12A9F472E000556A6 /* Chime.appextensionpoint in Copy Extensions */,
);
Expand Down Expand Up @@ -952,6 +972,8 @@
/* Begin PBXFileReference section */
C900A7BA2A9E93FC000556A6 /* libPreferencesWindow.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPreferencesWindow.a; sourceTree = BUILT_PRODUCTS_DIR; };
C900A7CF2A9F46EF000556A6 /* Chime.appextensionpoint */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Chime.appextensionpoint; sourceTree = "<group>"; };
C92631A52C40002F00C0AE07 /* PythonExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.extensionkit-extension"; includeInIndex = 0; path = PythonExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };
C92631B12C40005200C0AE07 /* PythonStandaloneExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PythonStandaloneExtension.swift; sourceTree = "<group>"; };
C92672F72B0399D800B3CE2F /* SwiftExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftExtension.swift; path = "submodules/chime-swift/Sources/ChimeSwift/SwiftExtension.swift"; sourceTree = SOURCE_ROOT; };
C92673282B04046700B3CE2F /* Edit-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Edit-Debug.xcconfig"; sourceTree = "<group>"; };
C92673432B05244600B3CE2F /* EditUITests.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = EditUITests.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1067,6 +1089,7 @@
C99491C12B0D1660002DC2AC /* TextStorageDispatcher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextStorageDispatcher.swift; sourceTree = "<group>"; };
C99491C42B153051002DC2AC /* TextMetrics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextMetrics.swift; sourceTree = "<group>"; };
C995EA742C3ED52900D3ED4C /* ClojureStandaloneExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClojureStandaloneExtension.swift; sourceTree = "<group>"; };
C99A8DF82C40011100D8F599 /* PythonExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PythonExtension.swift; path = "submodules/chime-python/Sources/ChimePython/PythonExtension.swift"; sourceTree = SOURCE_ROOT; };
C99D75F32B5DB42E0028E3B0 /* TextMetrics+ChimeKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "TextMetrics+ChimeKit.swift"; sourceTree = "<group>"; };
C99D76112B5EFA050028E3B0 /* TextViewSystemNeonInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextViewSystemNeonInterface.swift; sourceTree = "<group>"; };
C9B8A9802B1B836C00C79606 /* TextMetricsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextMetricsTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1189,6 +1212,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C92631A22C40002F00C0AE07 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C99A8DFD2C40017200D8F599 /* ChimeKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C929313F2B80CC6700C64DDE /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -1477,6 +1508,15 @@
path = PreferencesWindow;
sourceTree = "<group>";
};
C92631A62C40002F00C0AE07 /* Python */ = {
isa = PBXGroup;
children = (
C99A8DF82C40011100D8F599 /* PythonExtension.swift */,
C92631B12C40005200C0AE07 /* PythonStandaloneExtension.swift */,
);
path = Python;
sourceTree = "<group>";
};
C93F72492BF26BDC0021ACF3 /* EditIntents */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1746,6 +1786,7 @@
C9E878062A9F53530018340C /* Extension.entitlements */,
C9818AC32C3F2C2F0032899D /* Go */,
C9BDB54C2B00FD89009225FB /* Info.plist */,
C92631A62C40002F00C0AE07 /* Python */,
C9BDB5492B00FD89009225FB /* Swift */,
C9E878022A9F53530018340C /* UIPlaceholder */,
C942E6772B67B78F00792DD4 /* UserScriptExtension */,
Expand Down Expand Up @@ -1824,6 +1865,7 @@
C9439A792C3EC4220020DDF5 /* ClojureExtension.appex */,
C9818AAA2C3EF5ED0032899D /* ElixirExtension.appex */,
C9818AC22C3F2C2F0032899D /* GoExtension.appex */,
C92631A52C40002F00C0AE07 /* PythonExtension.appex */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -2259,6 +2301,24 @@
productReference = C900A7BA2A9E93FC000556A6 /* libPreferencesWindow.a */;
productType = "com.apple.product-type.library.static";
};
C92631A42C40002F00C0AE07 /* Python */ = {
isa = PBXNativeTarget;
buildConfigurationList = C92631B02C40002F00C0AE07 /* Build configuration list for PBXNativeTarget "Python" */;
buildPhases = (
C92631A12C40002F00C0AE07 /* Sources */,
C92631A22C40002F00C0AE07 /* Frameworks */,
C92631A32C40002F00C0AE07 /* Resources */,
);
buildRules = (
);
dependencies = (
C99A8DFC2C40016E00D8F599 /* PBXTargetDependency */,
);
name = Python;
productName = Python;
productReference = C92631A52C40002F00C0AE07 /* PythonExtension.appex */;
productType = "com.apple.product-type.extensionkit-extension";
};
C92931412B80CC6700C64DDE /* EditKit */ = {
isa = PBXNativeTarget;
buildConfigurationList = C929314A2B80CC6700C64DDE /* Build configuration list for PBXNativeTarget "EditKit" */;
Expand Down Expand Up @@ -2660,6 +2720,7 @@
C9439A802C3EC4220020DDF5 /* PBXTargetDependency */,
C9818AB12C3EF5ED0032899D /* PBXTargetDependency */,
C9818AC92C3F2C2F0032899D /* PBXTargetDependency */,
C92631AC2C40002F00C0AE07 /* PBXTargetDependency */,
);
name = Edit;
packageProductDependencies = (
Expand Down Expand Up @@ -2976,6 +3037,9 @@
CreatedOnToolsVersion = 15.0;
LastSwiftMigration = 1500;
};
C92631A42C40002F00C0AE07 = {
CreatedOnToolsVersion = 15.4;
};
C92931412B80CC6700C64DDE = {
CreatedOnToolsVersion = 15.3;
};
Expand Down Expand Up @@ -3150,11 +3214,19 @@
C9439A782C3EC4220020DDF5 /* Clojure */,
C9818AA92C3EF5ED0032899D /* Elixir */,
C9818AC12C3F2C2F0032899D /* Go */,
C92631A42C40002F00C0AE07 /* Python */,
);
};
/* End PBXProject section */

/* Begin PBXResourcesBuildPhase section */
C92631A32C40002F00C0AE07 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
C92931402B80CC6700C64DDE /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -3286,6 +3358,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
C92631A12C40002F00C0AE07 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
C92631B22C40005800C0AE07 /* PythonStandaloneExtension.swift in Sources */,
C99A8DFA2C40011100D8F599 /* PythonExtension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
C929313E2B80CC6700C64DDE /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -3651,6 +3732,7 @@
C941F0AD2B6E65110003B640 /* Process+Pipes.swift in Sources */,
C97919042A9E74620046EAF1 /* AppExtensionIdentity+UI.swift in Sources */,
C9818AD22C3F2CA70032899D /* GoExtension.swift in Sources */,
C99A8DF92C40011100D8F599 /* PythonExtension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -3678,6 +3760,11 @@
target = C900A7B92A9E93FC000556A6 /* PreferencesWindow */;
targetProxy = C900A7CD2A9E9600000556A6 /* PBXContainerItemProxy */;
};
C92631AC2C40002F00C0AE07 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C92631A42C40002F00C0AE07 /* Python */;
targetProxy = C92631AB2C40002F00C0AE07 /* PBXContainerItemProxy */;
};
C92673492B055DD700B3CE2F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C9FE53222A75A17700CACA1A /* UIUtility */;
Expand Down Expand Up @@ -4021,6 +4108,11 @@
target = C9FE52F32A7539B100CACA1A /* ChimeKit */;
targetProxy = C999C7852ABDA97500D49939 /* PBXContainerItemProxy */;
};
C99A8DFC2C40016E00D8F599 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C9FE52F32A7539B100CACA1A /* ChimeKit */;
targetProxy = C99A8DFB2C40016E00D8F599 /* PBXContainerItemProxy */;
};
C99D76172B5FE1530028E3B0 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = C9FE53DC2A7A5A2A00CACA1A /* ExtensionHost */;
Expand Down Expand Up @@ -4328,6 +4420,20 @@
};
name = Release;
};
C92631AE2C40002F00C0AE07 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C9E878112A9F53BB0018340C /* Extension.xcconfig */;
buildSettings = {
};
name = Debug;
};
C92631AF2C40002F00C0AE07 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C9E878112A9F53BB0018340C /* Extension.xcconfig */;
buildSettings = {
};
name = Release;
};
C929314B2B80CC6700C64DDE /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = C92931722B822BFF00C64DDE /* EditKit.xcconfig */;
Expand Down Expand Up @@ -4788,6 +4894,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C92631B02C40002F00C0AE07 /* Build configuration list for PBXNativeTarget "Python" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C92631AE2C40002F00C0AE07 /* Debug */,
C92631AF2C40002F00C0AE07 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
C929314A2B80CC6700C64DDE /* Build configuration list for PBXNativeTarget "EditKit" */ = {
isa = XCConfigurationList;
buildConfigurations = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "64557960cc5ec5b4a9453f704db74eda7fe05f7d4409970dff0b26d5861a97ae",
"originHash" : "a40fd49a16700338aabad67421f82fb686bfcd06da9dc2ea24be06be89094a14",
"pins" : [
{
"identity" : "asyncxpcconnection",
Expand Down Expand Up @@ -312,6 +312,15 @@
"revision" : "0b12614ded3ec7ed7ab7933a9ba4f695ba4c342e"
}
},
{
"identity" : "tree-sitter-python",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tree-sitter/tree-sitter-python",
"state" : {
"branch" : "master",
"revision" : "ccc2408e558029ad82b0dea63ff55ada495965da"
}
},
{
"identity" : "tree-sitter-swift",
"kind" : "remoteSourceControl",
Expand Down
24 changes: 16 additions & 8 deletions Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ extension LanguageProfile {
return LanguageProfile.elixirProfile
}

if utType.conforms(to: .goSource) {
return LanguageProfile.goProfile
}

if utType.conforms(to: .goSumFile) {
return LanguageProfile.goSumProfile
}

if utType.conforms(to: .markdown) {
return LanguageProfile.markdownProfile
}
Expand All @@ -32,16 +40,12 @@ extension LanguageProfile {
return LanguageProfile.ocamlInterfaceProfile
}

if utType.conforms(to: .swiftSource) {
return LanguageProfile.swiftProfile
if utType.conforms(to: .pythonScript) {
return LanguageProfile.pythonProfile
}

if utType.conforms(to: .goSource) {
return LanguageProfile.goProfile
}

if utType.conforms(to: .goSumFile) {
return LanguageProfile.goSumProfile
if utType.conforms(to: .swiftSource) {
return LanguageProfile.swiftProfile
}

return LanguageProfile.genericProfile
Expand Down Expand Up @@ -99,7 +103,11 @@ extension LanguageProfile {
name: "OCaml Interface",
language: Language(tree_sitter_ocaml_interface()),
bundleName: "TreeSitterOCaml_TreeSitterOCaml"
)

static let pythonProfile = LanguageProfile(
RootLanguage.python,
language: Language(tree_sitter_python())
)

static let swiftProfile = LanguageProfile(
Expand Down
Loading

0 comments on commit 756c53c

Please sign in to comment.