aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Reinartz <filmor@gmail.com>2022-12-08 19:40:41 +0100
committerGitHub <noreply@github.com>2022-12-08 19:40:41 +0100
commit84261c67fce6322c241ec74a44c5dff6598166c5 (patch)
treef166cdf66afa9e692988ff015958f165fe27447f
parentUpdate lockfile.json (diff)
downloadnvim-treesitter-84261c67fce6322c241ec74a44c5dff6598166c5.tar
nvim-treesitter-84261c67fce6322c241ec74a44c5dff6598166c5.tar.gz
nvim-treesitter-84261c67fce6322c241ec74a44c5dff6598166c5.tar.bz2
nvim-treesitter-84261c67fce6322c241ec74a44c5dff6598166c5.tar.lz
nvim-treesitter-84261c67fce6322c241ec74a44c5dff6598166c5.tar.xz
nvim-treesitter-84261c67fce6322c241ec74a44c5dff6598166c5.tar.zst
nvim-treesitter-84261c67fce6322c241ec74a44c5dff6598166c5.zip
feat(erlang)!: switch parser to maintained fork (#3791)
update queries to breaking changes
-rw-r--r--lockfile.json2
-rw-r--r--lua/nvim-treesitter/parsers.lua4
-rw-r--r--queries/erlang/folds.scm11
-rw-r--r--queries/erlang/highlights.scm156
4 files changed, 97 insertions, 76 deletions
diff --git a/lockfile.json b/lockfile.json
index d415e4b0a..500977a17 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -90,7 +90,7 @@
"revision": "91fc5ae1140d5c9d922312431f7d251a48d7b8ce"
},
"erlang": {
- "revision": "3a9c769444f08bbccce03845270efac0c641c5e7"
+ "revision": "a8b8b0e16c4f5552f5e85af3dec976a5d16af8b9"
},
"fennel": {
"revision": "517195970428aacca60891b050aa53eabf4ba78d"
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 73841850a..0246cde81 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -412,11 +412,11 @@ list.scss = {
list.erlang = {
install_info = {
- url = "https://github.com/AbstractMachinesLab/tree-sitter-erlang",
+ url = "https://github.com/WhatsApp/tree-sitter-erlang",
files = { "src/parser.c" },
branch = "main",
},
- maintainers = { "@ostera" },
+ maintainers = { "@filmor" },
}
list.elixir = {
diff --git a/queries/erlang/folds.scm b/queries/erlang/folds.scm
index 39c65c5b2..35073e869 100644
--- a/queries/erlang/folds.scm
+++ b/queries/erlang/folds.scm
@@ -1,7 +1,8 @@
[
- (function_declaration)
- (lambda_clause)
- (expr_case)
- (map)
- (module_export)
+ (fun_decl)
+ (anonymous_fun)
+ (case_expr)
+ (map_expr)
+ (export_attribute)
+ (export_type_attribute)
] @fold
diff --git a/queries/erlang/highlights.scm b/queries/erlang/highlights.scm
index c51019fd5..fba44359f 100644
--- a/queries/erlang/highlights.scm
+++ b/queries/erlang/highlights.scm
@@ -1,8 +1,18 @@
-;; keywoord
+((atom) @constant (#set! "priority" "90"))
+(var) @variable
+
+(char) @character
+(integer) @number
+(float) @float
+
+(comment) @comment
+
+;; keyword
[
"fun"
"div"
] @keyword
+
;; bracket
[
"("
@@ -11,10 +21,41 @@
"}"
"["
"]"
- "#"
+ "#"
] @punctuation.bracket
-;; conditional
+
+;;; Comparisons
+[
+ "=="
+ "=:="
+ "=/="
+ "=<"
+ ">="
+ "<"
+ ">"
+] @operator ;; .comparison
+
+;;; operator
+[
+ ":"
+ ":="
+ "!"
+ ;; "-"
+ "+"
+ "="
+ "->"
+ "=>"
+ "|"
+] @operator
+
[
+ ","
+ "."
+ ";"
+] @punctuation.delimiter
+
+;; conditional
+([
"receive"
"if"
"case"
@@ -22,83 +63,62 @@
"when"
"after"
"end"
-] @conditional
+] @conditional (#set! "priority" 95))
[
"catch"
- "try"
- "throw"
+ "try"
] @exception
-;;; module define
-[
- "module"
- "export"
-] @include
-;;; operator
-[
- ":"
- ":="
- "?"
- "!"
- "-"
- "+"
- "="
- "->"
- "=>"
- "|"
- ;;;TODO
- "$"
- ] @operator
-(comment) @comment
-(string) @string
-(variable) @variable
+((atom) @boolean (#any-of? @boolean "true" "false"))
-(module_name
- (atom) @namespace
-)
-;;; expr_function_call
-(expr_function_call
- name: (computed_function_name) @function.call
-)
+;; Macros
+((macro_call_expr) @constant.macro (#set! "priority" 101))
-(expr_function_call
- arguments: (atom) @variable
+;; Preprocessor
+(pp_define
+ lhs: _ @constant.macro (#set! "priority" 101)
)
+(_preprocessor_directive) @preproc (#set! "priority" 99)
-;;; map
-(map
- (map_entry [
- (atom)
- (variable)
- ] @variable)
-)
+;; Attributes
+(pp_include) @include
+(pp_include_lib) @include
+(export_attribute) @include
+(export_type_attribute) @type.definition
+(export_type_attribute types: (fa fun: _ @type (#set! "priority" 101)))
+(behaviour_attribute) @include
+(module_attribute (atom) @namespace) @include
+(wild_attribute name: (attr_name name: _ @attribute)) @attribute
+;; Records
+(record_expr) @type
+(record_field_expr _ @field) @type
+(record_field_name _ @field) @type
+(record_name "#" @type name: _ @type) @type
+(record_decl name: _ @type) @type.definition
+(record_field name: _ @field)
+(record_field name: _ @field ty: _ @type)
-(tuple (atom) @variable)
-(pat_tuple ( pattern (atom) @variable))
+;; Type alias
+(type_alias name: _ @type) @type.definition
+(spec) @type.definition
-(computed_function_name) @function
-;;; case
-(case_clause
- pattern: (pattern
- (atom) @variable
- )
-)
-(case_clause
- body: (atom) @variable
+(comment) @comment
+[(string) (binary)] @string
+
+;;; expr_function_call
+(call expr: [(atom) (remote) (var)] @function)
+(call (atom) @exception (#any-of? @exception "error" "throw" "exit"))
+
+;;; Parenthesized expression: (SomeFunc)(), only highlight the parens
+(call
+ expr: (paren_expr "(" @function.call ")" @function.call)
)
;;; function
-(qualified_function_name
- module_name: (atom) @attribute
- function_name: (atom) @function
-)
-;; function
-(function_clause
- name: (atom) @function)
-;;;lambda
-(lambda_clause
- arguments:
- (pattern) @variable
-)
+(external_fun) @function.call
+(internal_fun fun: (atom) @function.call)
+(function_clause name: (atom) @function)
+(fa fun: (atom) @function)
+