Tweak csharp-mode font-lock-settings (bug#60376)
* lisp/progmodes/csharp-mode.el (csharp-ts-mode--font-lock-settings): Rearrange features. (csharp-ts-mode): Rearrange features.
This commit is contained in:
parent
46362c0a3a
commit
f9aef67c36
1 changed files with 32 additions and 21 deletions
|
@ -692,25 +692,47 @@ compilation and evaluation time conflicts."
|
||||||
|
|
||||||
(defvar csharp-ts-mode--font-lock-settings
|
(defvar csharp-ts-mode--font-lock-settings
|
||||||
(treesit-font-lock-rules
|
(treesit-font-lock-rules
|
||||||
|
:language 'c-sharp
|
||||||
|
:feature 'expression
|
||||||
|
'((conditional_expression (identifier) @font-lock-variable-name-face)
|
||||||
|
(postfix_unary_expression (identifier)* @font-lock-variable-name-face)
|
||||||
|
(assignment_expression (identifier) @font-lock-variable-name-face))
|
||||||
|
|
||||||
|
:language 'c-sharp
|
||||||
|
:feature 'bracket
|
||||||
|
'((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
|
||||||
|
|
||||||
|
:language 'c-sharp
|
||||||
|
:feature 'delimiter
|
||||||
|
'((["," ":" ";"]) @font-lock-delimiter-face)
|
||||||
|
|
||||||
|
:language 'c-sharp
|
||||||
|
:feature 'error
|
||||||
|
'((ERROR) @font-lock-warning-face)
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:override t
|
:override t
|
||||||
:feature 'comment
|
:feature 'comment
|
||||||
'((comment) @font-lock-comment-face)
|
'((comment) @font-lock-comment-face)
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:override t
|
:override t
|
||||||
:feature 'keyword
|
:feature 'keyword
|
||||||
`([,@csharp-ts-mode--keywords] @font-lock-keyword-face
|
`([,@csharp-ts-mode--keywords] @font-lock-keyword-face
|
||||||
(modifier) @font-lock-keyword-face
|
(modifier) @font-lock-keyword-face
|
||||||
(this_expression) @font-lock-keyword-face)
|
(this_expression) @font-lock-keyword-face)
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:override t
|
:override t
|
||||||
:feature 'attribute
|
:feature 'property
|
||||||
`((attribute (identifier) @font-lock-property-face (attribute_argument_list))
|
`((attribute (identifier) @font-lock-property-face (attribute_argument_list))
|
||||||
(attribute (identifier) @font-lock-property-face))
|
(attribute (identifier) @font-lock-property-face))
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:override t
|
:override t
|
||||||
:feature 'escape-sequence
|
:feature 'escape-sequence
|
||||||
'((escape_sequence) @font-lock-escape-face)
|
'((escape_sequence) @font-lock-escape-face)
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:override t
|
:override t
|
||||||
:feature 'literal
|
:feature 'literal
|
||||||
|
@ -718,6 +740,7 @@ compilation and evaluation time conflicts."
|
||||||
(real_literal) @font-lock-number-face
|
(real_literal) @font-lock-number-face
|
||||||
(null_literal) @font-lock-constant-face
|
(null_literal) @font-lock-constant-face
|
||||||
(boolean_literal) @font-lock-constant-face)
|
(boolean_literal) @font-lock-constant-face)
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:override t
|
:override t
|
||||||
:feature 'string
|
:feature 'string
|
||||||
|
@ -730,6 +753,7 @@ compilation and evaluation time conflicts."
|
||||||
"$\""
|
"$\""
|
||||||
"@$\""
|
"@$\""
|
||||||
"$@\""] @font-lock-string-face)
|
"$@\""] @font-lock-string-face)
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:override t
|
:override t
|
||||||
:feature 'type
|
:feature 'type
|
||||||
|
@ -750,14 +774,14 @@ compilation and evaluation time conflicts."
|
||||||
target: (identifier) @font-lock-type-face)
|
target: (identifier) @font-lock-type-face)
|
||||||
(type_of_expression (identifier) @font-lock-type-face)
|
(type_of_expression (identifier) @font-lock-type-face)
|
||||||
(object_creation_expression (identifier) @font-lock-type-face))
|
(object_creation_expression (identifier) @font-lock-type-face))
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:feature 'definition
|
:feature 'definition
|
||||||
:override t
|
:override t
|
||||||
'((qualified_name (identifier) @font-lock-type-face)
|
'((qualified_name (identifier) @font-lock-type-face)
|
||||||
(using_directive (identifier) @font-lock-type-face)
|
(using_directive (identifier) @font-lock-type-face)
|
||||||
(using_directive (name_equals
|
(using_directive (name_equals
|
||||||
(identifier) @font-lock-type-face
|
(identifier) @font-lock-type-face))
|
||||||
["="] @default-face))
|
|
||||||
|
|
||||||
(enum_declaration (identifier) @font-lock-type-face)
|
(enum_declaration (identifier) @font-lock-type-face)
|
||||||
(enum_member_declaration (identifier) @font-lock-variable-name-face)
|
(enum_member_declaration (identifier) @font-lock-variable-name-face)
|
||||||
|
@ -820,24 +844,11 @@ compilation and evaluation time conflicts."
|
||||||
|
|
||||||
(binary_expression (identifier) @font-lock-variable-name-face)
|
(binary_expression (identifier) @font-lock-variable-name-face)
|
||||||
(argument (identifier) @font-lock-variable-name-face))
|
(argument (identifier) @font-lock-variable-name-face))
|
||||||
:language 'c-sharp
|
|
||||||
:feature 'expression
|
|
||||||
'((conditional_expression (identifier) @font-lock-variable-name-face)
|
|
||||||
(postfix_unary_expression (identifier)* @font-lock-variable-name-face)
|
|
||||||
(assignment_expression (identifier) @font-lock-variable-name-face))
|
|
||||||
:language 'c-sharp
|
|
||||||
:feature 'bracket
|
|
||||||
'((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
|
|
||||||
|
|
||||||
:language 'c-sharp
|
|
||||||
:feature 'delimiter
|
|
||||||
'((["," ":" ";"]) @font-lock-delimiter-face)
|
|
||||||
|
|
||||||
:language 'c-sharp
|
:language 'c-sharp
|
||||||
:feature 'escape-sequence
|
:feature 'escape-sequence
|
||||||
:override t
|
:override t
|
||||||
'((escape_sequence) @font-lock-escape-face
|
'((escape_sequence) @font-lock-escape-face)))
|
||||||
(ERROR) @font-lock-warning-face)))
|
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-mode))
|
(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-mode))
|
||||||
|
@ -903,9 +914,9 @@ Key bindings:
|
||||||
(setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-settings)
|
(setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-settings)
|
||||||
(setq-local treesit-font-lock-feature-list
|
(setq-local treesit-font-lock-feature-list
|
||||||
'(( comment definition)
|
'(( comment definition)
|
||||||
( keyword string escape-sequence type)
|
( keyword string type)
|
||||||
( attribute constant expression literal)
|
( constant escape-sequence expression literal property)
|
||||||
( bracket delimiter)))
|
( bracket delimiter error)))
|
||||||
|
|
||||||
;; Imenu.
|
;; Imenu.
|
||||||
(setq-local treesit-simple-imenu-settings
|
(setq-local treesit-simple-imenu-settings
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue