aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/erlang
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/erlang
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/erlang')
-rw-r--r--runtime/queries/erlang/folds.scm9
-rw-r--r--runtime/queries/erlang/highlights.scm184
-rw-r--r--runtime/queries/erlang/injections.scm2
3 files changed, 195 insertions, 0 deletions
diff --git a/runtime/queries/erlang/folds.scm b/runtime/queries/erlang/folds.scm
new file mode 100644
index 000000000..65c2d8ed1
--- /dev/null
+++ b/runtime/queries/erlang/folds.scm
@@ -0,0 +1,9 @@
+[
+ (fun_decl)
+ (anonymous_fun)
+ (case_expr)
+ (maybe_expr)
+ (map_expr)
+ (export_attribute)
+ (export_type_attribute)
+] @fold
diff --git a/runtime/queries/erlang/highlights.scm b/runtime/queries/erlang/highlights.scm
new file mode 100644
index 000000000..8bba348d9
--- /dev/null
+++ b/runtime/queries/erlang/highlights.scm
@@ -0,0 +1,184 @@
+((atom) @constant
+ (#set! priority "90"))
+
+(var) @variable
+
+(char) @character
+
+(integer) @number
+
+(float) @number.float
+
+(comment) @comment @spell
+
+((comment) @comment.documentation
+ (#lua-match? @comment.documentation "^[%%][%%]"))
+
+; keyword
+[
+ "fun"
+ "div"
+] @keyword
+
+; bracket
+[
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+ "#"
+] @punctuation.bracket
+
+; Comparisons
+[
+ "=="
+ "=:="
+ "=/="
+ "=<"
+ ">="
+ "<"
+ ">"
+] @operator ; .comparison
+
+; operator
+[
+ ":"
+ ":="
+ "!"
+ ; "-"
+ "+"
+ "="
+ "->"
+ "=>"
+ "|"
+ "?="
+] @operator
+
+[
+ ","
+ "."
+ ";"
+] @punctuation.delimiter
+
+; conditional
+[
+ "receive"
+ "if"
+ "case"
+ "of"
+ "when"
+ "after"
+ "begin"
+ "end"
+ "maybe"
+ "else"
+] @keyword.conditional
+
+[
+ "catch"
+ "try"
+] @keyword.exception
+
+((atom) @boolean
+ (#any-of? @boolean "true" "false"))
+
+; Macros
+((macro_call_expr) @constant.macro
+ (#set! priority 101))
+
+; Preprocessor
+(pp_define
+ lhs: _ @constant.macro
+ (#set! priority 101))
+
+(_preprocessor_directive) @keyword.directive
+(#set! priority 99)
+
+; Attributes
+(pp_include) @keyword.import
+
+(pp_include_lib) @keyword.import
+
+(export_attribute) @keyword.import
+
+(export_type_attribute) @type.definition
+
+(export_type_attribute
+ types: (fa
+ fun: _ @type
+ (#set! priority 101)))
+
+(behaviour_attribute) @keyword.import
+
+(module_attribute
+ (atom) @module) @keyword.import
+
+(wild_attribute
+ name: (attr_name
+ name: _ @attribute)) @attribute
+
+; Records
+(record_expr) @type
+
+(record_field_expr
+ _ @variable.member) @type
+
+(record_field_name
+ _ @variable.member) @type
+
+(record_name
+ "#" @type
+ name: _ @type) @type
+
+(record_decl
+ name: _ @type) @type.definition
+
+(record_field
+ name: _ @variable.member)
+
+(record_field
+ name: _ @variable.member
+ ty: _ @type)
+
+; Type alias
+(type_alias
+ name: _ @type) @type.definition
+
+(spec) @type.definition
+
+[
+ (string)
+ (binary)
+] @string
+
+; expr_function_call
+(call
+ expr: [
+ (atom)
+ (remote)
+ (var)
+ ] @function)
+
+(call
+ (atom) @keyword.exception
+ (#any-of? @keyword.exception "error" "throw" "exit"))
+
+; Parenthesized expression: (SomeFunc)(), only highlight the parens
+(call
+ expr: (paren_expr
+ "(" @function.call
+ ")" @function.call))
+
+; function
+(external_fun) @function.call
+
+(internal_fun
+ fun: (atom) @function.call)
+
+(function_clause
+ name: (atom) @function)
+
+(fa
+ fun: (atom) @function)
diff --git a/runtime/queries/erlang/injections.scm b/runtime/queries/erlang/injections.scm
new file mode 100644
index 000000000..2f0e58eb6
--- /dev/null
+++ b/runtime/queries/erlang/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))