Skip to content
/ vim-http Public
forked from nicwest/vim-http

simple vim plugin to make http requests from buffers

Notifications You must be signed in to change notification settings

shime/vim-http

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Powered by vital.vim

vim-http

Simple wrapper over curl and http syntax highlighting.

asciicast

Usage

Write a raw http request

GET http://httpbin.org/get HTTP/1.1
Host: httpbin.org
Accept: application/json

:Http will execute the request and display the response in a new buffer.

:Http! will execute the request as above and follow any redirects.

:HttpShowCurl displays the curl request that the plugin executes under the hood

:HttpShowRequest displays the internal object representing the request

:HttpClean will add Host and Content-Length headers

:HttpAuth will prompt for authorization credentials

Configuration

g:vim_http_clean_before_do if set to 1 (default) will clean a request before sending it to curl. Disable this by setting this global to 0

g:vim_http_additional_curl_args can be used to provide additional arguments to curl.

g:vim_http_split_vertically when set to 1 will split the window vertically on response rather than horizontally (the default).

Helper Methods

http#remove_header(header) removes all occurances of the given header in the current buffer.

http#set_header(header, value) sets the header to the given value in the current buffer, removes duplicates

Examples for your vimrc:

function! s:set_json_header() abort
  call http#set_header('Content-Type', 'application/json')
endfunction

function! s:clean_personal_stuff() abort
  call http#remove_header('Cookie')
  call http#remove_header('Accept')
  call http#remove_header('User-Agent')
  call http#remove_header('Accept-Language')
endfunction 

function! s:add_compression() abort
  call http#set_header('Accept-Encoding', 'deflate, gzip')
  let g:vim_http_additional_curl_args = '--compressed'
endfunction

command! JSON call s:set_json_header()
command! Anon call s:clean_personal_stuff()
command! Compression call s:add_compression()

Tests

The integration test use httpbin, and assumes it running locally. I use a docker container:

docker pull citizenstig/httpbin
docker run -d=true -p 8000:8000 citizenstig/httpbin

To run the tests pull the themis test suite (you don't have to install it but you can if you want). I normally just dump it in the plugin directory.

git clone [email protected]:thinca/vim-themis.git
./vim-themis/bin/themis --reporter dot test

About

simple vim plugin to make http requests from buffers

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Vim Script 100.0%