httpyac-nvim (Neovim plugin)
httpyac-nvim Link to heading
A NeoVim wrapper plugin for httpyac CLI - Send HTTP requests from .http files directly within NeoVim with async execution and dedicated output buffer.
Source: asd-noor/httpyac-nvim
Features Link to heading
- โก Async Execution - Non-blocking HTTP requests using
vim.uv - ๐ Send Requests - Execute request at cursor or all requests in buffer
- ๐จ Syntax Highlighting - Color-coded HTTP responses with status codes
- ๐ Fuzzy Navigation - Jump to requests/variables with integrated picker
- ๐ Environment Management - Switch between dev/staging/prod environments
- ๐ค Dedicated Output - Persistent vertical split buffer for responses
- ๐ Seamless Integration - Works with snacks.nvim and which-key.nvim
Requirements Link to heading
Required Link to heading
- NeoVim 0.10+ (for
vim.uvsupport) - httpyac CLI tool
npm install -g httpyac # or yarn global add httpyac - snacks.nvim - For pickers
- which-key.nvim - For keymap registration
Optional Link to heading
- Treesitter parser for
httpfiles (recommended for better syntax highlighting in source files)
Installation Link to heading
Using lazy.nvim Link to heading
{
"asd-noor/httpyac-nvim",
dependencies = {
"folke/snacks.nvim",
"folke/which-key.nvim",
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "http" }
}
}
},
ft = "http", -- Load on http filetype
config = function()
require("httpyac-nvim").setup({})
end,
}
Manual Installation Link to heading
- Clone repository to your NeoVim plugin directory:
git clone https://github.com/noor/httpyac-nvim.git ~/.local/share/nvim/site/pack/plugins/start/httpyac-nvim - Ensure dependencies are installed
- Restart NeoVim
Setup Link to heading
Basic setup (optional - plugin auto-initializes):
require("httpyac-nvim").setup({})
Usage Link to heading
Quick Start Link to heading
- Create a
.httpfile:
### Simple GET request
GET https://httpbin.org/get
### POST with JSON body
POST https://httpbin.org/post
Content-Type: application/json
{
"name": "John Doe",
"email": "[email protected]"
}
### Using variables
@baseUrl = https://api.github.com
@username = octocat
GET {{baseUrl}}/users/{{username}}
Open in NeoVim:
nvim requests.httpSend requests:
- Position cursor on a request line
- Press
<leader>Rsto send request at cursor - Press
<leader>RSto send all requests in buffer
Default Keymaps Link to heading
All keymaps are buffer-local and only active in .http files:
| Keymap | Action | Description |
|---|---|---|
<leader>Rs | send_request_at_cursor() | Send HTTP request at cursor position |
<leader>RS | send_all_requests() | Send all HTTP requests in buffer |
<leader>Re | view_custom_env() | View current httpyac environment |
<leader>RE | set_custom_env() | Set httpyac environment file |
<leader>Rr | jump_to_request() | Jump to HTTP request (fuzzy picker) |
<leader>Rv | jump_to_variable() | Jump to HTTP variable (fuzzy picker) |
Note: Default leader key is usually
<Space>
Lua API Link to heading
You can call functions directly from Lua:
local httpyac = require("httpyac-nvim")
-- Send request at cursor
httpyac.send_request_at_cursor()
-- Send request with custom options
httpyac.send_request_at_cursor({"--verbose"})
-- Send all requests
httpyac.send_all_requests()
-- Environment management
httpyac.set_custom_env()
httpyac.view_custom_env()
-- Navigation
httpyac.jump_to_request()
httpyac.jump_to_variable()
Environment Files Link to heading
httpyac supports environment files for managing variables across different contexts (dev, staging, production).
Setting Environment Link to heading
Method 1: Using keymap
<leader>RE " Opens file picker to select environment file
Method 2: Using Lua function
require("httpyac-nvim").set_custom_env()
Method 3: Using environment variable
export HTTPYAC_ENV=/path/to/httpyac.config.js
nvim requests.http
Environment File Example Link to heading
Create httpyac.config.js:
module.exports = {
environments: {
dev: {
baseUrl: "http://localhost:3000",
token: "dev-token-123"
},
staging: {
baseUrl: "https://staging.api.example.com",
token: "staging-token-456"
},
prod: {
baseUrl: "https://api.example.com",
token: "prod-token-789"
}
}
};
Use in your .http file:
GET {{baseUrl}}/api/users
Authorization: Bearer {{token}}
See httpyac documentation for more details.
Syntax Highlighting Link to heading
The plugin provides custom syntax highlighting for HTTP responses in the output buffer (HTTPYAC_OUT):
- HTTP Methods - GET, POST, PUT, DELETE, etc.
- Status Codes - Color-coded by category:
2xxSuccess (green)3xxRedirect (cyan)4xxClient Error (yellow)5xxServer Error (red)
- Headers - Header names and values
- JSON - Strings, numbers, booleans
- URLs - Request paths
For .http source files, we recommend using Treesitter with the http parser.
Health Check Link to heading
Verify all dependencies are properly installed:
:checkhealth httpyac-nvim
The health check verifies:
- โ httpyac CLI installation and version
- โ snacks.nvim availability
- โ which-key.nvim availability
- โ NeoVim version (0.10+)
- โ HTTPYAC_ENV status
Advanced Usage Link to heading
Custom httpyac CLI Options Link to heading
Pass additional options to httpyac CLI:
-- Send with verbose output
require("httpyac-nvim").send_request_at_cursor({"--verbose"})
-- Send with specific output format
require("httpyac-nvim").send_request_at_cursor({"--output", "body"})
Multiple Environments Link to heading
Switch environments on-the-fly:
- Press
<leader>RE - Select environment file from picker
- Press
<leader>Reto verify current environment - Send requests - they’ll use the selected environment
Troubleshooting Link to heading
Plugin doesn’t load for .http files Link to heading
Check:
- File has
.httpextension or:set filetype=httpmanually - Dependencies are installed:
:Lazyto check plugin status - Run
:checkhealth httpyac-nvim
Syntax highlighting not working in output Link to heading
Check:
- Output buffer filetype:
:set ft?(should behttpyacout) - File exists:
ls ~/.config/nvim/.../syntax/httpyacout.vim - Run
:checkhealth httpyac-nvim
httpyac command not found Link to heading
Install httpyac CLI:
npm install -g httpyac
# Verify installation
httpyac --version
Keymaps not working Link to heading
Check:
- You’re in a buffer with
filetype=http - which-key.nvim is installed and loaded
- Try calling functions directly:
:lua require("httpyac-nvim").send_request_at_cursor()
Contributing Link to heading
Contributions are welcome! Please feel free to submit issues or pull requests.
Development Setup Link to heading
For local development:
-- In your init.lua
{
dir = "/path/to/httpyac-nvim",
name = "httpyac-nvim",
dependencies = {
"folke/snacks.nvim",
"folke/which-key.nvim",
},
ft = "http",
}
License Link to heading
MIT License - see LICENSE file for details
Related Projects Link to heading
- httpyac - The underlying CLI tool
- rest.nvim - Alternative HTTP client for NeoVim
- kulala.nvim - Another .http file client
Credits Link to heading
- Built on top of httpyac by Andreas Wassner
- Inspired from nvim-httpyac
- Uses snacks.nvim for pickers
- Uses which-key.nvim for keybindings
Note: This plugin is a wrapper around the httpyac CLI. For httpyac-specific features and advanced usage, refer to the official httpyac documentation.