A Neovim plugin for HTTPie — run HTTP requests and manage collections without leaving your editor.
- Neovim 0.9+
- HTTPie (
brew install httpie)
-- lazy.nvim
{
"harrydt/httpie.nvim",
config = function()
require("httpie").setup()
end,
}Create a .http file (:HttpieNew myapi) and write requests separated by ###:
# in-file variables, used as a fallback when the env var isn't set
@BASE_URL = https://api.example.com
@TOKEN = supersecret
### Get users
GET {{BASE_URL}}/users?active=true
Authorization: Bearer {{TOKEN}}
Accept: application/json
### Create user
# comments are allowed anywhere in a request block
POST {{BASE_URL}}/users
Content-Type: application/json
{"name": "Alice", "email": "alice@example.com"}
### Delete user
DELETE {{BASE_URL}}/users/1
Authorization: Bearer {{TOKEN}}{{VAR}} placeholders are substituted from OS environment variables (export BASE_URL=...), falling back to in-file variables declared as @VAR = value anywhere in the file if no environment variable of that name is set. The ### line optionally takes a name (e.g. ### Get users) used to label the request in the output window.
| Command | Action |
|---|---|
:HttpieNew [name] |
Create a new collection |
:HttpieOpen |
Browse and open a saved collection |
:HttpieSave |
Append the request at cursor to a collection |
:HttpieRun |
Run the request at cursor |
:HttpieClose |
Close the current .http buffer and return to where it was opened from |
:HttpieImport |
Convert a selected httpie CLI command into a request block |
:HttpieExport |
Copy the request at cursor as an httpie CLI command |
Collections are .http files stored in ~/.local/share/nvim/httpie-nvim/.
:HttpieImport — paste an http CLI command into a .http file, select it (visual mode), and run :HttpieImport:
http POST https://api.example.com/users Authorization:"Bearer abc123" name=Alice age:=30
becomes:
###
POST https://api.example.com/users
Authorization: Bearer abc123
Content-Type: application/json
{"age": 30, "name": "Alice"}:HttpieExport goes the other way: builds the equivalent http CLI command for the request at cursor and copies it to your system clipboard.
require("httpie").setup({
binary = "http", -- path to httpie binary
storage_dir = vim.fn.stdpath("data") .. "/httpie-nvim", -- where collections live
print = "hb", -- httpie's --print flag, e.g. "b" for body only
output = {
split = "vertical", -- "vertical" | "horizontal" | "float"
size = 80,
},
})What httpie syntax does :HttpieImport support?
- Methods and URLs
- Headers (
Name:value) - JSON body fields (
key=value,key:=valuefor raw JSON) - Query params (
key==value) - Basic auth (
-a user:pass) - Form-encoded bodies (
-f) - Piped bodies (
echo '{...}' | http POST ...) - Anything else (file uploads, sessions, etc.) is left as a
# NOTE:comment instead of being silently dropped
What happens to $VAR / ${VAR} in an imported command?
- They're converted to
{{VAR}} - A header like
Authorization:"Bearer $TOKEN"resolves from your OS environment instead of staying as dead text
What does :HttpieExport produce, exactly?
{{VAR}}placeholders are converted back to$VAR, so the exported command never contains a resolved secret — the value is only filled in by your shell when you run it- If the request has a body, it's exported as
echo '{...}' | http POST ... - A plain
Content-Type: application/jsonheader is omitted, since httpie sets that automatically whenever a body is present - Any other
Content-Typeis kept
Are secrets ever shown in the output window?
- The command echoed at the top of the output window (
# $ http ...) masks known sensitive header values as***—Authorization,Cookie,Set-Cookie,X-Api-Key,X-Auth-Token, andProxy-Authorization - The actual request still sends the real, substituted value; only the echoed line is masked
- This list isn't currently configurable
- Request bodies aren't masked at all
What does :HttpieClose do if I have unsaved changes?
- It refuses to close (save with
:wfirst, or force with:bd!) - It also does nothing if the current buffer isn't an
.httpfile