aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlvaro Muñoz <pwntester@github.com>2020-09-30 00:30:26 +0200
committerStephan Seitz <stephan.lauf@yahoo.de>2020-09-30 17:06:58 +0200
commit3dc2e9331e18635f518db853fb076852c9bed16a (patch)
treea26e8b6188b08b096ca88794974db3bccde27ec1
parentchore: dedup join_paths <-> join_path (diff)
downloadnvim-treesitter-3dc2e9331e18635f518db853fb076852c9bed16a.tar
nvim-treesitter-3dc2e9331e18635f518db853fb076852c9bed16a.tar.gz
nvim-treesitter-3dc2e9331e18635f518db853fb076852c9bed16a.tar.bz2
nvim-treesitter-3dc2e9331e18635f518db853fb076852c9bed16a.tar.lz
nvim-treesitter-3dc2e9331e18635f518db853fb076852c9bed16a.tar.xz
nvim-treesitter-3dc2e9331e18635f518db853fb076852c9bed16a.tar.zst
nvim-treesitter-3dc2e9331e18635f518db853fb076852c9bed16a.zip
initial support for CodeQL
-rw-r--r--lua/nvim-treesitter/parsers.lua8
-rw-r--r--queries/ql/highlights.scm103
-rw-r--r--queries/ql/locals.scm26
3 files changed, 137 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 24a7ca0a6..6b74faaa8 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -261,6 +261,14 @@ list.fennel = {
maintainers = {'@TravonteD'},
}
+list.ql = {
+ install_info = {
+ url = "https://github.com/tree-sitter/tree-sitter-ql",
+ files = { "src/parser.c" },
+ },
+ maintainers = {'@pwntester'},
+}
+
-- Parsers for injections
list.regex = {
install_info = {
diff --git a/queries/ql/highlights.scm b/queries/ql/highlights.scm
new file mode 100644
index 000000000..67810de6a
--- /dev/null
+++ b/queries/ql/highlights.scm
@@ -0,0 +1,103 @@
+[
+ "and"
+ "any"
+ "as"
+ "asc"
+ "avg"
+ "by"
+ "class"
+ "concat"
+ "count"
+ "desc"
+ "else"
+ "exists"
+ "extends"
+ "forall"
+ "forex"
+ "from"
+ "if"
+ "implies"
+ "import"
+ "in"
+ "instanceof"
+ "max"
+ "min"
+ "module"
+ "newtype"
+ "not"
+ "or"
+ "order"
+ "rank"
+ "select"
+ "strictconcat"
+ "strictcount"
+ "strictsum"
+ "sum"
+ "then"
+ "where"
+
+ (false)
+ (predicate)
+ (result)
+ (specialId)
+ (super)
+ (this)
+ (true)
+] @keyword
+
+[
+ "boolean"
+ "float"
+ "int"
+ "date"
+ "string"
+] @type.builtin
+
+(annotName) @attribute
+
+[
+ "<"
+ "<="
+ "="
+ ">"
+ ">="
+ "-"
+ "!="
+ "/"
+ "*"
+ "%"
+ "+"
+ "::"
+] @operator
+
+[
+ "("
+ ")"
+ "{"
+ "}"
+ "["
+ "]"
+] @punctuation.bracket
+
+[
+ ","
+ "|"
+] @punctuation.delimiter
+
+(className) @type
+
+(varName) @variable
+
+(integer) @number
+(float) @number
+
+(string) @string
+
+(aritylessPredicateExpr (literalId) @function)
+(predicateName) @function
+
+[
+ (line_comment)
+ (block_comment)
+ (qldoc)
+] @comment
diff --git a/queries/ql/locals.scm b/queries/ql/locals.scm
new file mode 100644
index 000000000..fa488be1d
--- /dev/null
+++ b/queries/ql/locals.scm
@@ -0,0 +1,26 @@
+(classlessPredicate
+ name: (predicateName) @name) @definition.function
+
+(memberPredicate
+ name: (predicateName) @name) @definition.method
+
+(aritylessPredicateExpr
+ name: (literalId) @name) @reference.call
+
+(module
+ name: (moduleName) @name) @definition.module
+
+(dataclass
+ name: (className) @name) @definition.class
+
+(datatype
+ name: (className) @name) @definition.class
+
+(datatypeBranch
+ name: (className) @name) @definition.class
+
+(qualifiedRhs
+ name: (predicateName) @name) @reference.call
+
+(typeExpr
+ name: (className) @name) @reference.type