Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add elisp support #10644

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
| edoc | ✓ | | | |
| eex | ✓ | | | |
| ejs | ✓ | | | |
| elisp | ✓ | | | |
| elixir | ✓ | ✓ | ✓ | `elixir-ls` |
| elm | ✓ | ✓ | | `elm-language-server` |
| elvish | ✓ | | | `elvish` |
Expand Down
14 changes: 14 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3579,3 +3579,17 @@ language-servers = ["pest-language-server"]
[[grammar]]
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" }
72 changes: 72 additions & 0 deletions runtime/queries/elisp/highlights.scm
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions runtime/queries/elisp/tags.scm
Original file line number Diff line number Diff line change
@@ -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
Loading