Skip to content

Commit 5f613ff

Browse files
committed
built-in functions highlight
1 parent 24b4578 commit 5f613ff

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Running `M-x treesit-install-language-grammar [RET] php` will compile and instal
5353
In `php-ts-mode`, syntax elements are classified as follows.
5454

5555
* **Level 1**: `comment` `definition` `preprocessor`
56-
* **Level 2**: `keyword` `string` `type`
56+
* **Level 2**: `keyword` `string` `type` `built-in`
5757
* **Level 3**: `function` `constant` `label`
5858
* **Level 4**: `bracket` `delimiter` `operator` `variables` `this`
5959

php-ts-mode.el

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
"while" "yield")
106106
"PHP keywords for tree-sitter font-locking.")
107107

108+
(defvar php-ts-mode--built-in-functions
109+
'("die" "echo" "empty" "isset")
110+
"PHP built-in functions for tree-sitter font-locking.")
111+
108112
(defvar php-ts-mode--operators
109113
'("!=" "!==" "%" "%=" "&" "&&" "&=" "*" "**" "*="
110114
"+" "++" "+=" "," "-" "-" "--" "-=" "->" "."
@@ -259,6 +263,16 @@ see https://www.php.net/manual/language.constants.predefined.php")
259263
(goto_statement "goto" @php-keyword)
260264
(yield_expression "from" @php-keyword))
261265

266+
:language 'php
267+
:feature 'built-in
268+
:override t
269+
`((function_call_expression
270+
function: (name) @php-keyword
271+
(:match ,(rx-to-string
272+
`(seq bol
273+
(or ,@php-ts-mode--built-in-functions)
274+
eol)) @php-keyword)))
275+
262276
:language 'php
263277
:feature 'label
264278
`((goto_statement (name) @php-keyword)
@@ -359,7 +373,7 @@ Currently there are `php-mode' and `php-ts-mode'."
359373
(setq-local treesit-font-lock-settings php-ts-mode--font-lock-settings)
360374
(setq-local treesit-font-lock-feature-list
361375
'((comment definition preprocessor)
362-
(keyword string type)
376+
(keyword string type built-in)
363377
(function constant label)
364378
(bracket delimiter operator variables this)))
365379

0 commit comments

Comments
 (0)