This commit is contained in:
radumaco
2026-03-06 22:14:04 +01:00
parent 29272e3e1c
commit 70016196c1
8 changed files with 1148 additions and 0 deletions

148
doc/nvim-http.txt Normal file
View File

@@ -0,0 +1,148 @@
*nvim-http.txt* nvim-http
==============================================================================
CONTENTS *nvim-http-contents*
1. Introduction.............................................|nvim-http-intro|
2. Setup....................................................|nvim-http-setup|
3. Commands.................................................|nvim-http-commands|
4. HTTP Runner..............................................|nvim-http-http|
==============================================================================
INTRODUCTION *nvim-http-intro*
nvim-http supports:
- Running HTTP commands from the current line under cursor
- Parsing optional YAML header/body blocks under the request line
- Showing command output in a Telescope tree window
==============================================================================
SETUP *nvim-http-setup*
Using lazy.nvim:
>lua
{
"macocianradu/nvim-http",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
},
build = "rockspec",
config = function()
require("nvim_http").setup({
http = {
enabled = true,
execute_keymap = "<leader>hr",
clear_keymap = "<leader>hc",
timeout_ms = 10000,
highlight_group = "Comment",
command_patterns = {
"^curl%s+",
"^http%s+",
"^wget%s+",
"^%u+%s+https?://",
"^https?://",
},
},
})
end,
}
<
==============================================================================
COMMANDS *nvim-http-commands*
:NvimHttpRun
Run the HTTP command under cursor and open a Telescope window with:
- response_code
- a collapsed request block (url, headers, body)
- a collapsed headers block
- a collapsed result block (nested JSON tree when response is JSON)
:NvimHttpClear
Close and clear the HTTP result Telescope window.
==============================================================================
HTTP RUNNER *nvim-http-http*
Default mapping:
<leader>hr
Default clear mapping:
<leader>hc
Result window usage:
<CR> or <Tab> to open/close/toggle the selected node
q to close the result window
Supported line styles:
curl https://example.com
http GET https://example.com
wget https://example.com
GET https://example.com
https://example.com
Lines in markdown lists/quotes/inline code are normalized first, so these also
work:
- curl https://example.com
`GET https://example.com`
> https://example.com
YAML request blocks under request line:
POST https://jsonplaceholder.typicode.com/users
headers:
Content-Type: application/json
Authorization: Bearer token
body:
name: Jane
username: jane1
Accepted block names:
header / headers
body / request
Parsing behavior:
- scans only directly-below lines with bounded lookahead (does not scan file)
- ignores leading whitespace
- uses only first header(s) block and first body/request block
- stops when both are found
- also stops when another top-level block is found after parsing started
- request blocks are currently applied to curl-style requests
- YAML block decoding requires the lyaml Lua rock
Examples:
url
header:
X-Test: 1
body:
a: 1
-> uses both
url
header:
X-Test: 1
body:
a: 1
header2:
ignored: true
-> stops after body, ignores header2
url
header:
X-Test: 1
header2:
nope: 1
body:
ignored: true
-> stops at header2, ignores body
url
body:
a: 1
header:
X-Test: 1
-> body-first order works
==============================================================================
vim:tw=78:ts=8:ft=help:norl:

6
doc/tags Normal file
View File

@@ -0,0 +1,6 @@
nvim-http-commands nvim-http.txt /*nvim-http-commands*
nvim-http-contents nvim-http.txt /*nvim-http-contents*
nvim-http-http nvim-http.txt /*nvim-http-http*
nvim-http-intro nvim-http.txt /*nvim-http-intro*
nvim-http-setup nvim-http.txt /*nvim-http-setup*
nvim-http.txt nvim-http.txt /*nvim-http.txt*