diff --git a/Cargo.lock b/Cargo.lock index 87e56d599e..00917fb3dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8790,6 +8790,15 @@ dependencies = [ "tree-sitter", ] +[[package]] +name = "tree-sitter-gomod" +version = "1.0.2" +source = "git+https://github.com/camdencheek/tree-sitter-go-mod#bbe2fe3be4b87e06a613e685250f473d2267f430" +dependencies = [ + "cc", + "tree-sitter", +] + [[package]] name = "tree-sitter-haskell" version = "0.14.0" @@ -10316,6 +10325,7 @@ dependencies = [ "tree-sitter-gleam", "tree-sitter-glsl", "tree-sitter-go", + "tree-sitter-gomod", "tree-sitter-haskell", "tree-sitter-heex", "tree-sitter-html", diff --git a/Cargo.toml b/Cargo.toml index b224033101..b423969259 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -142,6 +142,7 @@ tree-sitter-embedded-template = "0.20.0" tree-sitter-gleam = { git = "https://github.com/gleam-lang/tree-sitter-gleam", rev = "58b7cac8fc14c92b0677c542610d8738c373fa81" } tree-sitter-glsl = { git = "https://github.com/theHamsta/tree-sitter-glsl", rev = "2a56fb7bc8bb03a1892b4741279dd0a8758b7fb3" } tree-sitter-go = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "aeb2f33b366fd78d5789ff104956ce23508b85db" } +tree-sitter-gomod = { git = "https://github.com/camdencheek/tree-sitter-go-mod" } tree-sitter-haskell = { git = "https://github.com/tree-sitter/tree-sitter-haskell", rev = "cf98de23e4285b8e6bcb57b050ef2326e2cc284b" } tree-sitter-heex = { git = "https://github.com/phoenixframework/tree-sitter-heex", rev = "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" } tree-sitter-html = "0.19.0" diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index c930c2eeb1..c57c27b854 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -115,6 +115,7 @@ tree-sitter-embedded-template.workspace = true tree-sitter-gleam.workspace = true tree-sitter-glsl.workspace = true tree-sitter-go.workspace = true +tree-sitter-gomod.workspace = true tree-sitter-haskell.workspace = true tree-sitter-heex.workspace = true tree-sitter-html.workspace = true diff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rs index 5ed9e43ec5..2055518df3 100644 --- a/crates/zed/src/languages.rs +++ b/crates/zed/src/languages.rs @@ -122,6 +122,7 @@ pub fn init( tree_sitter_go::language(), vec![Arc::new(go::GoLspAdapter)], ); + language("gomod", tree_sitter_gomod::language(), vec![]); language( "zig", tree_sitter_zig::language(), diff --git a/crates/zed/src/languages/gomod/config.toml b/crates/zed/src/languages/gomod/config.toml new file mode 100644 index 0000000000..80c252949d --- /dev/null +++ b/crates/zed/src/languages/gomod/config.toml @@ -0,0 +1,7 @@ +name = "Go Mod" +path_suffixes = ["mod"] +line_comments = ["//"] +autoclose_before = ")" +brackets = [ + { start = "(", end = ")", close = true, newline = true} +] diff --git a/crates/zed/src/languages/gomod/highlights.scm b/crates/zed/src/languages/gomod/highlights.scm new file mode 100644 index 0000000000..0d3e0ca551 --- /dev/null +++ b/crates/zed/src/languages/gomod/highlights.scm @@ -0,0 +1,18 @@ +[ + "require" + "replace" + "go" + "toolchain" + "exclude" + "retract" + "module" +] @keyword + +"=>" @operator + +(comment) @comment + +[ +(version) +(go_version) +] @string diff --git a/crates/zed/src/languages/gomod/structure.scm b/crates/zed/src/languages/gomod/structure.scm new file mode 100644 index 0000000000..0df01ea255 --- /dev/null +++ b/crates/zed/src/languages/gomod/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 +)