Unnamed repository; edit this file 'description' to name the repository.
Add support for the SlightLisp language (#14236)
Xavier R. Guérin 5 months ago
parent 66737c6 · commit 2dddace
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml13
-rw-r--r--runtime/queries/slisp/highlights.scm74
-rw-r--r--runtime/queries/slisp/tags.scm8
4 files changed, 95 insertions, 1 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index aefc729d..63bc55f6 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -232,6 +232,7 @@
| shellcheckrc | ✓ | ✓ | | | | |
| slang | ✓ | ✓ | ✓ | | | `slangd` |
| slint | ✓ | ✓ | ✓ | | | `slint-lsp` |
+| slisp | ✓ | | | ✓ | | |
| smali | ✓ | | ✓ | | | |
| smithy | ✓ | | | | | `cs` |
| sml | ✓ | | | | | |
diff --git a/languages.toml b/languages.toml
index 158f876e..d8027ab1 100644
--- a/languages.toml
+++ b/languages.toml
@@ -4751,7 +4751,6 @@ file-types = [{glob = "Cross.toml"}]
language-servers = [ "taplo", "tombi" ]
indent = { tab-width = 2, unit = " " }
-# https://git-cliff.org/docs/configuration/
[[language]]
name = "git-cliff-config"
scope = "source.git-cliff-config"
@@ -4832,3 +4831,15 @@ language-servers = ["wikitext-lsp"]
indent = { tab-width = 2, unit = " " }
block-comment-tokens = { start = "<!--", end = "-->" }
word-completion.trigger-length = 4
+
+[[language]]
+name = "slisp"
+scope = "source.sl"
+injection-regex = "sl"
+file-types = ["sl"]
+comment-token = ";"
+indent = { tab-width = 2, unit = " " }
+
+[[grammar]]
+name = "slisp"
+source = { git = "https://github.com/xenogenics/tree-sitter-slisp", rev = "29f9c6707ce9dfc2fc915d175ec720b207f179f3" }
diff --git a/runtime/queries/slisp/highlights.scm b/runtime/queries/slisp/highlights.scm
new file mode 100644
index 00000000..a7bf91d8
--- /dev/null
+++ b/runtime/queries/slisp/highlights.scm
@@ -0,0 +1,74 @@
+;; Keywords
+[ "if" "prog" ] @keyword
+
+;; Let binding
+[ "let" ] @keyword
+
+(let_bindings name: (symbol) @variable)
+
+;; Apply
+(apply_stmt . (symbol) @function)
+
+;; Use module
+[ "use" ] @keyword
+
+(use_module_global (quote) . (symbol) @namespace)
+(use_module_select (quote) . (symbol) @namespace)
+
+;; Val definition
+[ "val" ] @keyword
+
+(val_definition name: (symbol) @constant)
+
+;; External definitions
+[ "ext" ] @keyword
+
+(external_definition name: (symbol) @function)
+(external_definition signature: (signature (symbol) @variable.parameter (dot) (external_type) @type.builtin))
+(external_definition docstring: (string) @comment)
+(external_definition return_type: (external_type) @type.builtin)
+
+;; Function definitions
+[ "def" ] @keyword
+
+(function_definition name: (symbol) @function)
+(function_definition parameters: (parameters (symbol) @variable.parameter))
+(function_definition docstring: (string) @comment)
+
+;; Macro definitions
+[ "mac" ] @keyword
+
+(macro_definition name: (symbol) @function)
+(macro_definition parameters: (parameters (symbol) @variable.parameter))
+(macro_definition docstring: (string) @comment)
+
+;; Lambda
+[ "\\" ] @keyword
+
+(lambda_stmt parameters: (parameters (symbol) @variable.parameter))
+
+;; Atoms
+(char) @constant.character
+(comment) @comment
+(number) @constant.numeric
+(string) @string
+
+;; Punctuation
+[ "(" ")" ] @punctuation.bracket
+
+;; Operators
+(dot) @operator
+(tilde) @operator
+(backquote) @operator
+(quote) @operator
+(unquote) @operator
+(unquote_splice) @operator
+
+;; Highlight nil t as constant
+[ "nil" ] @constant.builtin
+
+;; Highlight as t as boolean constant
+[ "T" ] @constant.builtin.boolean
+
+;; Highlight variable names used in anamorphic macros.
+[ "it" ] @variable.builtin
diff --git a/runtime/queries/slisp/tags.scm b/runtime/queries/slisp/tags.scm
new file mode 100644
index 00000000..df62606b
--- /dev/null
+++ b/runtime/queries/slisp/tags.scm
@@ -0,0 +1,8 @@
+;; def
+(function_definition name: (symbol) @name) @definition.function
+
+;; ext
+(external_definition name: (symbol) @name) @definition.function
+
+;; mac
+(macro_definition name: (symbol) @name) @definition.function