aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorTheodor Thornhill2022-12-30 20:26:09 +0100
committerYuan Fu2022-12-31 14:21:01 -0800
commitf9aef67c36c1352c4773dc0b1f832b48e7e4e85f (patch)
tree77ed9808aaa37a3b90cddf1e398dfe25e269c9d3 /lisp
parent46362c0a3a685c3d0b2036d4db1120bad64d1269 (diff)
downloademacs-f9aef67c36c1352c4773dc0b1f832b48e7e4e85f.tar.gz
emacs-f9aef67c36c1352c4773dc0b1f832b48e7e4e85f.zip
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/progmodes/csharp-mode.el53
1 files changed, 32 insertions, 21 deletions
diff --git a/lisp/progmodes/csharp-mode.el b/lisp/progmodes/csharp-mode.el
index 66e4a65184c..bd0e023db18 100644
--- a/lisp/progmodes/csharp-mode.el
+++ b/lisp/progmodes/csharp-mode.el
@@ -693,24 +693,46 @@ compilation and evaluation time conflicts."
693(defvar csharp-ts-mode--font-lock-settings 693(defvar csharp-ts-mode--font-lock-settings
694 (treesit-font-lock-rules 694 (treesit-font-lock-rules
695 :language 'c-sharp 695 :language 'c-sharp
696 :feature 'expression
697 '((conditional_expression (identifier) @font-lock-variable-name-face)
698 (postfix_unary_expression (identifier)* @font-lock-variable-name-face)
699 (assignment_expression (identifier) @font-lock-variable-name-face))
700
701 :language 'c-sharp
702 :feature 'bracket
703 '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
704
705 :language 'c-sharp
706 :feature 'delimiter
707 '((["," ":" ";"]) @font-lock-delimiter-face)
708
709 :language 'c-sharp
710 :feature 'error
711 '((ERROR) @font-lock-warning-face)
712
713 :language 'c-sharp
696 :override t 714 :override t
697 :feature 'comment 715 :feature 'comment
698 '((comment) @font-lock-comment-face) 716 '((comment) @font-lock-comment-face)
717
699 :language 'c-sharp 718 :language 'c-sharp
700 :override t 719 :override t
701 :feature 'keyword 720 :feature 'keyword
702 `([,@csharp-ts-mode--keywords] @font-lock-keyword-face 721 `([,@csharp-ts-mode--keywords] @font-lock-keyword-face
703 (modifier) @font-lock-keyword-face 722 (modifier) @font-lock-keyword-face
704 (this_expression) @font-lock-keyword-face) 723 (this_expression) @font-lock-keyword-face)
724
705 :language 'c-sharp 725 :language 'c-sharp
706 :override t 726 :override t
707 :feature 'attribute 727 :feature 'property
708 `((attribute (identifier) @font-lock-property-face (attribute_argument_list)) 728 `((attribute (identifier) @font-lock-property-face (attribute_argument_list))
709 (attribute (identifier) @font-lock-property-face)) 729 (attribute (identifier) @font-lock-property-face))
730
710 :language 'c-sharp 731 :language 'c-sharp
711 :override t 732 :override t
712 :feature 'escape-sequence 733 :feature 'escape-sequence
713 '((escape_sequence) @font-lock-escape-face) 734 '((escape_sequence) @font-lock-escape-face)
735
714 :language 'c-sharp 736 :language 'c-sharp
715 :override t 737 :override t
716 :feature 'literal 738 :feature 'literal
@@ -718,6 +740,7 @@ compilation and evaluation time conflicts."
718 (real_literal) @font-lock-number-face 740 (real_literal) @font-lock-number-face
719 (null_literal) @font-lock-constant-face 741 (null_literal) @font-lock-constant-face
720 (boolean_literal) @font-lock-constant-face) 742 (boolean_literal) @font-lock-constant-face)
743
721 :language 'c-sharp 744 :language 'c-sharp
722 :override t 745 :override t
723 :feature 'string 746 :feature 'string
@@ -730,6 +753,7 @@ compilation and evaluation time conflicts."
730 "$\"" 753 "$\""
731 "@$\"" 754 "@$\""
732 "$@\""] @font-lock-string-face) 755 "$@\""] @font-lock-string-face)
756
733 :language 'c-sharp 757 :language 'c-sharp
734 :override t 758 :override t
735 :feature 'type 759 :feature 'type
@@ -750,14 +774,14 @@ compilation and evaluation time conflicts."
750 target: (identifier) @font-lock-type-face) 774 target: (identifier) @font-lock-type-face)
751 (type_of_expression (identifier) @font-lock-type-face) 775 (type_of_expression (identifier) @font-lock-type-face)
752 (object_creation_expression (identifier) @font-lock-type-face)) 776 (object_creation_expression (identifier) @font-lock-type-face))
777
753 :language 'c-sharp 778 :language 'c-sharp
754 :feature 'definition 779 :feature 'definition
755 :override t 780 :override t
756 '((qualified_name (identifier) @font-lock-type-face) 781 '((qualified_name (identifier) @font-lock-type-face)
757 (using_directive (identifier) @font-lock-type-face) 782 (using_directive (identifier) @font-lock-type-face)
758 (using_directive (name_equals 783 (using_directive (name_equals
759 (identifier) @font-lock-type-face 784 (identifier) @font-lock-type-face))
760 ["="] @default-face))
761 785
762 (enum_declaration (identifier) @font-lock-type-face) 786 (enum_declaration (identifier) @font-lock-type-face)
763 (enum_member_declaration (identifier) @font-lock-variable-name-face) 787 (enum_member_declaration (identifier) @font-lock-variable-name-face)
@@ -820,24 +844,11 @@ compilation and evaluation time conflicts."
820 844
821 (binary_expression (identifier) @font-lock-variable-name-face) 845 (binary_expression (identifier) @font-lock-variable-name-face)
822 (argument (identifier) @font-lock-variable-name-face)) 846 (argument (identifier) @font-lock-variable-name-face))
823 :language 'c-sharp
824 :feature 'expression
825 '((conditional_expression (identifier) @font-lock-variable-name-face)
826 (postfix_unary_expression (identifier)* @font-lock-variable-name-face)
827 (assignment_expression (identifier) @font-lock-variable-name-face))
828 :language 'c-sharp
829 :feature 'bracket
830 '((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face)
831
832 :language 'c-sharp
833 :feature 'delimiter
834 '((["," ":" ";"]) @font-lock-delimiter-face)
835 847
836 :language 'c-sharp 848 :language 'c-sharp
837 :feature 'escape-sequence 849 :feature 'escape-sequence
838 :override t 850 :override t
839 '((escape_sequence) @font-lock-escape-face 851 '((escape_sequence) @font-lock-escape-face)))
840 (ERROR) @font-lock-warning-face)))
841 852
842;;;###autoload 853;;;###autoload
843(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-mode)) 854(add-to-list 'auto-mode-alist '("\\.cs\\'" . csharp-mode))
@@ -903,9 +914,9 @@ Key bindings:
903 (setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-settings) 914 (setq-local treesit-font-lock-settings csharp-ts-mode--font-lock-settings)
904 (setq-local treesit-font-lock-feature-list 915 (setq-local treesit-font-lock-feature-list
905 '(( comment definition) 916 '(( comment definition)
906 ( keyword string escape-sequence type) 917 ( keyword string type)
907 ( attribute constant expression literal) 918 ( constant escape-sequence expression literal property)
908 ( bracket delimiter))) 919 ( bracket delimiter error)))
909 920
910 ;; Imenu. 921 ;; Imenu.
911 (setq-local treesit-simple-imenu-settings 922 (setq-local treesit-simple-imenu-settings