rest.nvim icon indicating copy to clipboard operation
rest.nvim copied to clipboard

TreeSitter highlighting for response

Open disrupted opened this issue 1 year ago • 6 comments

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.

disrupted avatar Apr 17 '24 14:04 disrupted

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

NTBBloodbath avatar Apr 17 '24 14:04 NTBBloodbath

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

disrupted avatar Apr 17 '24 14:04 disrupted

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

NTBBloodbath avatar Apr 17 '24 16:04 NTBBloodbath

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 avatar Apr 17 '24 16:04 disrupted

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?

disrupted avatar Apr 17 '24 17:04 disrupted

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

NTBBloodbath avatar Apr 18 '24 02:04 NTBBloodbath

Closing this due to v3 release. rest.nvim now use tree-sitter-http to highlight the result UI.

boltlessengineer avatar Aug 22 '24 06:08 boltlessengineer