Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPdoc #18

Open
piotrkwiecinski opened this issue May 26, 2023 · 2 comments
Open

PHPdoc #18

piotrkwiecinski opened this issue May 26, 2023 · 2 comments

Comments

@piotrkwiecinski
Copy link
Contributor

To support phpdoc blocks we have to use so called injections. This means delegating responsibility to other parsers.
it's a recommended way. JS tree-sitter has corresponding jsdoc too.

Based on a discussion in tree-sitter/tree-sitter-php#50

Here is an example from NVIM treesitter plugin:

https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/php/injections.scm

We have to use https://github.com/claytonrcarter/tree-sitter-phpdoc

The same is going to apply if we would like to support SQL queries in strings

@piotrkwiecinski
Copy link
Contributor Author

piotrkwiecinski commented May 26, 2023

Early experiment

phpdoc

It requires creating additional parser and probably separate variables for phpdoc for highlights but tree sitter inspector detects additional nodes in comments.

(treesit-parser-create 'phpdoc)

(setq-local treesit-range-settings
              (treesit-range-rules
               :embed 'phpdoc
               :host 'php
               '((comment) @capture)))

I found useful information here: https://archive.casouri.cc/note/2023/tree-sitter-starter-guide/html-manual/Multiple-Languages.html

@piotrkwiecinski
Copy link
Contributor Author

To support highlights in phpdoc we'll have to implement phpdoc-ts-mode and embed highlights.
The same applies to SQL and other nested languages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant