mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 13:24:19 +00:00
Merge pull request #2250 from zed-industries/syntax-highlighting-tweaks
Syntax highlighting tweaks
This commit is contained in:
commit
7163ba429b
6 changed files with 33 additions and 72 deletions
|
@ -43,8 +43,10 @@
|
||||||
|
|
||||||
; Special identifiers
|
; Special identifiers
|
||||||
|
|
||||||
((identifier) @constructor
|
((identifier) @type
|
||||||
(#match? @constructor "^[A-Z]"))
|
(#match? @type "^[A-Z]"))
|
||||||
|
(type_identifier) @type
|
||||||
|
(predefined_type) @type.builtin
|
||||||
|
|
||||||
([
|
([
|
||||||
(identifier)
|
(identifier)
|
||||||
|
@ -192,14 +194,6 @@
|
||||||
"${" @punctuation.special
|
"${" @punctuation.special
|
||||||
"}" @punctuation.special) @embedded
|
"}" @punctuation.special) @embedded
|
||||||
|
|
||||||
; Types
|
|
||||||
|
|
||||||
(type_identifier) @type
|
|
||||||
(predefined_type) @type.builtin
|
|
||||||
|
|
||||||
((identifier) @type
|
|
||||||
(#match? @type "^[A-Z]"))
|
|
||||||
|
|
||||||
(type_arguments
|
(type_arguments
|
||||||
"<" @punctuation.bracket
|
"<" @punctuation.bracket
|
||||||
">" @punctuation.bracket)
|
">" @punctuation.bracket)
|
||||||
|
|
|
@ -137,7 +137,7 @@
|
||||||
;; Constants
|
;; Constants
|
||||||
|
|
||||||
((identifier) @constant
|
((identifier) @constant
|
||||||
(#lua-match? @constant "^[A-Z][A-Z_0-9]*$"))
|
(#match? @constant "^[A-Z][A-Z_0-9]*$"))
|
||||||
|
|
||||||
(vararg_expression) @constant
|
(vararg_expression) @constant
|
||||||
|
|
||||||
|
@ -164,11 +164,17 @@
|
||||||
|
|
||||||
(parameters (identifier) @parameter)
|
(parameters (identifier) @parameter)
|
||||||
|
|
||||||
(function_call name: (identifier) @function.call)
|
(function_call
|
||||||
(function_declaration name: (identifier) @function)
|
name: [
|
||||||
|
(identifier) @function
|
||||||
|
(dot_index_expression field: (identifier) @function)
|
||||||
|
])
|
||||||
|
|
||||||
(function_call name: (dot_index_expression field: (identifier) @function.call))
|
(function_declaration
|
||||||
(function_declaration name: (dot_index_expression field: (identifier) @function))
|
name: [
|
||||||
|
(identifier) @function.definition
|
||||||
|
(dot_index_expression field: (identifier) @function.definition)
|
||||||
|
])
|
||||||
|
|
||||||
(method_index_expression method: (identifier) @method)
|
(method_index_expression method: (identifier) @method)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
(quote . (symbol)) @constant
|
(quote . (symbol)) @constant
|
||||||
|
|
||||||
(extension) @keyword
|
(extension) @keyword
|
||||||
(lang_name) @variable.builtin
|
(lang_name) @variable.special
|
||||||
|
|
||||||
((symbol) @operator
|
((symbol) @operator
|
||||||
(#match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$"))
|
(#match? @operator "^(\\+|-|\\*|/|=|>|<|>=|<=)$"))
|
||||||
|
|
|
@ -46,6 +46,11 @@
|
||||||
((identifier) @constructor
|
((identifier) @constructor
|
||||||
(#match? @constructor "^[A-Z]"))
|
(#match? @constructor "^[A-Z]"))
|
||||||
|
|
||||||
|
((identifier) @type
|
||||||
|
(#match? @type "^[A-Z]"))
|
||||||
|
(type_identifier) @type
|
||||||
|
(predefined_type) @type.builtin
|
||||||
|
|
||||||
([
|
([
|
||||||
(identifier)
|
(identifier)
|
||||||
(shorthand_property_identifier)
|
(shorthand_property_identifier)
|
||||||
|
@ -193,14 +198,6 @@
|
||||||
"${" @punctuation.special
|
"${" @punctuation.special
|
||||||
"}" @punctuation.special) @embedded
|
"}" @punctuation.special) @embedded
|
||||||
|
|
||||||
; Types
|
|
||||||
|
|
||||||
(type_identifier) @type
|
|
||||||
(predefined_type) @type.builtin
|
|
||||||
|
|
||||||
((identifier) @type
|
|
||||||
(#match? @type "^[A-Z]"))
|
|
||||||
|
|
||||||
(type_arguments
|
(type_arguments
|
||||||
"<" @punctuation.bracket
|
"<" @punctuation.bracket
|
||||||
">" @punctuation.bracket)
|
">" @punctuation.bracket)
|
||||||
|
|
|
@ -47,11 +47,11 @@ export interface Syntax {
|
||||||
"string.special": SyntaxHighlightStyle
|
"string.special": SyntaxHighlightStyle
|
||||||
// elixir: atom, quoted_atom, keyword, quoted_keyword
|
// elixir: atom, quoted_atom, keyword, quoted_keyword
|
||||||
// ruby: simple_symbol, delimited_symbol...
|
// ruby: simple_symbol, delimited_symbol...
|
||||||
"string.special.symbol": SyntaxHighlightStyle
|
"string.special.symbol"?: SyntaxHighlightStyle
|
||||||
// elixir, python, yaml...: escape_sequence
|
// elixir, python, yaml...: escape_sequence
|
||||||
"string.escape": SyntaxHighlightStyle
|
"string.escape"?: SyntaxHighlightStyle
|
||||||
// Regular expressions
|
// Regular expressions
|
||||||
"string.regex": SyntaxHighlightStyle
|
"string.regex"?: SyntaxHighlightStyle
|
||||||
|
|
||||||
// == Types ====== /
|
// == Types ====== /
|
||||||
// We allow Function here because all JS objects literals have this property
|
// We allow Function here because all JS objects literals have this property
|
||||||
|
@ -59,16 +59,14 @@ export interface Syntax {
|
||||||
variant: SyntaxHighlightStyle
|
variant: SyntaxHighlightStyle
|
||||||
type: SyntaxHighlightStyle
|
type: SyntaxHighlightStyle
|
||||||
// js: predefined_type
|
// js: predefined_type
|
||||||
"type.builtin": SyntaxHighlightStyle
|
"type.builtin"?: SyntaxHighlightStyle
|
||||||
|
|
||||||
// == Values
|
// == Values
|
||||||
variable: SyntaxHighlightStyle
|
variable: SyntaxHighlightStyle
|
||||||
// racket: lang_name
|
|
||||||
"variable.builtin": SyntaxHighlightStyle
|
|
||||||
// this, ...
|
// this, ...
|
||||||
// css: -- (var(--foo))
|
// css: -- (var(--foo))
|
||||||
// lua: self
|
// lua: self
|
||||||
"variable.special": SyntaxHighlightStyle
|
"variable.special"?: SyntaxHighlightStyle
|
||||||
// c: statement_identifier,
|
// c: statement_identifier,
|
||||||
label: SyntaxHighlightStyle
|
label: SyntaxHighlightStyle
|
||||||
// css: tag_name, nesting_selector, universal_selector...
|
// css: tag_name, nesting_selector, universal_selector...
|
||||||
|
@ -90,24 +88,22 @@ export interface Syntax {
|
||||||
boolean: SyntaxHighlightStyle
|
boolean: SyntaxHighlightStyle
|
||||||
// elixir: __MODULE__, __DIR__, __ENV__, etc
|
// elixir: __MODULE__, __DIR__, __ENV__, etc
|
||||||
// go: nil, iota
|
// go: nil, iota
|
||||||
"constant.builtin": SyntaxHighlightStyle
|
"constant.builtin"?: SyntaxHighlightStyle
|
||||||
|
|
||||||
// == Functions ====== /
|
// == Functions ====== /
|
||||||
|
|
||||||
function: SyntaxHighlightStyle
|
function: SyntaxHighlightStyle
|
||||||
// lua: assert, error, loadfile, tostring, unpack...
|
// lua: assert, error, loadfile, tostring, unpack...
|
||||||
"function.builtin": SyntaxHighlightStyle
|
"function.builtin"?: SyntaxHighlightStyle
|
||||||
// lua: function_call
|
|
||||||
"function.call": SyntaxHighlightStyle
|
|
||||||
// go: call_expression, method_declaration
|
// go: call_expression, method_declaration
|
||||||
// js: call_expression, method_definition, pair (key, arrow function)
|
// js: call_expression, method_definition, pair (key, arrow function)
|
||||||
// rust: function_item name: (identifier)
|
// rust: function_item name: (identifier)
|
||||||
"function.definition": SyntaxHighlightStyle
|
"function.definition"?: SyntaxHighlightStyle
|
||||||
// rust: macro_definition name: (identifier)
|
// rust: macro_definition name: (identifier)
|
||||||
"function.special.definition": SyntaxHighlightStyle
|
"function.special.definition"?: SyntaxHighlightStyle
|
||||||
"function.method": SyntaxHighlightStyle
|
"function.method"?: SyntaxHighlightStyle
|
||||||
// ruby: identifier/"defined?" // Nate note: I don't fully understand this one.
|
// ruby: identifier/"defined?" // Nate note: I don't fully understand this one.
|
||||||
"function.method.builtin": SyntaxHighlightStyle
|
"function.method.builtin"?: SyntaxHighlightStyle
|
||||||
|
|
||||||
// == Unsorted ====== /
|
// == Unsorted ====== /
|
||||||
// lua: hash_bang_line
|
// lua: hash_bang_line
|
||||||
|
@ -117,9 +113,6 @@ export interface Syntax {
|
||||||
embedded: SyntaxHighlightStyle
|
embedded: SyntaxHighlightStyle
|
||||||
}
|
}
|
||||||
|
|
||||||
// HACK: "constructor" as a key in the syntax interface returns an error when a theme tries to use it.
|
|
||||||
// For now hack around it by omiting constructor as a valid key for overrides.
|
|
||||||
// export type ThemeSyntax = Partial<Omit<Syntax, "constructor">>
|
|
||||||
export type ThemeSyntax = Partial<Syntax>
|
export type ThemeSyntax = Partial<Syntax>
|
||||||
|
|
||||||
const defaultSyntaxHighlightStyle: Omit<SyntaxHighlightStyle, "color"> = {
|
const defaultSyntaxHighlightStyle: Omit<SyntaxHighlightStyle, "color"> = {
|
||||||
|
@ -238,18 +231,9 @@ function buildDefaultSyntax(colorScheme: ColorScheme): Syntax {
|
||||||
type: {
|
type: {
|
||||||
color: color.type,
|
color: color.type,
|
||||||
},
|
},
|
||||||
"type.builtin": {
|
|
||||||
color: color.type,
|
|
||||||
},
|
|
||||||
variable: {
|
variable: {
|
||||||
color: color.primary,
|
color: color.primary,
|
||||||
},
|
},
|
||||||
"variable.builtin": {
|
|
||||||
color: colorScheme.ramps.blue(0.5).hex(),
|
|
||||||
},
|
|
||||||
"variable.special": {
|
|
||||||
color: colorScheme.ramps.blue(0.7).hex(),
|
|
||||||
},
|
|
||||||
label: {
|
label: {
|
||||||
color: colorScheme.ramps.blue(0.5).hex(),
|
color: colorScheme.ramps.blue(0.5).hex(),
|
||||||
},
|
},
|
||||||
|
@ -280,30 +264,9 @@ function buildDefaultSyntax(colorScheme: ColorScheme): Syntax {
|
||||||
boolean: {
|
boolean: {
|
||||||
color: color.boolean,
|
color: color.boolean,
|
||||||
},
|
},
|
||||||
"constant.builtin": {
|
|
||||||
color: color.constant,
|
|
||||||
},
|
|
||||||
function: {
|
function: {
|
||||||
color: color.function,
|
color: color.function,
|
||||||
},
|
},
|
||||||
"function.builtin": {
|
|
||||||
color: color.function,
|
|
||||||
},
|
|
||||||
"function.call": {
|
|
||||||
color: color.function,
|
|
||||||
},
|
|
||||||
"function.definition": {
|
|
||||||
color: color.function,
|
|
||||||
},
|
|
||||||
"function.special.definition": {
|
|
||||||
color: color.function,
|
|
||||||
},
|
|
||||||
"function.method": {
|
|
||||||
color: color.function,
|
|
||||||
},
|
|
||||||
"function.method.builtin": {
|
|
||||||
color: color.function,
|
|
||||||
},
|
|
||||||
preproc: {
|
preproc: {
|
||||||
color: color.primary,
|
color: color.primary,
|
||||||
},
|
},
|
||||||
|
|
|
@ -51,6 +51,7 @@ const syntax: ThemeSyntax = {
|
||||||
linkText: { color: color.blue, italic: false },
|
linkText: { color: color.blue, italic: false },
|
||||||
linkUri: { color: color.teal },
|
linkUri: { color: color.teal },
|
||||||
number: { color: color.orange },
|
number: { color: color.orange },
|
||||||
|
constant: { color: color.yellow },
|
||||||
operator: { color: color.teal },
|
operator: { color: color.teal },
|
||||||
primary: { color: color.white },
|
primary: { color: color.white },
|
||||||
property: { color: color.red },
|
property: { color: color.red },
|
||||||
|
|
Loading…
Reference in a new issue