languages: add highlighting for go.mod (#7137)

Release Notes:

- Added syntax highlighting for go.mod files. Fixes #7133 

<img width="863" alt="image"
src="https://github.com/zed-industries/zed/assets/8725798/dc521a02-c53a-44aa-b0c1-eebf31835679">
This commit is contained in:
Derrick Laird 2024-01-31 00:46:13 -07:00 committed by GitHub
parent e5fe811d7a
commit ba91adf48a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 67 additions and 0 deletions

10
Cargo.lock generated
View File

@ -8790,6 +8790,15 @@ dependencies = [
"tree-sitter", "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]] [[package]]
name = "tree-sitter-haskell" name = "tree-sitter-haskell"
version = "0.14.0" version = "0.14.0"
@ -10316,6 +10325,7 @@ dependencies = [
"tree-sitter-gleam", "tree-sitter-gleam",
"tree-sitter-glsl", "tree-sitter-glsl",
"tree-sitter-go", "tree-sitter-go",
"tree-sitter-gomod",
"tree-sitter-haskell", "tree-sitter-haskell",
"tree-sitter-heex", "tree-sitter-heex",
"tree-sitter-html", "tree-sitter-html",

View File

@ -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-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-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-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-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-heex = { git = "https://github.com/phoenixframework/tree-sitter-heex", rev = "2e1348c3cf2c9323e87c2744796cf3f3868aa82a" }
tree-sitter-html = "0.19.0" tree-sitter-html = "0.19.0"

View File

@ -115,6 +115,7 @@ tree-sitter-embedded-template.workspace = true
tree-sitter-gleam.workspace = true tree-sitter-gleam.workspace = true
tree-sitter-glsl.workspace = true tree-sitter-glsl.workspace = true
tree-sitter-go.workspace = true tree-sitter-go.workspace = true
tree-sitter-gomod.workspace = true
tree-sitter-haskell.workspace = true tree-sitter-haskell.workspace = true
tree-sitter-heex.workspace = true tree-sitter-heex.workspace = true
tree-sitter-html.workspace = true tree-sitter-html.workspace = true

View File

@ -122,6 +122,7 @@ pub fn init(
tree_sitter_go::language(), tree_sitter_go::language(),
vec![Arc::new(go::GoLspAdapter)], vec![Arc::new(go::GoLspAdapter)],
); );
language("gomod", tree_sitter_gomod::language(), vec![]);
language( language(
"zig", "zig",
tree_sitter_zig::language(), tree_sitter_zig::language(),

View File

@ -0,0 +1,7 @@
name = "Go Mod"
path_suffixes = ["mod"]
line_comments = ["//"]
autoclose_before = ")"
brackets = [
{ start = "(", end = ")", close = true, newline = true}
]

View File

@ -0,0 +1,18 @@
[
"require"
"replace"
"go"
"toolchain"
"exclude"
"retract"
"module"
] @keyword
"=>" @operator
(comment) @comment
[
(version)
(go_version)
] @string

View File

@ -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
)