(ruby-ts-mode): Split font-lock feature 'builtin' into two
* lisp/progmodes/ruby-ts-mode.el (ruby-ts-mode): Split the 'builtin' feature in two: 'builtin-constant' and 'builtin-variable'. (ruby-ts-highlight-predefined-constants): Drop the user option, the highlighting granularity can be chosen using treesit-font-lock-recompute-features. (ruby-ts--font-lock-settings): Update accordingly. (ruby-ts--predefined-constants, ruby-ts--predefined-variables): Fix docstrings.
This commit is contained in:
parent
ec172d748f
commit
7ede600273
1 changed files with 13 additions and 16 deletions
|
@ -52,7 +52,8 @@
|
||||||
;; following levels:
|
;; following levels:
|
||||||
;; 1: comment method-definition
|
;; 1: comment method-definition
|
||||||
;; 2: keyword regexp string type
|
;; 2: keyword regexp string type
|
||||||
;; 3: builtin constant delimiter escape-sequence
|
;; 3: builtin-variable builtin-constant constant
|
||||||
|
;; delimiter escape-sequence
|
||||||
;; global instance
|
;; global instance
|
||||||
;; interpolation literal symbol variable
|
;; interpolation literal symbol variable
|
||||||
;; 4: bracket error function operator punctuation
|
;; 4: bracket error function operator punctuation
|
||||||
|
@ -87,11 +88,6 @@
|
||||||
:prefix "ruby-ts-"
|
:prefix "ruby-ts-"
|
||||||
:group 'languages)
|
:group 'languages)
|
||||||
|
|
||||||
(defcustom ruby-ts-highlight-predefined-constants t
|
|
||||||
"When non-nil, the pre-defined constants are highlighted.
|
|
||||||
They will be highlighted the same way as the pre-defined variables."
|
|
||||||
:type 'boolean)
|
|
||||||
|
|
||||||
(defvar ruby-ts--operators
|
(defvar ruby-ts--operators
|
||||||
'("+" "-" "*" "/" "%" "**"
|
'("+" "-" "*" "/" "%" "**"
|
||||||
"==" "!=" ">" "<" ">=" "<=" "<=>" "==="
|
"==" "!=" ">" "<" ">=" "<=" "<=>" "==="
|
||||||
|
@ -113,8 +109,7 @@ They will be highlighted the same way as the pre-defined variables."
|
||||||
"RUBY_PATCHLEVEL" "RUBY_PLATFORM" "RUBY_RELEASE_DATE"
|
"RUBY_PATCHLEVEL" "RUBY_PLATFORM" "RUBY_RELEASE_DATE"
|
||||||
"RUBY_REVISION" "RUBY_VERSION" "STDERR" "STDIN" "STDOUT"
|
"RUBY_REVISION" "RUBY_VERSION" "STDERR" "STDIN" "STDOUT"
|
||||||
"TOPLEVEL_BINDING"))
|
"TOPLEVEL_BINDING"))
|
||||||
"Ruby predefined global constants.
|
"Ruby predefined global constants.")
|
||||||
These are currently unused")
|
|
||||||
|
|
||||||
(defvar ruby-ts--predefined-variables
|
(defvar ruby-ts--predefined-variables
|
||||||
(rx (or "$!" "$@" "$~" "$&" "$‘" "$‘" "$+" "$=" "$/" "$\\" "$," "$;"
|
(rx (or "$!" "$@" "$~" "$&" "$‘" "$‘" "$+" "$=" "$/" "$\\" "$," "$;"
|
||||||
|
@ -122,7 +117,7 @@ These are currently unused")
|
||||||
"$LOADED_FEATURES" "$DEBUG" "$FILENAME" "$stderr" "$stdin"
|
"$LOADED_FEATURES" "$DEBUG" "$FILENAME" "$stderr" "$stdin"
|
||||||
"$stdout" "$VERBOSE" "$-a" "$-i" "$-l" "$-p"
|
"$stdout" "$VERBOSE" "$-a" "$-i" "$-l" "$-p"
|
||||||
(seq "$" (+ digit))))
|
(seq "$" (+ digit))))
|
||||||
"Ruby global variables (but not global constants.")
|
"Ruby predefined global variables.")
|
||||||
|
|
||||||
(defconst ruby-ts--class-or-module-regex
|
(defconst ruby-ts--class-or-module-regex
|
||||||
(rx string-start
|
(rx string-start
|
||||||
|
@ -201,10 +196,12 @@ values of OVERRIDE"
|
||||||
'((comment) @ruby-ts--comment-font-lock)
|
'((comment) @ruby-ts--comment-font-lock)
|
||||||
|
|
||||||
:language language
|
:language language
|
||||||
:feature 'builtin
|
:feature 'builtin-variable
|
||||||
`(((global_variable) @var (:match ,ruby-ts--predefined-variables @var)) @font-lock-builtin-face
|
`(((global_variable) @var (:match ,ruby-ts--predefined-variables @var)) @font-lock-builtin-face)
|
||||||
,@(when ruby-ts-highlight-predefined-constants
|
|
||||||
`(((constant) @var (:match ,ruby-ts--predefined-constants @var)) @font-lock-builtin-face)))
|
:language language
|
||||||
|
:feature 'builtin-constant
|
||||||
|
`(((constant) @var (:match ,ruby-ts--predefined-constants @var)) @font-lock-builtin-face)
|
||||||
|
|
||||||
:language language
|
:language language
|
||||||
:feature 'keyword
|
:feature 'keyword
|
||||||
|
@ -932,9 +929,9 @@ leading double colon is not added."
|
||||||
(setq-local treesit-font-lock-feature-list
|
(setq-local treesit-font-lock-feature-list
|
||||||
'(( comment method-definition )
|
'(( comment method-definition )
|
||||||
( keyword regexp string type)
|
( keyword regexp string type)
|
||||||
( builtin constant
|
( builtin-variable builtin-constant constant
|
||||||
delimiter escape-sequence global
|
delimiter escape-sequence
|
||||||
instance
|
global instance
|
||||||
interpolation literal symbol variable)
|
interpolation literal symbol variable)
|
||||||
( bracket error function operator punctuation)))
|
( bracket error function operator punctuation)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue