https://github.com/nicwest/vim-http
simple vim plugin to make http requests from buffers
https://github.com/nicwest/vim-http
curl http vim
Last synced: 6 months ago
JSON representation
simple vim plugin to make http requests from buffers
- Host: GitHub
- URL: https://github.com/nicwest/vim-http
- Owner: nicwest
- License: unlicense
- Created: 2016-08-20T01:56:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-16T17:56:08.000Z (over 1 year ago)
- Last Synced: 2024-08-07T18:46:38.578Z (9 months ago)
- Topics: curl, http, vim
- Language: Vim Script
- Size: 61.5 KB
- Stars: 139
- Watchers: 3
- Forks: 13
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
[](https://circleci.com/gh/nicwest/vim-http/tree/master)
[](https://github.com/vim-jp/vital.vim)vim-http
========Simple wrapper over curl and http syntax highlighting.
[](https://asciinema.org/a/120707)
Usage
------Write a raw http request
```http
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).`g:vim_http_right_below` when set to `1` split window will be open on the
right (for vertical) or below (for horizontal).`g:vim_http_tempbuffer` when set to `1` response buffers will overwrite each
other instead of persisting forever.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 duplicatesExamples for your vimrc:
```viml
function! s:set_json_header() abort
call http#set_header('Content-Type', 'application/json')
endfunctionfunction! 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')
endfunctionfunction! s:add_compression() abort
call http#set_header('Accept-Encoding', 'deflate, gzip')
let g:vim_http_additional_curl_args = '--compressed'
endfunctioncommand! JSON call s:set_json_header()
command! Anon call s:clean_personal_stuff()
command! Compression call s:add_compression()
```