diff --git a/.gitmodules b/.gitmodules index 48b2c4f..55ff8b9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "submodules/chime-elixir"] path = submodules/chime-elixir url = git@github.com:ChimeHQ/chime-elixir.git +[submodule "submodules/chime-go"] + path = submodules/chime-go + url = git@github.com:ChimeHQ/chime-go.git diff --git a/Configurations/NonSwiftWorkaround.xcconfig b/Configurations/NonSwiftWorkaround.xcconfig index 82e1f1b..43b1f0a 100644 --- a/Configurations/NonSwiftWorkaround.xcconfig +++ b/Configurations/NonSwiftWorkaround.xcconfig @@ -10,6 +10,9 @@ OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DI 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)/TreeSitterGoMod.modulemap +OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGosum.modulemap +OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterGoWork.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 OTHER_SWIFT_FLAGS = $(inherited) -Xcc -fmodule-map-file=$(GENERATED_MODULEMAP_DIR)/TreeSitterOCaml.modulemap diff --git a/Dependencies/Package.swift b/Dependencies/Package.swift index eb4b2b7..9011ca8 100644 --- a/Dependencies/Package.swift +++ b/Dependencies/Package.swift @@ -15,6 +15,9 @@ let package = Package( .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/camdencheek/tree-sitter-go-mod", branch: "main"), + .package(url: "https://github.com/tree-sitter-grammars/tree-sitter-go-sum", branch: "master"), + .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/alex-pinkus/tree-sitter-swift", branch: "with-generated-files"), @@ -26,6 +29,9 @@ let package = Package( .product(name: "TreeSitterClojure", package: "tree-sitter-clojure"), .product(name: "TreeSitterElixir", package: "tree-sitter-elixir"), .product(name: "TreeSitterGo", package: "tree-sitter-go"), + .product(name: "TreeSitterGoMod", package: "tree-sitter-go-mod"), + .product(name: "TreeSitterGosum", package: "tree-sitter-go-sum"), + .product(name: "TreeSitterGoWork", package: "tree-sitter-go-work"), .product(name: "TreeSitterMarkdown", package: "tree-sitter-markdown"), .product(name: "TreeSitterOCaml", package: "tree-sitter-ocaml"), .product(name: "TreeSitterSwift", package: "tree-sitter-swift"), diff --git a/Dependencies/Sources/TreeSitterParsers/TreeSitterParsers.swift b/Dependencies/Sources/TreeSitterParsers/TreeSitterParsers.swift index e5ff11e..6c4ea92 100644 --- a/Dependencies/Sources/TreeSitterParsers/TreeSitterParsers.swift +++ b/Dependencies/Sources/TreeSitterParsers/TreeSitterParsers.swift @@ -1,6 +1,9 @@ @_exported import TreeSitterClojure @_exported import TreeSitterElixir @_exported import TreeSitterGo +@_exported import TreeSitterGoMod +@_exported import TreeSitterGosum +@_exported import TreeSitterGoWork @_exported import TreeSitterMarkdown @_exported import TreeSitterMarkdownInline @_exported import TreeSitterOCaml diff --git a/Edit.xcodeproj/project.pbxproj b/Edit.xcodeproj/project.pbxproj index 9c711bf..3ada9d3 100644 --- a/Edit.xcodeproj/project.pbxproj +++ b/Edit.xcodeproj/project.pbxproj @@ -128,6 +128,14 @@ 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 */; }; + C9818ACA2C3F2C2F0032899D /* GoExtension.appex in Copy Extensions */ = {isa = PBXBuildFile; fileRef = C9818AC22C3F2C2F0032899D /* GoExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; + C9818ACF2C3F2C870032899D /* GoStandaloneExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818ACE2C3F2C7F0032899D /* GoStandaloneExtension.swift */; }; + C9818AD22C3F2CA70032899D /* GoExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AD02C3F2CA70032899D /* GoExtension.swift */; }; + C9818AD32C3F2CA70032899D /* GoExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AD02C3F2CA70032899D /* GoExtension.swift */; }; + C9818AD42C3F2CA70032899D /* Gopls.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AD12C3F2CA70032899D /* Gopls.swift */; }; + C9818AD52C3F2CA70032899D /* Gopls.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AD12C3F2CA70032899D /* Gopls.swift */; }; + C9818AD82C3F2D350032899D /* ChimeKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C9FE52F42A7539B100CACA1A /* ChimeKit.framework */; }; + C9818AD92C3F2DB90032899D /* Gopls.swift in Sources */ = {isa = PBXBuildFile; fileRef = C9818AD12C3F2CA70032899D /* Gopls.swift */; }; 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 */; }; @@ -530,6 +538,20 @@ remoteGlobalIDString = C9FE52F32A7539B100CACA1A; remoteInfo = ChimeKit; }; + C9818AC82C3F2C2F0032899D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C9FE52912A7525D000CACA1A /* Project object */; + proxyType = 1; + remoteGlobalIDString = C9818AC12C3F2C2F0032899D; + remoteInfo = Go; + }; + C9818AD62C3F2D2F0032899D /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = C9FE52912A7525D000CACA1A /* Project object */; + proxyType = 1; + remoteGlobalIDString = C9FE52F32A7539B100CACA1A; + remoteInfo = ChimeKit; + }; C9891AFE2AFEA3E400C8F393 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = C9FE52912A7525D000CACA1A /* Project object */; @@ -891,6 +913,7 @@ files = ( C93F72582BF26E9C0021ACF3 /* EditIntents.appex in Copy Extensions */, C9E878092A9F53530018340C /* UIPlaceholderExtension.appex in Copy Extensions */, + C9818ACA2C3F2C2F0032899D /* GoExtension.appex in Copy Extensions */, C9BDB5502B00FD89009225FB /* SwiftExtension.appex in Copy Extensions */, C9818AB22C3EF5ED0032899D /* ElixirExtension.appex in Copy Extensions */, C9439A812C3EC4220020DDF5 /* ClojureExtension.appex in Copy Extensions */, @@ -1025,6 +1048,10 @@ 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 = ""; }; C9818AB82C3EF6E80032899D /* ElixirExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ElixirExtension.swift; path = "submodules/chime-elixir/Sources/ChimeElixir/ElixirExtension.swift"; sourceTree = SOURCE_ROOT; }; + C9818AC22C3F2C2F0032899D /* GoExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.extensionkit-extension"; includeInIndex = 0; path = GoExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; + C9818ACE2C3F2C7F0032899D /* GoStandaloneExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GoStandaloneExtension.swift; sourceTree = ""; }; + C9818AD02C3F2CA70032899D /* GoExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GoExtension.swift; path = "submodules/chime-go/Sources/ChimeGo/GoExtension.swift"; sourceTree = SOURCE_ROOT; }; + C9818AD12C3F2CA70032899D /* Gopls.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Gopls.swift; path = "submodules/chime-go/Sources/ChimeGo/Gopls.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 = ""; }; C9891AF92AFE9A3900C8F393 /* NSFont+Measurements.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSFont+Measurements.swift"; sourceTree = ""; }; @@ -1241,6 +1268,14 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C9818ABF2C3F2C2F0032899D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + C9818AD82C3F2D350032899D /* ChimeKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; C9891B112AFEC11A00C8F393 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -1562,6 +1597,16 @@ path = Elixir; sourceTree = ""; }; + C9818AC32C3F2C2F0032899D /* Go */ = { + isa = PBXGroup; + children = ( + C9818AD02C3F2CA70032899D /* GoExtension.swift */, + C9818AD12C3F2CA70032899D /* Gopls.swift */, + C9818ACE2C3F2C7F0032899D /* GoStandaloneExtension.swift */, + ); + path = Go; + sourceTree = ""; + }; C9891AF62AFE994C00C8F393 /* AppKit */ = { isa = PBXGroup; children = ( @@ -1698,6 +1743,7 @@ C9439A862C3EC4470020DDF5 /* Clojure */, C9818AAB2C3EF5ED0032899D /* Elixir */, C9E878062A9F53530018340C /* Extension.entitlements */, + C9818AC32C3F2C2F0032899D /* Go */, C9BDB54C2B00FD89009225FB /* Info.plist */, C9BDB5492B00FD89009225FB /* Swift */, C9E878022A9F53530018340C /* UIPlaceholder */, @@ -1776,6 +1822,7 @@ C93F72482BF26BDC0021ACF3 /* EditIntents.appex */, C9439A792C3EC4220020DDF5 /* ClojureExtension.appex */, C9818AAA2C3EF5ED0032899D /* ElixirExtension.appex */, + C9818AC22C3F2C2F0032899D /* GoExtension.appex */, ); name = Products; sourceTree = ""; @@ -2377,6 +2424,24 @@ productReference = C9818AAA2C3EF5ED0032899D /* ElixirExtension.appex */; productType = "com.apple.product-type.extensionkit-extension"; }; + C9818AC12C3F2C2F0032899D /* Go */ = { + isa = PBXNativeTarget; + buildConfigurationList = C9818ACD2C3F2C2F0032899D /* Build configuration list for PBXNativeTarget "Go" */; + buildPhases = ( + C9818ABE2C3F2C2F0032899D /* Sources */, + C9818ABF2C3F2C2F0032899D /* Frameworks */, + C9818AC02C3F2C2F0032899D /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + C9818AD72C3F2D2F0032899D /* PBXTargetDependency */, + ); + name = Go; + productName = Go; + productReference = C9818AC22C3F2C2F0032899D /* GoExtension.appex */; + productType = "com.apple.product-type.extensionkit-extension"; + }; C9891B122AFEC11A00C8F393 /* DocumentContent */ = { isa = PBXNativeTarget; buildConfigurationList = C9891B192AFEC11A00C8F393 /* Build configuration list for PBXNativeTarget "DocumentContent" */; @@ -2593,6 +2658,7 @@ C93F72512BF26BDC0021ACF3 /* PBXTargetDependency */, C9439A802C3EC4220020DDF5 /* PBXTargetDependency */, C9818AB12C3EF5ED0032899D /* PBXTargetDependency */, + C9818AC92C3F2C2F0032899D /* PBXTargetDependency */, ); name = Edit; packageProductDependencies = ( @@ -2932,6 +2998,9 @@ CreatedOnToolsVersion = 15.4; LastSwiftMigration = 1540; }; + C9818AC12C3F2C2F0032899D = { + CreatedOnToolsVersion = 15.4; + }; C9891B122AFEC11A00C8F393 = { CreatedOnToolsVersion = 15.1; }; @@ -3079,6 +3148,7 @@ C9BDB5472B00FD89009225FB /* SwiftExtension */, C9439A782C3EC4220020DDF5 /* Clojure */, C9818AA92C3EF5ED0032899D /* Elixir */, + C9818AC12C3F2C2F0032899D /* Go */, ); }; /* End PBXProject section */ @@ -3120,6 +3190,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C9818AC02C3F2C2F0032899D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; C9B8AA162B362DDD00C79606 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; @@ -3230,6 +3307,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + C9818AD92C3F2DB90032899D /* Gopls.swift in Sources */, C942E6AC2B69747E00792DD4 /* UserScriptStandaloneExtension.swift in Sources */, C942E6792B67B78F00792DD4 /* UserScriptExtension.swift in Sources */, ); @@ -3278,6 +3356,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + C9818ABE2C3F2C2F0032899D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + C9818AD52C3F2CA70032899D /* Gopls.swift in Sources */, + C9818ACF2C3F2C870032899D /* GoStandaloneExtension.swift in Sources */, + C9818AD32C3F2CA70032899D /* GoExtension.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; C9891B102AFEC11A00C8F393 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; @@ -3549,6 +3637,7 @@ C97918FC2A9E5EFC0046EAF1 /* CompositeProjectService.swift in Sources */, C941F0AC2B6E5A760003B640 /* AppHost.swift in Sources */, C986F24A2C3ED67900A62879 /* ClojureExtension.swift in Sources */, + C9818AD42C3F2CA70032899D /* Gopls.swift in Sources */, C92672FA2B039AA300B3CE2F /* SwiftExtension.swift in Sources */, C9FE53E82A7A5B2000CACA1A /* LazyRemoteExtension.swift in Sources */, C97919002A9E728F0046EAF1 /* ExtensionManager.swift in Sources */, @@ -3559,6 +3648,7 @@ C9FE54072A7A617000CACA1A /* ExtensionDocumentState.swift in Sources */, C941F0AD2B6E65110003B640 /* Process+Pipes.swift in Sources */, C97919042A9E74620046EAF1 /* AppExtensionIdentity+UI.swift in Sources */, + C9818AD22C3F2CA70032899D /* GoExtension.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -3853,6 +3943,16 @@ target = C9FE52F32A7539B100CACA1A /* ChimeKit */; targetProxy = C9818ABC2C3EF7030032899D /* PBXContainerItemProxy */; }; + C9818AC92C3F2C2F0032899D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C9818AC12C3F2C2F0032899D /* Go */; + targetProxy = C9818AC82C3F2C2F0032899D /* PBXContainerItemProxy */; + }; + C9818AD72C3F2D2F0032899D /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = C9FE52F32A7539B100CACA1A /* ChimeKit */; + targetProxy = C9818AD62C3F2D2F0032899D /* PBXContainerItemProxy */; + }; C9891AFF2AFEA3E400C8F393 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = C9FE53C72A77CC1E00CACA1A /* Theme */; @@ -4324,6 +4424,20 @@ }; name = Release; }; + C9818ACB2C3F2C2F0032899D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C9E878112A9F53BB0018340C /* Extension.xcconfig */; + buildSettings = { + }; + name = Debug; + }; + C9818ACC2C3F2C2F0032899D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = C9E878112A9F53BB0018340C /* Extension.xcconfig */; + buildSettings = { + }; + name = Release; + }; C9891B1A2AFEC11A00C8F393 /* Debug */ = { isa = XCBuildConfiguration; baseConfigurationReference = C926738A2B078B0200B3CE2F /* WorkaroundModule.xcconfig */; @@ -4737,6 +4851,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + C9818ACD2C3F2C2F0032899D /* Build configuration list for PBXNativeTarget "Go" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C9818ACB2C3F2C2F0032899D /* Debug */, + C9818ACC2C3F2C2F0032899D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; C9891B192AFEC11A00C8F393 /* Build configuration list for PBXNativeTarget "DocumentContent" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 6a0e165..decbc66 100644 --- a/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Edit.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "e7e174512a4cbf5c900b9b47cfbcd7730e05f04d11057492b2b5cb1750586fe9", + "originHash" : "64557960cc5ec5b4a9453f704db74eda7fe05f7d4409970dff0b26d5861a97ae", "pins" : [ { "identity" : "asyncxpcconnection", @@ -267,6 +267,33 @@ "revision" : "7ee8d928db5202f6831a78f8112fd693bf69f98b" } }, + { + "identity" : "tree-sitter-go-mod", + "kind" : "remoteSourceControl", + "location" : "https://github.com/camdencheek/tree-sitter-go-mod", + "state" : { + "branch" : "main", + "revision" : "bbe2fe3be4b87e06a613e685250f473d2267f430" + } + }, + { + "identity" : "tree-sitter-go-sum", + "kind" : "remoteSourceControl", + "location" : "https://github.com/tree-sitter-grammars/tree-sitter-go-sum", + "state" : { + "branch" : "master", + "revision" : "e2ac513b2240c7ff1069ae33b2df29ce90777c11" + } + }, + { + "identity" : "tree-sitter-go-work", + "kind" : "remoteSourceControl", + "location" : "https://github.com/mattmassicotte/tree-sitter-go-work", + "state" : { + "branch" : "feature/spm", + "revision" : "177fb5a21eecd6709deeeaf7abcb6a13c7dd38f5" + } + }, { "identity" : "tree-sitter-markdown", "kind" : "remoteSourceControl", diff --git a/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift b/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift index f4e014d..03156eb 100644 --- a/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift +++ b/Edit/Modules/SyntaxService/LanguageProfile+Profiles.swift @@ -40,6 +40,10 @@ extension LanguageProfile { return LanguageProfile.goProfile } + if utType.conforms(to: .goSumFile) { + return LanguageProfile.goSumProfile + } + return LanguageProfile.genericProfile } } @@ -60,6 +64,21 @@ extension LanguageProfile { language: Language(tree_sitter_go()) ) + static let goModProfile = LanguageProfile( + RootLanguage.goMod, + language: Language(tree_sitter_gomod()) + ) + + static let goSumProfile = LanguageProfile( + RootLanguage.goSum, + language: Language(tree_sitter_gosum()) + ) + + static let goWorkProfile = LanguageProfile( + RootLanguage.goWork, + language: Language(tree_sitter_gowork()) + ) + static let markdownProfile = LanguageProfile( RootLanguage.markdown, language: Language(tree_sitter_markdown()) diff --git a/Edit/Modules/SyntaxService/RootLanguage.swift b/Edit/Modules/SyntaxService/RootLanguage.swift index fe3673b..638e0e4 100644 --- a/Edit/Modules/SyntaxService/RootLanguage.swift +++ b/Edit/Modules/SyntaxService/RootLanguage.swift @@ -10,6 +10,9 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable { case clojure case elixir case go + case goMod + case goSum + case goWork case markdown case ocaml case ocamlInterface @@ -20,6 +23,9 @@ public enum RootLanguage: Hashable, CaseIterable, Sendable { case .clojure: .clojureSource case .elixir: .elixirSource case .go: .goSource + case .goMod: .goModFile + case .goSum: .goSumFile + case .goWork: .goWorkFile case .markdown: .markdown case .ocaml: .ocamlSource case .ocamlInterface: .ocamlInterface @@ -41,6 +47,12 @@ extension RootLanguage: RawRepresentable { self = .elixir case "go": self = .go + case "gomod": + self = .goMod + case "gosum": + self = .goSum + case "gowork": + self = .goWork case "markdown": self = .markdown case "ocaml": @@ -62,6 +74,12 @@ extension RootLanguage: RawRepresentable { "Elixir" case .go: "Go" + case .goMod: + "Go Mod" + case .goSum: + "Go Sum" + case .goWork: + "Go Work" case .markdown: "Markdown" case .ocaml: diff --git a/Edit/Resources/Info.plist b/Edit/Resources/Info.plist index e3a2e73..e2f9f3d 100644 --- a/Edit/Resources/Info.plist +++ b/Edit/Resources/Info.plist @@ -141,6 +141,57 @@ + + UTTypeConformsTo + + public.source-code + + UTTypeDescription + Go Module + UTTypeIdentifier + dev.go.go-module + UTTypeTagSpecification + + public.filename-extension + + mod + + + + + UTTypeDescription + Go Workspace File + UTTypeConformsTo + + public.source-code + + UTTypeIdentifier + dev.go.go-work + UTTypeTagSpecification + + public.filename-extension + + work + + + + + UTTypeConformsTo + + public.source-code + + UTTypeDescription + Go Module Checksums + UTTypeIdentifier + dev.go.go-sum + UTTypeTagSpecification + + public.filename-extension + + sum + + + UTTypeConformsTo diff --git a/Edit/Resources/LanguageData/Go/queries/highlights.scm b/Edit/Resources/LanguageData/Go/queries/highlights.scm new file mode 100644 index 0000000..6a3c0ac --- /dev/null +++ b/Edit/Resources/LanguageData/Go/queries/highlights.scm @@ -0,0 +1,123 @@ +; Function calls + +(call_expression + function: (identifier) @function) + +(call_expression + function: (identifier) @function.builtin + (#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$")) + +(call_expression + function: (selector_expression + field: (field_identifier) @function.method)) + +; Function definitions + +(function_declaration + name: (identifier) @function) + +(method_declaration + name: (field_identifier) @function.method) + +; Identifiers + +(type_identifier) @type +(field_identifier) @property +(identifier) @variable + +; Operators + +[ + "--" + "-" + "-=" + ":=" + "!" + "!=" + "..." + "*" + "*" + "*=" + "/" + "/=" + "&" + "&&" + "&=" + "%" + "%=" + "^" + "^=" + "+" + "++" + "+=" + "<-" + "<" + "<<" + "<<=" + "<=" + "=" + "==" + ">" + ">=" + ">>" + ">>=" + "|" + "|=" + "||" + "~" +] @operator + +; Keywords + +[ + "break" + "case" + "chan" + "const" + "continue" + "default" + "defer" + "else" + "fallthrough" + "for" + "func" + "go" + "goto" + "if" + "import" + "interface" + "map" + "package" + "range" + "return" + "select" + "struct" + "switch" + "type" + "var" +] @keyword + +; Literals + +[ + (interpreted_string_literal) + (raw_string_literal) + (rune_literal) +] @string + +(escape_sequence) @escape + +[ + (int_literal) + (float_literal) + (imaginary_literal) +] @number + +[ + (true) + (false) + (nil) + (iota) +] @constant.builtin + +(comment) @comment diff --git a/Edit/Resources/LanguageData/Go/queries/structure.scm b/Edit/Resources/LanguageData/Go/queries/structure.scm new file mode 100644 index 0000000..b86a123 --- /dev/null +++ b/Edit/Resources/LanguageData/Go/queries/structure.scm @@ -0,0 +1,175 @@ +(import_declaration + "import" @structure.anchor + (import_spec_list + "(" @structure.open + ")" @structure.close + ) +) + +(function_declaration + "func" @structure.anchor + body: (block + "{" @structure.open + "}" @structure.close + ) +) + +(function_declaration + (identifier) @structure.anchor + (parameter_list + "(" @structure.open + ("," @structure.separator (_))* + ")" @structure.close + ) +) + +(method_declaration + "func" @structure.anchor + body: (block + "{" @structure.open + "}" @structure.close + ) +) + +(call_expression + function: (_) @structure.anchor + (argument_list + "(" @structure.open + ("," @structure.separator (_))* + ","? @structure.separator + ")" @structure.close + ) +) + +(composite_literal + type: (_) @structure.anchor + body: (literal_value + "{" @structure.open + ("," @structure.separator (_)?)* + "}" @structure.close + ) +) + +(literal_value + "{" @structure.anchor + ("," @structure.separator (_)?)* + "}" @structure.close +) + +(if_statement + ["if" "else"] @structure.anchor + (block + "{" @structure.open + "}" @structure.close + ) +) + +(if_statement + "else" @structure.anchor + (if_statement + "if" + (block + "{" @structure.open + "}" @structure.close + ) + ) +) + +(expression_switch_statement + "switch" @structure.anchor + "{" @structure.open + "}" @structure.close +) + +(expression_switch_statement + (expression_case + "case" @structure.anchor + ":" @structure.open + ) + . + [ + (expression_case "case" @structure.limit) + (default_case "default" @structure.limit) + ] +) + + (expression_switch_statement + (default_case "default" @structure.anchor) + "}" @structure.limit + ) + +(type_switch_statement + "switch" @structure.anchor + "{" @structure.open + "}" @structure.close +) + +(type_switch_statement + (type_case + "case" @structure.anchor + ":" @structure.open + ) + . + [ + (type_case "case" @structure.limit) + (default_case "default" @structure.limit) + ] +) + +(select_statement + "select" @structure.anchor + "{" @structure.open + "}" @structure.close +) + +(func_literal + "func" @structure.anchor + (block + "{" @structure.open + "}" @structure.close + ) +) + +(for_statement + "for" @structure.anchor + (block + "{" @structure.open + "}" @structure.close + ) +) + +(type_declaration + "type" @structure.anchor + (type_spec + (struct_type + (field_declaration_list + "{" @structure.open + "}" @structure.close + ) + ) + ) +) + +(struct_type + "struct" @structure.anchor + (field_declaration_list + "{" @structure.open + "}" @structure.close + ) +) + +(type_declaration + "type" @structure.anchor + (type_spec + (interface_type + "{" @structure.open + "}" @structure.close + ) + ) +) + +(interface_type + "interface" @structure.anchor + "{" @structure.open + "}" @structure.close +) diff --git a/Edit/Resources/LanguageData/Go/queries/tags.scm b/Edit/Resources/LanguageData/Go/queries/tags.scm new file mode 100644 index 0000000..d87008a --- /dev/null +++ b/Edit/Resources/LanguageData/Go/queries/tags.scm @@ -0,0 +1,30 @@ +( + (comment)* @doc + . + (function_declaration + name: (identifier) @name) @definition.function + (#strip! @doc "^//\\s*") + (#set-adjacent! @doc @definition.function) +) + +( + (comment)* @doc + . + (method_declaration + name: (field_identifier) @name) @definition.method + (#strip! @doc "^//\\s*") + (#set-adjacent! @doc @definition.method) +) + +(call_expression + function: [ + (identifier) @name + (parenthesized_expression (identifier) @name) + (selector_expression field: (field_identifier) @name) + (parenthesized_expression (selector_expression field: (field_identifier) @name)) + ]) @reference.call + +(type_spec + name: (type_identifier) @name) @definition.type + +(type_identifier) @name @reference.type diff --git a/Edit/Resources/LanguageData/GoMod/queries/highlights.scm b/Edit/Resources/LanguageData/GoMod/queries/highlights.scm new file mode 100644 index 0000000..0d3e0ca --- /dev/null +++ b/Edit/Resources/LanguageData/GoMod/queries/highlights.scm @@ -0,0 +1,18 @@ +[ + "require" + "replace" + "go" + "toolchain" + "exclude" + "retract" + "module" +] @keyword + +"=>" @operator + +(comment) @comment + +[ +(version) +(go_version) +] @string diff --git a/Edit/Resources/LanguageData/GoMod/queries/structure.scm b/Edit/Resources/LanguageData/GoMod/queries/structure.scm new file mode 100644 index 0000000..0df01ea --- /dev/null +++ b/Edit/Resources/LanguageData/GoMod/queries/structure.scm @@ -0,0 +1,29 @@ +(require_directive + "require" @structure.anchor + ("(") @structure.open + (")") @structure.close +) + +(exclude_directive + "exclude" @structure.anchor + ("(") @structure.open + (")") @structure.close +) + +(module_directive + "module" @structure.anchor + ("(") @structure.open + (")") @structure.close +) + +(replace_directive + "replace" @structure.anchor + ("(") @structure.open + (")") @structure.close +) + +(retract_directive + "retract" @structure.anchor + ("(") @structure.open + (")") @structure.close +) diff --git a/EditIntents/HighlightIntent.swift b/EditIntents/HighlightIntent.swift index 7ab740a..db407b1 100644 --- a/EditIntents/HighlightIntent.swift +++ b/EditIntents/HighlightIntent.swift @@ -13,6 +13,9 @@ extension RootLanguage: AppEnum { .clojure: "Clojure", .elixir: "Elixir", .go: "Go", + .goMod: "Go Mod", + .goSum: "Go Sum", + .goWork: "Go Work", .markdown: "Markdown", .ocaml: "OCaml", .ocamlInterface: "OCaml Interface", diff --git a/Extensions/Elixir/ElixirStandaloneExtension.swift b/Extensions/Elixir/ElixirStandaloneExtension.swift index b3c285e..71b4ffd 100644 --- a/Extensions/Elixir/ElixirStandaloneExtension.swift +++ b/Extensions/Elixir/ElixirStandaloneExtension.swift @@ -21,7 +21,7 @@ final class ElixirStandaloneExtension: ChimeExtension { } } -extension ClojureStandaloneExtension { +extension ElixirStandaloneExtension { var configuration: ExtensionConfiguration { get throws { try localExtension.configuration diff --git a/Extensions/Go/GoStandaloneExtension.swift b/Extensions/Go/GoStandaloneExtension.swift new file mode 100644 index 0000000..6d32b66 --- /dev/null +++ b/Extensions/Go/GoStandaloneExtension.swift @@ -0,0 +1,36 @@ +import Foundation +import ExtensionFoundation + +import ChimeKit +import Extendable + +@main +final class GoStandaloneExtension: ChimeExtension { + @InitializerTransferred private var localExtension: StandaloneExtension + + nonisolated init() { + self._localExtension = InitializerTransferred(mainActorProvider: { + StandaloneExtension(extensionProvider: { host in + GoExtension(host: host) + }) + }) + } + + func acceptHostConnection(_ host: HostProtocol) throws { + try localExtension.acceptHostConnection(host) + } +} + +extension GoStandaloneExtension { + var configuration: ExtensionConfiguration { + get throws { + try localExtension.configuration + } + } + + var applicationService: some ApplicationService { + get throws { + try localExtension.applicationService + } + } +} diff --git a/Extensions/UserScriptExtension/UserScriptExtension.swift b/Extensions/UserScriptExtension/UserScriptExtension.swift index 0e2a2a4..a74a71b 100644 --- a/Extensions/UserScriptExtension/UserScriptExtension.swift +++ b/Extensions/UserScriptExtension/UserScriptExtension.swift @@ -60,39 +60,3 @@ extension UserScriptExtension: ExtensionProtocol { return lspService } } - -struct Gopls { -} - -extension Gopls { - struct ServerOptions: Codable { - enum HoverKind: String, Codable { - case FullDocumentation - case NoDocumentation - case SingleLine - case Structured - case SynopsisDocumentation - } - - let usePlaceholders: Bool - let completeUnimported: Bool - let deepCompletion: Bool - let hoverKind: HoverKind - let semanticTokens: Bool - let staticcheck: Bool - let gofumpt: Bool - } - - static var serverOptions: some Codable { - let stackcheckEnabled = true - let gofumptEnabled = true - - return ServerOptions(usePlaceholders: true, - completeUnimported: true, - deepCompletion: true, - hoverKind: .Structured, - semanticTokens: true, - staticcheck: stackcheckEnabled, - gofumpt: gofumptEnabled) - } -} diff --git a/submodules/chime-go b/submodules/chime-go new file mode 160000 index 0000000..29e94a6 --- /dev/null +++ b/submodules/chime-go @@ -0,0 +1 @@ +Subproject commit 29e94a62c72a09ddc0f71da7515a9fc17a7c79df