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.uv support)
  • 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 http files (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

  1. 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
    
  2. Ensure dependencies are installed
  3. 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

  1. Create a .http file:
### 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}}
  1. Open in NeoVim:

    nvim requests.http
    
  2. Send requests:

    • Position cursor on a request line
    • Press <leader>Rs to send request at cursor
    • Press <leader>RS to send all requests in buffer

Default Keymaps Link to heading

All keymaps are buffer-local and only active in .http files:

KeymapActionDescription
<leader>Rssend_request_at_cursor()Send HTTP request at cursor position
<leader>RSsend_all_requests()Send all HTTP requests in buffer
<leader>Review_custom_env()View current httpyac environment
<leader>REset_custom_env()Set httpyac environment file
<leader>Rrjump_to_request()Jump to HTTP request (fuzzy picker)
<leader>Rvjump_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:
    • 2xx Success (green)
    • 3xx Redirect (cyan)
    • 4xx Client Error (yellow)
    • 5xx Server 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:

  1. Press <leader>RE
  2. Select environment file from picker
  3. Press <leader>Re to verify current environment
  4. Send requests - they’ll use the selected environment

Troubleshooting Link to heading

Plugin doesn’t load for .http files Link to heading

Check:

  1. File has .http extension or :set filetype=http manually
  2. Dependencies are installed: :Lazy to check plugin status
  3. Run :checkhealth httpyac-nvim

Syntax highlighting not working in output Link to heading

Check:

  1. Output buffer filetype: :set ft? (should be httpyacout)
  2. File exists: ls ~/.config/nvim/.../syntax/httpyacout.vim
  3. 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:

  1. You’re in a buffer with filetype=http
  2. which-key.nvim is installed and loaded
  3. 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

Credits Link to heading


Note: This plugin is a wrapper around the httpyac CLI. For httpyac-specific features and advanced usage, refer to the official httpyac documentation.