Skip to content

Quality of life changes to rest.nvim #125

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

Merged
merged 10 commits into from
Aug 9, 2022
Merged

Quality of life changes to rest.nvim #125

merged 10 commits into from
Aug 9, 2022

Conversation

udayvir-singh
Copy link
Contributor

@udayvir-singh udayvir-singh commented Aug 7, 2022

Features

Add ability to add custom formatters.

setup function now accepts formatters table. this makes jq optional.

require [[rest-nvim]].setup {
  result = {
    -- executables for formatting response body [optional]
    formatters = {
      -- set them to nil if you want to disable them
      json = "jq",
      html = {"tidy", "-i", "-q", "--show-errors", "0", "-"}
    },
  }
}

Add better syntax highlights in httpResult.

  • properly highlighted http status codes.
  • add separate highlights for date/expires headers.
  • better regex for numbers.
  • support highlighting response based on content-type header.

highlights

Add support for passing flags to curl, fixes #123.

Example:

POST http://localhost:3000/
Content-Type: application/json

-c /tmp/cookie

{ "id": 1 }

Bug Fixes

Fix errors in plenary when parsing json, fixes #118 and fixes #114.

Fix request preview getting cropped off.

Fix #67 error handling for formatters.

Copy link
Member

@NTBBloodbath NTBBloodbath left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thank you so much for this!

All these changes looks great, just a small things to be fixed (only documentation) imho.

I'll hopefully merge this PR once these changes are made :)

Cheers

@NTBBloodbath NTBBloodbath added the enhancement New feature or request label Aug 9, 2022
@NTBBloodbath NTBBloodbath merged commit 877291e into rest-nvim:main Aug 9, 2022
@teto
Copy link
Collaborator

teto commented Dec 29, 2022

I've been trying to override/remove the default formatters since otherwise I get

Error calling formatter on response body:                                                                                                                                                                                                                       
Vim:E475: Invalid value for argument cmd: 'tidy' is not executable

so I've done:

require("rest-nvim").setup({
          -- Open request results in a horizontal split
          result_split_horizontal = false,
          -- Skip SSL verification, useful for unknown certificates
          skip_ssl_verification = false,
          -- Highlight request on run
          highlight = {
		   enabled = true,
		   timeout = 150,
          },
          result = {
		   -- toggle showing URL, HTTP info, headers at top the of result window
		   show_url = true,
		   show_http_info = true,
		   show_headers = true,
		   -- disable formatters else they generate errors/add dependencies
		   -- for instance when it detects html, it tried to run 'tidy'
		   formatters = {
			html = nil,
			jq = nil
		   },
          },
          -- Jump to request line on run
          jump_to_request = false,
		})

to no avail. Can you change/override the formatters ? if yes how ? if no, do you want to send a patch ?

@udayvir-singh
Copy link
Contributor Author

@teto

I just noticed you have to set formatter to false instead of nil to disable them, also I have added an extra check to disable html formatter if tidy is not available in PR #165, and fixed the README in it.

@teto
Copy link
Collaborator

teto commented Dec 29, 2022

do you know why we special case json when we send the payload ? there should be no need, shouldn't it ?

I am looking at #157 and so if we didn't have to special case json, then we could skip the content-type check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: How can I pass arguments to curl ? plenary/curl : attempt to concatenate a table value Sending JSON-payload Error parsing bug
3 participants