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

TreeSitter highlighting for response #366

Open
disrupted opened this issue Apr 17, 2024 · 6 comments
Open

TreeSitter highlighting for response #366

disrupted opened this issue Apr 17, 2024 · 6 comments

Comments

@disrupted
Copy link
Contributor

Why does the response buffer use the httpResult filetype, not http like the request buffer? I feel like it would be nicer to use the same TreeSitter parser for the response.

@NTBBloodbath
Copy link
Member

It is not possible due to the nature of the results buffer content, at least not without introducing breaking changes and more complexity.

@disrupted
Copy link
Contributor Author

could you elaborate what are the breaking changes? I just tested it locally by running :set ft=http. After making the buffer modifiable (:set modifiable) and manually deleting the comments #+RES and #+END (not sure what's the purpose of those). It works well for me with a JSON body

@NTBBloodbath
Copy link
Member

NTBBloodbath commented Apr 17, 2024

could you elaborate what are the breaking changes? I just tested it locally by running :set ft=http. After making the buffer modifiable (:set modifiable) and manually deleting the comments #+RES and #+END (not sure what's the purpose of those). It works well for me with a JSON body

Does the HTTP/X.X OK line works well too? Also check :InspectTree output to look for error nodes. If nothing is wrong, we could make the change without much problem, although I'm worried about what the parser might spit out when the response to a request is binary, or in case of returning an image

@disrupted
Copy link
Contributor Author

disrupted commented Apr 17, 2024

Good point, the second line gets falsely parsed as request. This would either need to be fixed in the parser, or perhaps we would need a separate parser (based on http) since it's not part of the http filetype.

I haven't tested binary or image payload yet.

@disrupted
Copy link
Contributor Author

I can start by adding some test cases in https://github.com/rest-nvim/tree-sitter-http and then we can decide how to proceed, what do you think?

@NTBBloodbath
Copy link
Member

Sounds good to me, hope we can achieve something in the short term!

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

2 participants