From 0c125fcc67a47b933716124223404a45e73357c7 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sun, 5 Feb 2023 15:46:28 +0200 Subject: Make highlighting more regular across TS modes (bug#61205) * doc/emacs/display.texi (Parser-based Font Lock): Update description of treesit-font-lock-level, moving 'property' to level 4. * lisp/treesit.el (treesit-font-lock-level): Likewise, in docstring. * lisp/progmodes/c-ts-mode.el (c-ts-base-mode): Do that here. * lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode): Add a comment. * lisp/progmodes/go-ts-mode.el (go-ts-mode): Add 'definition' to level 1. Move 'function', 'property' and 'variable' to level 4. (go-ts-mode--font-lock-settings): Move a bunch of existing rules to 'definition'. Add highlighting of function parameters. * lisp/progmodes/rust-ts-mode.el (rust-ts-mode) (rust-ts-mode--font-lock-settings): Same. And also change "scoped identifiers" highlights to only match capitalized names. --- lisp/progmodes/go-ts-mode.el | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'lisp/progmodes/go-ts-mode.el') diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el index 95dcf653fc6..4b14e55281e 100644 --- a/lisp/progmodes/go-ts-mode.el +++ b/lisp/progmodes/go-ts-mode.el @@ -123,17 +123,26 @@ :feature 'delimiter '((["," "." ";" ":"]) @font-lock-delimiter-face) + :language 'go + :feature 'definition + '((function_declaration + name: (identifier) @font-lock-function-name-face) + (method_declaration + name: (field_identifier) @font-lock-function-name-face) + (method_spec + name: (field_identifier) @font-lock-function-name-face) + (field_declaration + name: (field_identifier) @font-lock-property-face) + (parameter_declaration + name: (identifier) @font-lock-variable-name-face)) + :language 'go :feature 'function '((call_expression function: (identifier) @font-lock-function-name-face) (call_expression function: (selector_expression - field: (field_identifier) @font-lock-function-name-face)) - (function_declaration - name: (identifier) @font-lock-function-name-face) - (method_declaration - name: (field_identifier) @font-lock-function-name-face)) + field: (field_identifier) @font-lock-function-name-face))) :language 'go :feature 'keyword @@ -221,11 +230,10 @@ ;; Font-lock. (setq-local treesit-font-lock-settings go-ts-mode--font-lock-settings) (setq-local treesit-font-lock-feature-list - '(( comment) + '(( comment definition) ( keyword string type) - ( constant escape-sequence function label number - property variable) - ( bracket delimiter error operator))) + ( constant escape-sequence label number) + ( bracket delimiter error function operator property variable))) (treesit-major-mode-setup))) -- cgit v1.2.3