Jeff Brennan
621ac16e35
go: Fix language injections (#43775)
Closes #43730
## Summary
This modifies the existing injections.scm file for go by adding more
specific prefix queries and *_content nodes to the existing
`raw_string_literal` and `interpreted_string_literal` sections
<details><summary>This PR</summary>
<img width="567" height="784" alt="image"
src="https://github.com/user-attachments/assets/bfe8c64e-1dc2-470c-9f85-2c664a6c5a15"
/>
<img width="383" height="909" alt="image"
src="https://github.com/user-attachments/assets/9349af8c-22d3-4c9b-a435-a73719f17ba3"
/>
<img width="572" height="800" alt="image"
src="https://github.com/user-attachments/assets/939ada3b-1440-443b-8492-0eb61a7ee90f"
/>
</details>
<details><summary>Current Release (0.214.7)</summary>
<img width="569" height="777" alt="image"
src="https://github.com/user-attachments/assets/e6fffe77-e4c6-48e3-9c6d-a140298225c5"
/>
<img width="381" height="896" alt="image"
src="https://github.com/user-attachments/assets/bf107950-c33a-4603-90d3-2304bef0a4af"
/>
<img width="574" height="798" alt="image"
src="https://github.com/user-attachments/assets/2c5e43e5-f101-4722-8f58-6b176ba950ca"
/>
</details>
<details><summary>Code</summary>
```go
func test_sql() {
// const assignment
const _ = /* sql */ "SELECT * FROM users"
const _ = /* sql */ `SELECT id, name FROM products`
// var assignment
var _ = /* sql */ `SELECT id, name FROM products`
var _ = /* sql */ "SELECT id, name FROM products"
// := assignment
test := /* sql */ "SELECT * FROM users"
test2 := /* sql */ `SELECT * FROM users`
println(test)
println(test2)
// = assignment
_ = /* sql */ "SELECT * FROM users WHERE id = 1"
_ = /* sql */ `SELECT * FROM users WHERE id = 1`
// literal elements
_ = testStruct{Field: /* sql */ "SELECT * FROM users"}
_ = testStruct{Field: /* sql */ `SELECT * FROM users`}
testFunc(/* sql */ "SELECT * FROM users")
testFunc(/* sql */ `SELECT * FROM users`)
const backtickString = /* sql */ `SELECT * FROM users;`
const quotedString = /* sql */ "SELECT * FROM users;"
const backtickStringNoHighlight = `SELECT * FROM users;`
const quotedStringNoHighlight = "SELECT * FROM users;"
}
func test_yaml() {
// const assignment
const _ = /* yaml */ `
settings:
enabled: true
port: 8080
`
// := assignment
test := /* yaml */ `
settings:
enabled: true
port: 8080
`
println(test)
// = assignment
_ = /* yaml */ `
settings:
enabled: true
port: 8080
`
// literal elements in a struct
_ = testStruct{Field: /* yaml */ `
settings:
test: 1234
port: 8080
`}
// function argument
testFunc(/* yaml */ `
settings:
enabled: true
port: 8080
`)
}
func test_css() {
// const assignment
const _ = /* css */ "body { margin: 0; }"
const _ = /* css */ `body { margin: 0; }`
const cssCodes = /* css */ `
h1 {
color: #333;
}
`
// := assignment
test := /* css */ "body { margin: 0; }"
println(test)
// = assignment
_ = /* css */ "body { margin: 0; }"
_ = /* css */ `body { margin: 0; }`
// literal elements
_ = testStruct{Field: /* css */ "body { margin: 0; }"}
_ = testStruct{Field: /* css */ `body { margin: 0; }`}
testFunc(/* css */ "body { margin: 0; }")
testFunc(/* css */ `body { margin: 0; }`)
const backtickString = /* css */ `body { margin: 0; }`
const quotedString = /* css */ "body { margin: 0; }"
const backtickStringNoHighlight = `body { margin: 0; }`
const quotedStringNoHighlight = "body { margin: 0; }"
}
```
</details>
Release Notes:
- Greatly improved the quality of comment-directed language injections
in Go
2025-12-03 10:32:51 -06:00
..
2025-11-20 19:47:39 +00:00
2025-09-06 01:36:36 +02:00
2025-10-08 12:04:06 -06:00
2025-12-03 10:32:51 -06:00
2025-08-12 21:08:19 +00:00
2025-10-08 22:55:26 +02:00