diepm / vim-rest-console

A REST console for Vim.
658 stars 54 forks source link

Response no longer highlights syntax #44

Closed chaucerbao closed 7 years ago

chaucerbao commented 7 years ago

I've noticed that the response window no longer has its syntax highlighted.

image

However, I can run a :set ft=rest on the __REST_response__ window to restore highlighting.

image

diepm commented 7 years ago

Do you have g:vrc_curl_opts (with -i) or g:vrc_include_response_header (or b:vrc_include_response_header) set? I'm curious because your response comes with the headers while your request doesn't specify any curl options. It might or might not be a bug depending on those settings.

You can enable the debug mode and check what cUrl options are used with your request.

chaucerbao commented 7 years ago

This is my config for VRC. Just one(-ish).

let g:vrc_curl_opts={
    \'--include': '',
    \'--location': '',
    \'--show-error': '',
    \'--silent': ''
\}

Basically equivalent to -sS -L -i. I prefer using the long-form version of options in config files for legibility.

The output from vrc_show_command is

curl --include --show-error -H 'Content-Type: application/json' --silent --location --get 'https://jsonplaceholder.typicode.com/comments//'
chaucerbao commented 7 years ago

Oh, and removing cURL's -i option still doesn't enable the syntax highlighting.

image

diepm commented 7 years ago

I see what went wrong. Just pushed the fix. Please retest. Thanks!

chaucerbao commented 7 years ago

Works for --include and -i now!

However, there's no syntax highlighting if you're not using --include/-i.

By the way, thanks a lot for your work on this plugin. I like being able to stay in Vim to test APIs instead of constantly switching apps.

diepm commented 7 years ago

It's expected since without the returned headers, VRC doesn't know the content type to properly format or syntax-highlight the content. However, there are a couple ways if you don't want to include the --include/-i flag. Check out section 7.2 and option vrc_response_default_content_type.

Glad that you enjoy VRC!

chaucerbao commented 7 years ago

Makes sense. I'm used to assuming JSON by default.