Note
please read this link.
This neovim plugin just do one thing: send http request under cursor and return the http response to you.
-- lazy.nvim spec
return {
"sunn4room/httpc.nvim",
ft = "http",
opts = {
register = "_", -- the register used to hold the response
animation = {
spinner = { "|", "/", "-", "\\" },
interval = 100,
},
magics = {
-- processEnv = function(args) ... end,
-- datetime = function(args) ... end,
-- randomInt = function(args) ... end,
-- timestamp = function(args) ... end,
-- urlencode = function(args) ... end,
-- ...
-- usage: {{$<magic> <arg1> <arg2> <args3>}}
},
patterns = {
-- json = "^application/.*json.*$",
-- ...
-- get lang from content-type for highlights.
},
},
}
Note
neovim doesn't recogize http
ft by default.
vim.filetype.add {
extension = {
http = "http",
rest = "http",
},
}
- Request parse.
- method
- url
- http version
- headers
- body
- external body
- form
- graphql
- Spinner to indicate that request is running.
- variable replacement.
- Define variable inside http file.
- Use magic lua function in variable replacement.
- Read variable from environment files.
- Response highlight.
-- run request under cursor
require("httpc").run()
-- run request somewhere
require("httpc").run({ buf = 0, row = 0, col = 0 })
-- cancel the running request if any
require("httpc").cancel()
Yes, you can.
{
animation = {
spinner = {
{
{ ">", "Comment" },
{ ">", "Comment" },
{ ">", "Comment" },
},
{
{ ">", "Special" },
{ ">", "Comment" },
{ ">", "Comment" },
},
{
{ ">", "Comment" },
{ ">", "Special" },
{ ">", "Comment" },
},
{
{ ">", "Comment" },
{ ">", "Comment" },
{ ">", "Special" },
},
},
},
}
Yes, you can.
@ORG=httpbin
@HOST={{ORG}}.org
###
GET https://{{HOST}}/get
GET https://httpbin.org/get
Current-Datetime: {{$datetime %Y-%m-%d\ %H:%M:%S}}
By default, httpc.nvim read variables from http-client.env.json
and http-client.env.json.user
with dev
env.
vim.b.http_client_env = "prod"