-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use treesitter highlights on successful invocations of Hurl
#7
Comments
Very interesting idea. Currently I set the buffer to be a terminal to gain highlighting of the hurl verbose output. I suspect that we can't really combine the two, so it might be that we need to switch to not using a terminal for the output to implement this. Another thought is that we could try to get treesitter highlighting merged into upstream hurl, but even if we did that it would probably still be valuable to be able to do it in neovim for the sake of using your nvim color settings |
A severe limitation is the headers at the top of these files, as I don't know how to write treesitter injections at this point in time to give the headers highlights separate from the body. Another issue is that this forces the users to opt-in to seeing headers which may not be desired. But for a PoC? Good enough. Related to pfeiferj#7
I have accomplished this feat. Is it any good? Probably not considering I've been up for close to 40 hours. BUT, it does, in fact, work. Take a look here: https://github.com/treatybreaker/nvim-hurl/tree/set-filetype I, unfortunately, don't know how to write Treesitter queries of any note so the headers are looking a bit drab. Ideally we'd do injections for the headers to highlight them separately from the body. For now though, this serves as a solid enough PoC. Screenshot of that branch in action: |
A severe limitation is the headers at the top of these files, as I don't know how to write treesitter injections at this point in time to give the headers highlights separate from the body. Another issue is that this forces the users to opt-in to seeing headers which may not be desired. But for a PoC? Good enough. Related to pfeiferj#7
Hmm, looks like a good start. Have some thoughts though: |
Nevermind, it would require a whole new grammar to support this |
1.) Infinite Energy. If you know of a better way then do say so, cutting out term codes is kinda hacky |
So another idea is to actually separate stdout and stderr into separate windows. I believe the verbose hurl output actually outputs on stderr and then the final request outputs its data to stdout. Then stderr we could set term on to get its highlighting and then we could set a filetype for the stdout |
But the issue is that if you call |
Not exactly, we just wouldn't use --no-color. The stderr is the only part that will have the term codes, so if we send that to its own window and set that window to term it will color it and hide the term codes correctly, then stdout we just send to a normal window that we set the filetype in. But, this is all assuming i'm right about the verbose header information being sent to stderr and not stdout |
Oh ok, I see what you're saying. AFAIK the Header info is populated into stdout by the |
ah, gotcha, so if we were to take the two window approach we would drop the --include so that we would have a separation of stderr=hurl colored term output, stdout=the last request's response data |
wait, just realized what you meant, I've only ever really used the verbose option to get header info, so i thought --include must have just been verbose output but combined into stdout. Let me try out some stuff real quick with --include |
ok, new new idea with a few parts: |
I can take a look at doing all of this tomorrow (if I get a minute), if not it'll have to be this coming weekend or Friday. The only thing that might be sketchy is the window split, as currently we're opening a floating window by default. Does this mean we're moving to a vertical split with two windows stacked on top of each other? Basically, that can't be fully configurable, might have to give up on some things on the user config side. |
Probably fine to default to splits, I can look into a floating window option for it. Other things like telescope use multiple floating windows to separate information so it should definitely be possible |
With `vim.system` we get better type coersion and general support from libuv. Jobstart is primarily meant to be used from vimscript, not lua. Per `:h jobstart` it recommends using `vim.system`. This also makes it easier to handle building the commands list for hurl as now we only have to manage a table. This is the first of a few commits related to pfeiferj#9 and pfeiferj#7.
With `vim.system` we get better type coersion and general support from libuv. Jobstart is primarily meant to be used from vimscript, not lua. Per `:h jobstart` it recommends using `vim.system`. This also makes it easier to handle building the commands list for hurl as now we only have to manage a table. This is the first of a few commits related to pfeiferj#9 and pfeiferj#7.
This issue is mostly to pitch an idea.
When Hurl successfully executes it returns the content from whatever API/webpage it was called against it returns the raw content. We can extract the
Content-Type
from Hurl by running it with the-i
flag.With the
Content-Type
in hand it should be possible to set the buffer'sfiletype
to the outputContent-Type
. As a note Hurl returns the last http request's content and headers only, so if you had multipleGET
orPOST
requests in a single file to different URLs, only the last request's content is returned.If Hurl runs into an error then we can return the content in
stderr
as usual without anyfiletype
settings.The text was updated successfully, but these errors were encountered: