diff options
| author | Michael Härtl <haertl.mike@gmail.com> | 2022-01-17 12:20:47 +0100 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2022-01-20 15:37:44 +0100 |
| commit | d7c4ae886d90471b1839dd601887bdd6e882efd9 (patch) | |
| tree | 37bf8b384531d0c0651dd70ebf0ba7f9ae4a0dc6 | |
| parent | d0158c053d01de1bcb618d7899bd8e38ce154430 (diff) | |
parsers: add phpdoc parser (experimental)
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 11 | ||||
| -rw-r--r-- | queries/php/injections.scm | 2 | ||||
| -rw-r--r-- | queries/phpdoc/highlights.scm | 42 |
3 files changed, 54 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index 8e28d743..3fc43f88 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -245,6 +245,17 @@ list.php = { maintainers = { "@tk-shirasaka" }, } +list.phpdoc = { + install_info = { + url = "https://github.com/claytonrcarter/tree-sitter-phpdoc", + files = { "src/parser.c" }, + -- parser.c in the repo still based on TS 0.17 due to other dependencies + requires_generate_from_grammar = true, + generate_requires_npm = true, + }, + experimental = true, +} + list.java = { install_info = { url = "https://github.com/tree-sitter/tree-sitter-java", diff --git a/queries/php/injections.scm b/queries/php/injections.scm index 8683d6ce..c90e2f93 100644 --- a/queries/php/injections.scm +++ b/queries/php/injections.scm @@ -1,3 +1,3 @@ (text) @html -(comment) @comment +(comment) @phpdoc diff --git a/queries/phpdoc/highlights.scm b/queries/phpdoc/highlights.scm new file mode 100644 index 00000000..047ee3aa --- /dev/null +++ b/queries/phpdoc/highlights.scm @@ -0,0 +1,42 @@ +(tag_name) @attribute +(tag + (tag_name) @_tag (#eq? @_tag "@param") + (variable_name) @parameter +) +(tag + (tag_name) @_tag (#eq? @_tag "@property") + (variable_name) @property +) +(tag + (tag_name) @_tag (#eq? @_tag "@var") + (variable_name) @variable +) +(tag + (tag_name) @_tag (#eq? @_tag "@method") + (name) @method +) +(parameter + (variable_name) @parameter) +(type_list + [ + (array_type) + (primitive_type) + (named_type) + ] @type) +(tag + (description (text) @text)) +(tag + [ + (author_name) + (version) + ] @text) +(tag + (email_address) @text.uri +) + +[ + "$" + ">" + "<" + "|" +]@keyword |
