Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A very fast, powerful, extensible and asynchronous Neovim HTTP client written in Lua.

License

NotificationsYou must be signed in to change notification settings

rest-nvim/rest.nvim

Repository files navigation


A very fast, powerful, extensible and asynchronous Neovim HTTP client written in Lua.

rest.nvim by default makes use of its owncurl wrapper made in pure Lua and atree-sitterparser to parsehttp files. So what you can run get exact and detailed result what you see fromyour editor!

In addition to this, you can also write integrations with external HTTP clients, such as the postmanCLI.

Important

If you are facing issues, pleasereport them so we can work in a fix together :)

Features

  • Easy to use
  • Friendly, organized and featureful request results window
  • Fast runtime with statistics about your request
  • Set custom pre-request and post-request hooks to dynamically interact with the data
  • Easily set environment variables based on the response to re-use the data later
  • Tree-sitter based parsing and syntax highlighting for speed and perfect accuracy
  • Format response body with nativegq command
  • Possibility of using dynamic/environment variables and Lua scripting in HTTP files
  • Save received cookies and load them automatically

Install

Note

Checkthis troubleshooting guide if you have any issues whileinstalling this plugin.

Dependencies

rocks.nvim (recommended)

:Rocks install rest.nvim
{"rest-nvim/rest.nvim",dependencies= {"nvim-treesitter/nvim-treesitter",opts=function (_,opts)opts.ensure_installed=opts.ensure_installedor {}table.insert(opts.ensure_installed,"http")end,  }}

Important

You need lazy.nvim higher than v11 to install rockspec dependencies

Setup

No.setup() call is needed!Just set your options viavim.g.rest_nvim. It is fully documented and typed internally so you geta good experience during autocompletion :)

---@typerest.Optsvim.g.rest_nvim= {-- ...}

Note

You can also check out:h rest-nvim.config for documentation.

Default configuration

---rest.nvim default configuration---@classrest.Configlocaldefault_config= {---@typetable<string,fun():string> Table of custom dynamic variablescustom_dynamic_variables= {},---@classrest.Config.Requestrequest= {---@typeboolean Skip SSL verification,useful for unknown certificatesskip_ssl_verification=false,---Default request hooks---@classrest.Config.Request.Hookshooks= {---@typeboolean Encode URL before making requestencode_url=true,---@typestring Set`User-Agent`header when it is emptyuser_agent="rest.nvim v"..require("rest-nvim.api").VERSION,---@typeboolean Set`Content-Type`header when it is empty and body is providedset_content_type=true,        },    },---@classrest.Config.Responseresponse= {---Default response hooks---@classrest.Config.Response.Hookshooks= {---@typeboolean Decode the request URL segments on response UI to improve readabilitydecode_url=true,---@typeboolean Format the response body using`gq`commandformat=true,        },    },---@classrest.Config.Clientsclients= {---@classrest.Config.Clients.Curlcurl= {---Statistics to be shown, takes cURL's `--write-out` flag variables---See `man curl` for `--write-out` flag---@typeRestStatisticsStyle[]statistics= {                {id="time_total",winbar="take",title="Time taken"},                {id="size_download",winbar="size",title="Download size"},            },---Curl-secific request/response hooks---@classrest.Config.Clients.Curl.Optsopts= {---@typeboolean Add`--compressed`argument when`Accept-Encoding`header includes---`gzip`set_compressed=false,---@typetable<string,Certificate> Table containing certificates for each domainscertificates= {},            },        },    },---@classrest.Config.Cookiescookies= {---@typeboolean Whether enable cookies support or notenable=true,---@typestring Cookies file pathpath=vim.fs.joinpath(vim.fn.stdpath("data")--[[@as string]],"rest-nvim.cookies"),    },---@classrest.Config.Envenv= {---@typebooleanenable=true,---@typestringpattern=".*%.env.*",---@typefun():string[]find=function()localconfig=require("rest-nvim.config")returnvim.fs.find(function(name,_)returnname:match(config.env.pattern)end, {path=vim.fn.getcwd(),type="file",limit=math.huge,            })end,    },---@classrest.Config.UIui= {---@typeboolean Whether to set winbar to result paneswinbar=true,---@classrest.Config.UI.Keybindskeybinds= {---@typestring Mapping for cycle to previous result paneprev="H",---@typestring Mapping for cycle to next result panenext="L",        },    },---@classrest.Config.Highlighthighlight= {---@typeboolean Whether current request highlighting is enabled or notenable=true,---@typenumber Duration time of the request highlighting in millisecondstimeout=750,    },---@seevim.log.levels---@typeinteger log level_log_level=vim.log.levels.WARN,}

Usage

Create a new http file or open an existing one and run the:Rest run {name} command, orjust place the cursor over the request and simply run:Rest run.

HTTP file syntax

Method Request-URI HTTP-VersionHeader-field: Header-valueRequest-Body

Note

rest.nvim followsintellij's http client specfor.http file syntax. You can find examples of use in thespec/examplesdirectory.

Keybindings

By defaultrest.nvim does not have any key mappings except the result buffers so you will not haveconflicts with any of your existing ones.

Commands

User CommandBehavior
:Rest openOpen result pane
:Rest runRun request under the cursor
:Rest run {name}Run request with name{name}
:Rest lastRun last request
:Rest logsEdit logs file
:Rest cookiesEdit cookies file
:Rest env showShow dotenv file registered to current.http file
:Rest env selectSelect & register.env file withvim.ui.select()
:Rest env set {path}Register.env file to current.http file

[!INFO]All:Rest subcommands opening new window supportcommand-modifiers (:h command-modifiers.)For example, you can run:hor Rest open to open result pane in horizontal split.

See:h rest-nvim.commands for more info

Lua scripting

http://localhost:8000# @lang=lua> {%local json = vim.json.decode(response.body)json.data = "overwritten"response.body = vim.json.encode(json)%}

Put# @lang=lua comment just above any script elements.Scripts without@lang will be parsed as javascript code to match withhttp spec.

Extensions

Telescope Extension

rest.nvim provides a [telescope.nvim] extension to select the environment variables file,you can load and use it with the following snippet:

-- first load extensionrequire("telescope").load_extension("rest")-- then use it, you can also use the `:Telescope rest select_env` commandrequire("telescope").extensions.rest.select_env()

Here is a preview of the extension working :)

telescope rest extension demo

Mappings

  • Enter: Select Env file
  • Ctrl + O: Edit Env file

Config

  • config.env.pattern: For env file pattern (lua-pattern)

Lualine Component

We also have lualine component to get what env file you select!

And don't worry, it will only show up under HTTP files.

-- Just add a component in your lualine config{sections= {lualine_x= {"rest"    }  }}-- To use a custom icon and color{sections= {lualine_x= {      {"rest",icon="",fg="#428890"      }    }  }}

Here is a preview of the component working :)

lualine component demo

Contribute

  1. Fork it (https://github.com/rest-nvim/rest.nvim/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'feat: add some feature')
  4. Push to the branch (git push -u origin my-new-feature)
  5. Create a new Pull Request

Important

rest.nvim usessemantic commits that adhere tosemantic versioning and these help with automatic releases, please use this type of conventionwhen submitting changes to the project.

Tests can be ran viamake test. You must haveluarocks installed to install dependencies. Thetest runner throughmake test will automatically install all required dependencies.

Related software

License

rest.nvim isGPLv3 Licensed.

About

A very fast, powerful, extensible and asynchronous Neovim HTTP client written in Lua.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Contributors73

Languages


[8]ページ先頭

©2009-2026 Movatter.jp