Skip to content

Commit

Permalink
Improve Go syntax highlighting (#25327)
Browse files Browse the repository at this point in the history
Release Notes:

  - Improved Go syntax highlighting.

| Zed 0.174.6 | With this PR |
| --- | --- |
|
![Image](https://github.com/user-attachments/assets/7f6113cb-0517-4ea7-a979-902a2373314e)
|
![Image](https://github.com/user-attachments/assets/0cf07ebc-c5bd-4269-af7a-49496305d265)
|

- `package_identifier`: `namespace`, language-agnostic scope for
modules, packages, namespaces
- `method_elem`: `function.method`
- `;` ,`.` ,`,` ,`:`: `punctuation.delimiter`

```go
package my_package
import (
  pkg "fmt"
)
type A interface {
  method_elem(foo int, bar float64) int
}
func main() {
  identifier := true
  const constant int = 3
  for i := 0; i <= 3; i++ {
    pkg.Println(identifier)
  }
}
```

---------

Co-authored-by: Marshall Bowers <[email protected]>
  • Loading branch information
chbk and maxdeviant authored Feb 21, 2025
1 parent a97a2eb commit 7deceb6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/languages/src/go/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

(type_identifier) @type
(field_identifier) @variable.member
(package_identifier) @namespace

(keyed_element
.
Expand All @@ -20,6 +21,15 @@

(method_declaration
name: (field_identifier) @function.method)
(method_elem
name: (field_identifier) @function.method)

[
";"
"."
","
":"
] @punctuation.delimiter

[
"("
Expand Down

0 comments on commit 7deceb6

Please sign in to comment.