Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork150
A very fast, powerful, extensible and asynchronous Neovim HTTP client written in Lua.
License
rest-nvim/rest.nvim
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
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 :)
- 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 native
gqcommand - Possibility of using dynamic/environment variables and Lua scripting in HTTP files
- Save received cookies and load them automatically
Note
Checkthis troubleshooting guide if you have any issues whileinstalling this plugin.
- Neovim >= 0.10.1
curl- tree-sitter-http (if you use
lazy.nvim)
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
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.
---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,}
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.
Method Request-URI HTTP-VersionHeader-field: Header-valueRequest-BodyNote
rest.nvim followsintellij's http client specfor.http file syntax. You can find examples of use in thespec/examplesdirectory.
By defaultrest.nvim does not have any key mappings except the result buffers so you will not haveconflicts with any of your existing ones.
| User Command | Behavior |
|---|---|
:Rest open | Open result pane |
:Rest run | Run request under the cursor |
:Rest run {name} | Run request with name{name} |
:Rest last | Run last request |
:Rest logs | Edit logs file |
:Rest cookies | Edit cookies file |
:Rest env show | Show dotenv file registered to current.http file |
:Rest env select | Select & register.env file withvim.ui.select() |
:Rest env set {path} | Register.env file to current.http file |
[!INFO]All
:Restsubcommands opening new window supportcommand-modifiers(:h command-modifiers.)For example, you can run:hor Rest opento open result pane in horizontal split.
See:h rest-nvim.commands for more info
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.
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 :)
- Enter: Select Env file
- Ctrl + O: Edit Env file
config.env.pattern: For env file pattern (lua-pattern)
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 :)
- Fork it (https://github.com/rest-nvim/rest.nvim/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'feat: add some feature') - Push to the branch (
git push -u origin my-new-feature) - 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.
rest.nvim isGPLv3 Licensed.
About
A very fast, powerful, extensible and asynchronous Neovim HTTP client written in Lua.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.


