Skip to content

Commit 8d79015

Browse files
committed
feat(theming): separate highlight for function declarations
Add separate highlighting scope for function (and method) declarations that allows styling the declarations differently from their calls.
1 parent 0b96021 commit 8d79015

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

book/src/themes.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,9 @@ We use a similar set of scopes as
193193
- `operator` - `||`, `+=`, `>`
194194

195195
- `function`
196-
- `builtin`
197-
- `method`
196+
- `declaration` - Declaration of a function (e.g. `fn foo() { }` in Rust)
197+
- `builtin` - Built-in functions (e.q. `println!` in Rust)
198+
- `method` - Methods
198199
- `macro`
199200
- `special` (preprocessor in C)
200201

runtime/queries/c/highlights.scm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@
109109
(char_literal) @constant.character
110110

111111
(call_expression
112-
function: (identifier) @function)
112+
function: (identifier) @function.declaration)
113113
(call_expression
114114
function: (field_expression
115-
field: (field_identifier) @function))
115+
field: (field_identifier) @function.declaration))
116116
(call_expression (argument_list (identifier) @variable))
117117
(function_declarator
118-
declarator: [(identifier) (field_identifier)] @function)
118+
declarator: [(identifier) (field_identifier)] @function.declaration)
119119
(parameter_declaration
120120
declarator: (identifier) @variable.parameter)
121121
(parameter_declaration

runtime/queries/ecma/highlights.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
(function
2727
name: (identifier) @function)
2828
(function_declaration
29-
name: (identifier) @function)
29+
name: (identifier) @function.declaration)
3030
(method_definition
31-
name: (property_identifier) @function.method)
31+
name: (property_identifier) @function.declaration)
3232

3333
(pair
3434
key: (property_identifier) @function.method

runtime/queries/go/highlights.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
; Function definitions
1515

1616
(function_declaration
17-
name: (identifier) @function)
17+
name: (identifier) @function.declaration)
1818

1919
(method_declaration
20-
name: (field_identifier) @function.method)
20+
name: (field_identifier) @function.declaration)
2121

2222
; Identifiers
2323

runtime/queries/rust/highlights.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,10 @@
263263
])
264264

265265
(function_item
266-
name: (identifier) @function)
266+
name: (identifier) @function.declaration)
267267

268268
(function_signature_item
269-
name: (identifier) @function)
269+
name: (identifier) @function.declaration)
270270

271271
; ---
272272
; Macros

runtime/themes/fleet_dark.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"keyword.control.exception" = "purple"
3333
"operator" = "light"
3434
"function" = "yellow"
35-
"function.macro" = "green"
35+
"function.declaration" = { fg = "lightest", modifiers = ["bold"] }
3636
"function.builtin" = "green"
3737
"function.special" = "green"
3838
"function.method" = "light"

0 commit comments

Comments
 (0)