add elisp support (#10644)

* add elisp support

* update queries for some constants
This commit is contained in:
Zoey Hewll 2024-06-07 12:02:27 +08:00 committed by GitHub
parent 80e0e98e45
commit 44504b720b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 92 additions and 0 deletions

View file

@ -42,6 +42,7 @@
| edoc | ✓ | | | |
| eex | ✓ | | | |
| ejs | ✓ | | | |
| elisp | ✓ | | | |
| elixir | ✓ | ✓ | ✓ | `elixir-ls` |
| elm | ✓ | ✓ | | `elm-language-server` |
| elvish | ✓ | | | `elvish` |

View file

@ -3641,6 +3641,20 @@ language-servers = ["pest-language-server"]
name = "pest"
source = { git = "https://github.com/pest-parser/tree-sitter-pest", rev = "a8a98a824452b1ec4da7f508386a187a2f234b85" }
[[language]]
name = "elisp"
scope = "source.elisp"
file-types = ["el"]
comment-tokens = [";"]
[language.auto-pairs]
'(' = ')'
'"' = '"'
[[grammar]]
name = "elisp"
source = { git = "https://github.com/Wilfred/tree-sitter-elisp", rev = "e5524fdccf8c22fc726474a910e4ade976dfc7bb" }
[[language]]
name = "gjs"
scope = "source.gjs"

View file

@ -0,0 +1,72 @@
;; Special forms
[
"and"
"catch"
"cond"
"condition-case"
"defconst"
"defvar"
"function"
"if"
"interactive"
"lambda"
"let"
"let*"
"or"
"prog1"
"prog2"
"progn"
"quote"
"save-current-buffer"
"save-excursion"
"save-restriction"
"setq"
"setq-default"
"unwind-protect"
"while"
] @keyword
;; Function definitions
[
"defun"
"defsubst"
] @keyword
(function_definition name: (symbol) @function)
(function_definition parameters: (list (symbol) @variable.parameter))
(function_definition docstring: (string) @comment)
;; Highlight macro definitions the same way as function definitions.
"defmacro" @keyword
(macro_definition name: (symbol) @function)
(macro_definition parameters: (list (symbol) @variable.parameter))
(macro_definition docstring: (string) @comment)
(comment) @comment
(integer) @constant.numeric.integer
(float) @constant.numeric.float
(char) @constant.character
(string) @string
[
"("
")"
"#["
"["
"]"
] @punctuation.bracket
[
"`"
"#'"
"'"
","
",@"
] @operator
;; Highlight nil and t as constants, unlike other symbols
[
"nil"
"t"
] @constant.builtin

View file

@ -0,0 +1,5 @@
;; defun/defsubst
(function_definition name: (symbol) @name) @definition.function
;; Treat macros as function definitions for the sake of TAGS.
(macro_definition name: (symbol) @name) @definition.function