jellydn / hurl.nvim

Hurl.nvim is a Neovim plugin designed to run HTTP requests directly from `.hurl` files. Elevate your API development workflow by executing and viewing responses without leaving your editor.
https://gyazo.com/19492e8b5366cec3f22d5fd97a63f37a
MIT License
148 stars 15 forks source link

Fix HurlRunnterToEntry using treesitter #116

Closed hsanson closed 6 months ago

hsanson commented 6 months ago

WHAT

Modify HurlRunnerToEntry to work using treesitter parser. This allows to run to a specific entry without having to be exactly located at the start of the entry where the verb is located.

WHY

HOW

Screenshots (if appropriate):

Types of changes

Checklist:

changeset-bot[bot] commented 6 months ago

⚠️ No Changeset found

Latest commit: ab9977987831fbfe06868711aad30a71a26329c1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

sweep-ai[bot] commented 6 months ago

Apply Sweep Rules to your PR?

This is an automated message generated by Sweep AI.

jellydn commented 6 months ago

Thanks. I will take a try tonight.

jellydn commented 6 months ago

FYI - Just synced your change to https://github.com/jellydn/hurl.nvim/tree/canary and the PR is not working properly yet.

hsanson commented 6 months ago

FYI - Just synced your change to https://github.com/jellydn/hurl.nvim/tree/canary and the PR is not working properly yet.

Please let me know what issues you are experiencing and if possible a sample hurl file to reproduce them. I have tested it on my hurl files and seems to work properly.

jellydn commented 5 months ago

FYI - Just synced your change to canary and the PR is not working properly yet.

Please let me know what issues you are experiencing and if possible a sample hurl file to reproduce them. I have tested it on my hurl files and seems to work properly.

Sure, I will push my test file to repository so you could try as well.

jellydn commented 5 months ago

Hi @hsanson Here is the simple test file https://github.com/jellydn/hurl.nvim/commit/ae57eba85eafd80d54c1f10c2d212383e8e55389 It works with main but not working properly with canary branch.

jellydn commented 5 months ago

Just FYI - I've reverted to using the find verb instead of treesitter parser.

Reproduce:

The canary branch will return the Google response instead of manga API. @hsanson

jellydn commented 5 months ago

Canary:

image

Main:

image
hsanson commented 5 months ago

@jellydn sorry for the issue... please test if this fixes it for you:

jellydn commented 5 months ago

Thanks @hsanson Almost there. The parser logic will failed if there is a comment on hurl, e.g: https://github.com/jellydn/hurl.nvim/commit/9f773eff4a061d7d5e66a1c58af345dc365b6417

jellydn commented 5 months ago

For now, this is my solution :) https://github.com/jellydn/hurl.nvim/commit/4d4e4ff9df020522dca8a6dc9ea7fd3dfa25069d

hsanson commented 5 months ago

@jellydn simple solution and seems to work as far as I can see... thanks. Better than trying to fix the treesitter parser that does not seem to properly parse the comments and treat them as errors. Specially the top most comment.

You can see how the treesitter sees the file using :InspectTree. This is a very useful tool to understand hurl grammar.

jellydn commented 5 months ago

Great. Thanks, @hsanson Also, the treesitter parser only works for nightly. I will bring the find verb back to fallback on stable version.

jellydn commented 5 months ago

FYI https://github.com/jellydn/hurl.nvim/commit/c10a905