rest-nvim / rest.nvim

A fast Neovim http client written in Lua
GNU General Public License v3.0
1.52k stars 141 forks source link

TreeSitter highlighting for response #366

Closed disrupted closed 1 month ago

disrupted commented 5 months ago

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 commented 5 months ago

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

disrupted commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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

boltlessengineer commented 1 month ago

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