aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShirasaka <tk.shirasaka@gmail.com>2020-07-31 23:59:57 +0900
committerThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-08-04 08:05:51 +0200
commitf372e2ab87fc9c6d13cd16b69d7ef08479e7b963 (patch)
tree0f356239a0e4d6a2b1b3dffd663b5ace269e96d1
parentLua locals: Make property_identifier a reference (diff)
downloadnvim-treesitter-f372e2ab87fc9c6d13cd16b69d7ef08479e7b963.tar
nvim-treesitter-f372e2ab87fc9c6d13cd16b69d7ef08479e7b963.tar.gz
nvim-treesitter-f372e2ab87fc9c6d13cd16b69d7ef08479e7b963.tar.bz2
nvim-treesitter-f372e2ab87fc9c6d13cd16b69d7ef08479e7b963.tar.lz
nvim-treesitter-f372e2ab87fc9c6d13cd16b69d7ef08479e7b963.tar.xz
nvim-treesitter-f372e2ab87fc9c6d13cd16b69d7ef08479e7b963.tar.zst
nvim-treesitter-f372e2ab87fc9c6d13cd16b69d7ef08479e7b963.zip
Add PHP, TOML, and update HTML, javascript queries
- PHP : Add highlights and locals query - TOML : Add highlights and locals query - HTML : Add scope - javascript : Add some scopes
-rw-r--r--README.md4
-rw-r--r--queries/html/locals.scm1
-rw-r--r--queries/javascript/locals.scm3
-rw-r--r--queries/php/highlights.scm191
-rw-r--r--queries/php/locals.scm22
-rw-r--r--queries/toml/highlights.scm12
-rw-r--r--queries/toml/locals.scm2
7 files changed, 233 insertions, 2 deletions
diff --git a/README.md b/README.md
index efbd054bb..32394dae9 100644
--- a/README.md
+++ b/README.md
@@ -263,7 +263,7 @@ List of currently supported languages:
- [ ] markdown
- [ ] nix
- [ ] ocaml
-- [ ] php
+- [x] php (maintained by @tk-shirasaka)
- [x] python (maintained by @theHamsta)
- [x] regex (maintained by @theHamsta)
- [x] rst (maintained by @stsewd)
@@ -271,7 +271,7 @@ List of currently supported languages:
- [x] rust (partial support, maintained by @vigoux)
- [ ] scala
- [ ] swift
-- [ ] toml
+- [x] toml (maintained by @tk-shirasaka)
- [x] tree-sitter query language (maintained by @steelsojka)
- [ ] tsx
- [x] typescript (maintained by @steelsojka)
diff --git a/queries/html/locals.scm b/queries/html/locals.scm
new file mode 100644
index 000000000..04d296a23
--- /dev/null
+++ b/queries/html/locals.scm
@@ -0,0 +1 @@
+(element) @scope
diff --git a/queries/javascript/locals.scm b/queries/javascript/locals.scm
index 1daefea40..f9ca96570 100644
--- a/queries/javascript/locals.scm
+++ b/queries/javascript/locals.scm
@@ -6,6 +6,9 @@
(arrow_function) @scope
(function_declaration) @scope
(method_definition) @scope
+(for_statement) @scope
+(for_in_statement) @scope
+(catch_clause) @scope
; Definitions
;------------
diff --git a/queries/php/highlights.scm b/queries/php/highlights.scm
new file mode 100644
index 000000000..c01b017a3
--- /dev/null
+++ b/queries/php/highlights.scm
@@ -0,0 +1,191 @@
+; Types
+
+[
+ (primitive_type)
+ (cast_type)
+ ] @type.builtin
+(type_name (name) @type)
+
+; Functions
+
+(array_creation_expression "array" @function.builtin)
+(list_literal "list" @function.builtin)
+
+(method_declaration
+ name: (name) @method)
+
+(function_call_expression
+ function: (qualified_name (name)) @function)
+
+(scoped_call_expression
+ name: (name) @function)
+
+(member_call_expression
+ name: (name) @method)
+
+(function_definition
+ name: (name) @function)
+
+; Member
+
+(property_element
+ (variable_name) @property)
+
+(member_access_expression
+ name: (variable_name (name)) @property)
+(member_access_expression
+ name: (name) @property)
+
+; Variables
+
+(relative_scope) @variable.builtin
+
+((name) @constant
+ (#match? @constant "^_?[A-Z][A-Z\d_]+$"))
+
+((name) @constructor
+ (#match? @constructor "^[A-Z]"))
+
+((name) @variable.builtin
+ (#eq? @variable.builtin "this"))
+
+(variable_name) @variable
+
+; Basic tokens
+
+[
+ (string)
+ (heredoc)
+ ] @string
+
+(boolean) @boolean
+(null) @constant.builtin
+(integer) @number
+(float) @float
+(comment) @comment
+
+; Keywords
+
+[
+ "$"
+ "abstract"
+ "as"
+ "break"
+ "class"
+ "const"
+ "continue"
+ "declare"
+ "default"
+ "echo"
+ "enddeclare"
+ "extends"
+ "final"
+ "function"
+ "global"
+ "implements"
+ "insteadof"
+ "interface"
+ "namespace"
+ "new"
+ "private"
+ "protected"
+ "public"
+ "return"
+ "static"
+ "trait"
+ ] @keyword
+
+[
+ "case"
+ "else"
+ "elseif"
+ "endif"
+ "endswitch"
+ "if"
+ "switch"
+ ] @conditional
+
+[
+ "do"
+ "endfor"
+ "endforeach"
+ "endwhile"
+ "for"
+ "foreach"
+ "while"
+ ] @repeat
+
+[
+ "catch"
+ "finally"
+ "throw"
+ "try"
+ ] @exception
+
+[
+ "include_once"
+ "include"
+ "require_once"
+ "require"
+ "use"
+ ] @include
+
+[
+ ","
+ ";"
+ "."
+ ] @punctuation.delimiter
+
+[
+ (php_tag)
+ "?>"
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+ ] @punctuation.bracket
+
+[
+ "="
+
+ "-"
+ "*"
+ "/"
+ "+"
+ "%"
+
+ "~"
+ "|"
+ "&"
+ "<<"
+ ">>"
+
+ "->"
+
+ "<"
+ "<="
+ ">="
+ ">"
+ "=="
+ "!="
+ "==="
+ "!=="
+
+ "!"
+ "&&"
+ "||"
+
+ "-="
+ "+="
+ "*="
+ "/="
+ "%="
+ "|="
+ "&="
+ "--"
+ "++"
+] @operator
+
+(ERROR) @error
diff --git a/queries/php/locals.scm b/queries/php/locals.scm
new file mode 100644
index 000000000..06c0af734
--- /dev/null
+++ b/queries/php/locals.scm
@@ -0,0 +1,22 @@
+; Scopes
+;-------
+
+(class_declaration) @scope
+(property_declaration) @scope
+(method_declaration) @scope
+(function_definition) @scope
+(while_statement) @scope
+(foreach_statement) @scope
+(if_statement) @scope
+(try_statement) @scope
+
+; Definitions
+;------------
+
+(variable_name
+ (name) @definition.var)
+
+; References
+;------------
+
+(variable_name) @reference
diff --git a/queries/toml/highlights.scm b/queries/toml/highlights.scm
new file mode 100644
index 000000000..10b937052
--- /dev/null
+++ b/queries/toml/highlights.scm
@@ -0,0 +1,12 @@
+(bare_key) @type.builtin
+
+(pair
+ (bare_key) @property)
+
+(string) @string
+(boolean) @constant.builtin
+(integer) @number
+(float) @float
+(comment) @comment
+
+(ERROR) @error
diff --git a/queries/toml/locals.scm b/queries/toml/locals.scm
new file mode 100644
index 000000000..cd79101cf
--- /dev/null
+++ b/queries/toml/locals.scm
@@ -0,0 +1,2 @@
+(table) @scope
+(table_array_element) @scope