Skip to content

Commit

Permalink
feat(theming): separate highlight for function declarations
Browse files Browse the repository at this point in the history
Add separate highlighting scope for function (and method) declarations
that allows styling the declarations differently from their calls.
  • Loading branch information
matoous committed Nov 26, 2022
1 parent 8529d75 commit 7d90a65
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
5 changes: 3 additions & 2 deletions book/src/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ We use a similar set of scopes as
- `operator` - `||`, `+=`, `>`

- `function`
- `builtin`
- `method`
- `declaration` - Declaration of a function (e.g. `fn foo() { }` in Rust)
- `builtin` - Built-in functions (e.q. `println!` in Rust)
- `method` - Methods
- `macro`
- `special` (preprocessor in C)

Expand Down
6 changes: 3 additions & 3 deletions runtime/queries/c/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@
(char_literal) @constant.character

(call_expression
function: (identifier) @function)
function: (identifier) @function.declaration)
(call_expression
function: (field_expression
field: (field_identifier) @function))
field: (field_identifier) @function.declaration))
(call_expression (argument_list (identifier) @variable))
(function_declarator
declarator: [(identifier) (field_identifier)] @function)
declarator: [(identifier) (field_identifier)] @function.declaration)
(parameter_declaration
declarator: (identifier) @variable.parameter)
(parameter_declaration
Expand Down
4 changes: 2 additions & 2 deletions runtime/queries/ecma/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
(function
name: (identifier) @function)
(function_declaration
name: (identifier) @function)
name: (identifier) @function.declaration)
(method_definition
name: (property_identifier) @function.method)
name: (property_identifier) @function.declaration)

(pair
key: (property_identifier) @function.method
Expand Down
4 changes: 2 additions & 2 deletions runtime/queries/go/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
; Function definitions

(function_declaration
name: (identifier) @function)
name: (identifier) @function.declaration)

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

; Identifiers

Expand Down
4 changes: 2 additions & 2 deletions runtime/queries/rust/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@
])

(function_item
name: (identifier) @function)
name: (identifier) @function.declaration)

(function_signature_item
name: (identifier) @function)
name: (identifier) @function.declaration)

; ---
; Macros
Expand Down
5 changes: 3 additions & 2 deletions runtime/themes/fleetish.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@
"keyword.control" = "yellow" # .conditional / .repeat / .import / .return / .exception
"operator" = "light"
"function" = "yellow"
"function.macro" = "green"
"function.declaration" = { fg = "lightest", modifiers = ["bold"] }
"function.builtin" = "green"
"function.method" = "yellow"
"function.macro" = "green"
"function.special" = "green"
"function.method" = "light"
"tag" = "green"
"special" = "green"
"namespace" = "light"
Expand Down

0 comments on commit 7d90a65

Please sign in to comment.