Giter VIP home page Giter VIP logo

rest.nvim's Introduction

rest.nvim

License Neovim version LuaRocks Discord Matrix

FeaturesInstallUsageContribute

Demo


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

rest.nvim by default makes use of native cURL bindings. In this way, you get absolutely all the power that cURL provides from the comfort of our editor just by using a keybind and without wasting the precious resources of your machine.

In addition to this, you can also write integrations with external HTTP clients, such as the postman CLI. For more information on this, please see this blog post.

Important

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

Features

  • Easy to use
  • Friendly and organized 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
  • Possibility of using dynamic/environment variables and Lua scripting in HTTP files

Install

Note

rest.nvim requires Neovim >= 0.9.2 to work.

Dependencies

  • System-wide
    • Python (only if you are using packer.nvim or lazy.nvim plus luarocks.nvim for the installation)
    • cURL development headers (usually called libcurl-dev or libcurl-devel depending on your Linux distribution)
  • Optional can be changed, see config below
    • jq (to format JSON output)
    • tidy (to format HTML output)

Note

  1. Python will be unnecessary once luarocks.nvim gets rid of it as a dependency in the go-away-python branch.

  2. I will be working on making a binary rock of Lua-cURL so that the cURL development headers are not necessary for the installation process.

rocks.nvim (recommended)

:Rocks install rest.nvim
{
  "vhyrro/luarocks.nvim",
  priority = 1000,
  config = true,
  opts = {
    rocks = { "lua-curl", "nvim-nio", "mimetypes", "xml2lua" }
  }
},
{
  "rest-nvim/rest.nvim",
  ft = "http",
  dependencies = { "luarocks.nvim" },
  config = function()
    require("rest-nvim").setup()
  end,
}

Note

There's a build.lua file in the repository that lazy.nvim will find and source to install the luarocks dependencies for you by using luarocks.nvim. You don't need to specify a rock list by yourself.

use {
  "rest-nvim/rest.nvim",
  rocks = { "lua-curl", "nvim-nio", "mimetypes", "xml2lua" },
  config = function()
    require("rest-nvim").setup()
  end,
}

Default configuration

This is the default configuration of rest.nvim, it is fully documented and typed internally so you get a good experience during autocompletion :)

Note

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

local default_config = {
  client = "curl",
  env_file = ".env",
  env_pattern = "\\.env$",
  env_edit_command = "tabedit",
  encode_url = true,
  skip_ssl_verification = false,
  custom_dynamic_variables = {},
  logs = {
    level = "info",
    save = true,
  },
  result = {
    split = {
      horizontal = false,
      in_place = false,
      stay_in_current_window_after_split = true,
    },
    behavior = {
      decode_url = true,
      show_info = {
        url = true,
        headers = true,
        http_info = true,
        curl_command = true,
      },
      statistics = {
        enable = true,
        ---@see https://curl.se/libcurl/c/curl_easy_getinfo.html
        stats = {
          { "total_time", title = "Time taken:" },
          { "size_download_t", title = "Download size:" },
        },
      },
      formatters = {
        json = "jq",
        html = function(body)
          if vim.fn.executable("tidy") == 0 then
            return body, { found = false, name = "tidy" }
          end
          local fmt_body = vim.fn.system({
            "tidy",
            "-i",
            "-q",
            "--tidy-mark",      "no",
            "--show-body-only", "auto",
            "--show-errors",    "0",
            "--show-warnings",  "0",
            "-",
          }, body):gsub("\n$", "")

          return fmt_body, { found = true, name = "tidy" }
        end,
      },
    },
    keybinds = {
      buffer_local = true,
      prev = "H",
      next = "L",
    },
  },
  highlight = {
    enable = true,
    timeout = 750,
  },
  ---Example:
  ---
  ---```lua
  ---keybinds = {
  ---  {
  ---    "<localleader>rr", "<cmd>Rest run<cr>", "Run request under the cursor",
  ---  },
  ---  {
  ---    "<localleader>rl", "<cmd>Rest run last<cr>", "Re-run latest request",
  ---  },
  ---}
  ---
  ---```
  ---@see vim.keymap.set
  keybinds = {},
}

Tree-Sitter parsing

rest.nvim uses tree-sitter as a first-class citizen, so it will not work if the required parsers are not installed. These parsers are as follows and you can add them to your ensure_installed table in your nvim-treesitter configuration.

ensure_installed = { "lua", "xml", "http", "json", "graphql" }

Or manually run :TSInstall lua xml http json graphql.

Keybindings

By default rest.nvim does not have any key mappings so you will not have conflicts with any of your existing ones.

However, rest.nvim exposes a :Rest command in HTTP files that you can use to create your keybinds easily. For example:

keybinds = {
  {
    "<localleader>rr", "<cmd>Rest run<cr>", "Run request under the cursor",
  },
  {
    "<localleader>rl", "<cmd>Rest run last<cr>", "Re-run latest request",
  },
}

You can still also use the legacy <Plug>RestNvim commands for mappings:

  • <Plug>RestNvim, run the request under the cursor
  • <Plug>RestNvimLast, re-run the last request

Note

  1. <Plug>RestNvimPreview has been removed, as we can no longer implement it with the current cURL implementation.

  2. The legacy <Plug> mappings will raise a deprecation warning suggesting you to switch to the :Rest command, as they are going to be completely removed in the next version.

Usage

Create a new http file or open an existing one and place the cursor over the request and run the :Rest run command.

Note

  1. You can find examples of use in the tests directory.

  2. rest.nvim supports multiple HTTP requests in one file. It selects the request in the current cursor line, no matters the position as long as the cursor is on a request tree-sitter node.


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 extension
require("telescope").load_extension("rest")
-- then use it, you can also use the `:Telescope rest select_env` command
require("telescope").extensions.rest.select_env()

If running Ubuntu or Debian based systems you might need to run ln -s $(which fdfind) ~/.local/bin/fd to get extension to work. This is becuase extension runs the fd command.

Here is a preview of the extension working :)

telescope rest extension demo

Mappings

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

Config

  • env_pattern: For env file pattern
  • env_edit_command: For env file edit command

Lualine

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

And dont'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 uses semantic commits that adhere to semantic versioning and these help with automatic releases, please use this type of convention when submitting changes to the project.

Tests can be ran via make test. You must have luarocks installed and lua5.1 or luajit to install dependencies. The test runner through make test will automatically install all required dependencies.

Related software

License

rest.nvim is GPLv3 Licensed.

rest.nvim's People

Contributors

apisc avatar bingcoke avatar blackadress avatar daniilrozanov avatar ddomurad avatar disrupted avatar github-actions[bot] avatar jens1205 avatar jgersdorf avatar joshuali925 avatar klen avatar leixb avatar lhanson avatar mr-majkel avatar ntbbloodbath avatar philrunninger avatar pinpongtp avatar pricehiller avatar purefun avatar rasmus-bertell avatar rhart92 avatar samuelabreu avatar srihari93 avatar teto avatar theleop avatar theneokun avatar udayvir-singh avatar yagua avatar ybbond avatar ziemcd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rest.nvim's Issues

No syntax highlighting for the http file

First of all thanks for this amazing plugin.

I was trying out this plugin but the http file is not getting syntax highlighted as shown in the image in readme. The response is getting highlighted correctly.
image

Suggestion: Follow RFC 2616 instead of named blocks

I think it'd make sense to follow RFC 2616 request format instead of using the named blocks.
This would allow you to share your http-files with team mates who use other editors and clients which follow that format.

POST https://example.com/comments HTTP/1.1
content-type: application/json

{
    "name": "example",
    "time": "Tue, 11 May 2021 9:50:50 GMT"
}

Feature request: add option to put header values in the .env

Hi @NTBBloodbath, following the resolution of the token authorization, I was wondering if it is possible to have values of the headers defined in the .env file, and resolve them when parsing the http file. It works today for URL component, but not for headers. It comes useful especially with the tokens - you can put the token in .env file and then have all the calls re-use it. What do you think?

Treesitter error when navigating in http file

Describe the bug
Following error is shown when moving in http file

image

To Reproduce
Steps to reproduce the behaviour:

  1. Create test.http file.
  2. Add GET https://reqres.in/api/users?page=5 content to the file.
  3. Move cursor on above line.
  4. See error.

Expected behaviour
No error when navigating and executing requests.

Version information

  • OS: mac
  • Neovim
NVIM v0.5.1
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/tmp/neovim-20211103-3501-1gz0ofb/neovim-0.5.1/build/config -I/tmp/neovim-20211103-3501-1gz0ofb/neovim-0.5.1/src -I/usr/local/include -I/tmp/neovim-20211103-3501-1gz0ofb/neovim-0.5.1/deps-build/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.sdk/usr/include -I/usr/local/opt/gettext/include -I/tmp/neovim-20211103-3501-1gz0ofb/neovim-0.5.1/build/src/nvim/auto -I/tmp/neovim-20211103-3501-1gz0ofb/neovim-0.5.1/build/include
Compiled by brew@BigSur

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.1_1/share/nvim"
  • Treesitter
health#nvim_treesitter#check
========================================================================
## Installation
  - OK: `tree-sitter` found  0.20.0 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v17.0.1 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl" }
  - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - javascript     ‚úì ‚úì ‚úì ‚úì ‚úì 
  - typescript     ‚úì ‚úì ‚úì ‚úì ‚úì 
  - c              ‚úì ‚úì ‚úì ‚úì ‚úì 
  - http           x . . . . 
  - bash           ‚úì ‚úì ‚úì . ‚úì 
  - dockerfile     ‚úì . . . ‚úì 
  - vim            ‚úì ‚úì . . ‚úì 
  - nix            ‚úì ‚úì ‚úì . ‚úì 
  - rust           ‚úì ‚úì ‚úì ‚úì ‚úì 
  - yaml           ‚úì ‚úì ‚úì ‚úì ‚úì 
  - python         ‚úì ‚úì ‚úì ‚úì ‚úì 
  - cmake          ‚úì . ‚úì . . 
  - css            ‚úì . ‚úì ‚úì ‚úì 
  - html           ‚úì ‚úì ‚úì ‚úì ‚úì 
  - lua            ‚úì ‚úì ‚úì ‚úì ‚úì 
  - cpp            ‚úì ‚úì ‚úì ‚úì ‚úì 
  - json           ‚úì ‚úì ‚úì ‚úì . 

 Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

The following errors have been detected:
  - ERROR: http(highlights): .../0.5.1_1/share/nvim/runtime/lua/vim/treesitter/query.lua:161: query: invalid node type at position 1

Additional context
Both http,json parsers installed

External files import does not work any longer

Something is broken with the external files.

E.g when trying the file `tests/external_file/post_create_user.http" the filename looks strange and is thus not recognized to be a file (which should be prefixed with @ in the curl call)

curl -sSL -D /tmp/plenary_curl_47f448ac.headers --compressed -X POST -H Content-Type: application/json --data-raw /./user.json https://reqres.in/api/users

Crashes neovim sometimes

Hi!

Sometimes, when running :lua require("rest-nvim").run(), my entire neovim crashes and leaves my terminal in a funky state.

image

I am not sure exactly what is happening here 😅

Dropbox link to the macOS crash report: https://www.dropbox.com/s/r9qe4kfg3skgcfj/nvim-crash-report.txt?dl=0

neovim version
NVIM v0.5.0
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/mitchellhanberg/.asdf/downloads/neovim/ref-stable/build/config -I/Users/mitchellhanberg/.asdf/downloads/neovim/ref-stable/src -I/Users/mitchellhanberg/.asdf/downloads/neovim/ref-stable/.deps/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk/usr/include -I/usr/local/opt/gettext/include -I/Users/mitchellhanberg/.asdf/downloads/neovim/ref-stable/build/src/nvim/auto -I/Users/mitchellhanberg/.asdf/downloads/neovim/ref-stable/build/include
Compiled by [email protected]

Features: +acl +iconv +tui
See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/share/nvim"

Run :checkhealth for more info

Failed to execute the run method

Thank you for making this amazing plugin.

I'm getting this error while testing with basic_get.http
image

Here is my config

  use {
    "NTBBloodbath/rest.nvim",
    requires = { "nvim-lua/plenary.nvim" },
    config = function()
      local nnoremap = cko.nnoremap
     
      nnoremap { "<LocalLeader>rx", "<Cmd>lua require('nvim-rest').run()<CR>" } 
      require("rest-nvim").setup {
        -- Open request results in a horizontal split
        result_split_horizontal = false,
        -- Skip SSL verification, useful for unknown certificates
        skip_ssl_verification = true,
        -- Highlight request on run
        highlight = { enabled = true, timeout = 150 },
        -- Jump to request line on run
        jump_to_request = false,
      }
    end,
  }

parsing newlines

Hey, I'm running into some issues with newlines. For example when the response looks something like this:

{
    "a": "\n"
}

then I believe jq breaks somewhere along the way, since I get parse error: Invalid string: control characters from U+0000 through U+001F must be escaped at line 2, column 1.

Otherwise a really neat project 😉

Trying to setup options in httpResult buffer

Hi, nice plugin!

I'm trying to change the foldmethod option for httpResult buffer with different strategies:

Creating a file in stdpath("config")/ftplugin/httpResult.vim (or after/ftplugin/httpResult.vim) with setlocal foldmethod=indent (and verifying that is executed, with :scriptnames)

Adding an autocommand with autocmd FileType httpResult set foldmethod=indent

The only way I could make it happen was modifying the plugin source code:

diff --git lua/rest-nvim/curl/init.lua lua/rest-nvim/curl/init.lua
index 7de0b9c..10fb302 100644
--- lua/rest-nvim/curl/init.lua
+++ lua/rest-nvim/curl/init.lua
@@ -36,6 +36,7 @@ M.get_or_create_buf = function()
   vim.api.nvim_buf_set_name(new_bufnr, tmp_name)
   vim.api.nvim_buf_set_option(new_bufnr, "ft", "httpResult")
   vim.api.nvim_buf_set_option(new_bufnr, "buftype", "nofile")
+  vim.api.nvim_set_option("foldlevelstart", 1)
 
   return new_bufnr
 end
@@ -98,6 +99,7 @@ local function create_callback(method, url)
       vim.cmd(cmd_split .. res_bufnr)
       -- Set unmodifiable state
       vim.api.nvim_buf_set_option(res_bufnr, "modifiable", false)
+      vim.api.nvim_win_set_option(vim.fn.bufwinid(res_bufnr), "foldmethod", "indent")
     end
 
     -- Send cursor in response buffer to start

Any ideas how this could work?

Even better would be if I could use json treesitter highlighting and folding in the httpResult buffer, but I guess it would be more difficult (making a httpResult treesitter parser and inject the json parser).

Thank you.

Selene lint action broken

Selene always complains about an unknown goto

error[parse_error]: unexpected token `goto`
    ┌─ lua/rest-nvim/init.lua:183:4
    │
183 │             goto continue
    │             ^^^^ expected 'end'

This is a known issue (Kampfkarren/selene#224)

Not Working

I can't get this plugin to work.
I use packer with the latest neovim stable release.
I am neither getting the syntax highlight nor the keymaps to commands are doing anything

Bug report: rest.nvim is not ignoring all comment lines

As the title says, rest.nvim is not currently ignoring all the commented lines in the http files, as I said in #20

http files uses # for comments and rest.nvim is supposed to ignore them although currently only the commented headers are ignored.

Does not work on Windows

Hi, I have tried to run the plugin from under the Git bash for Windows (curl is available there). When run even with the simplest test example:

POST https://reqres.in/api/users

Content-Type: application/json
{
  "name": "morpheus",
  "job": "leader"
}

I am getting these errors:

E5108: Error executing lua [string ":lua"]:1: [rest.nvim] Failed to perform the request.
Make sure that you have entered the proper URL and the server is running.
Error executing luv callback:
...ata\Local\nvim\plugged\plenary.nvim\lua\plenary\path.lua:571: ENOENT: no such file or directory: /tmp/plenary_curl_cb9c41a5.headers

I think the first one is thrown because the response is empty, and it's empty because plenary fails to create (or read) from the file it creates when running curl (see here: https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/curl.lua#L63). Should I file an issue against plenary?

Does not work with json-formatted POST-request

I am trying to use this to make a POST-request, but it does not work. When the request reaches the server, the body is not valid json, and is not able to be loaded with json.loads. The same thing is working with postman.

I could not manage to find out if it's this plugin or plenary that does not work. (Or if I am just doing it wrong). I managed to get it working with a GET-request.

I am trying with this request:

POST http://localhost:8000/api/login/

HEADERS {
    "Content-Type": "application/json"
}

BODY {
    "email": "[email protected]",
    "password": "test"
}

Feature request: Option to filter out headers in response

Hi, I was trying out this plugin for the first time and it is very useful :)

It would be nice if the headers of the response can be omitted in some way. I couldn't find any documentation on this atm so I assume it isn't implemented (correct me if I'm wrong 😅 ).
Some ideas:

  • Config option to specify the headers you want
  • Default "minimal" headers. Eg: response code, content-type and charset
  • new command that runs taking this config into consideration vs the normal one that returns everything

And talking about commands, it would be useful to me to have also commands, instead of just <Plug> mappings. I can create my own commands using those and execute but other people might have a similar workflow to mine

:RestNvim not available.

Hi!
I have try to install rest.nvim plugin on nvim 0.5, however it doesn't work. There are no errors on nvim start but if I type :RestNvim there isn't.

I just try to follow the recomendations in the README. What I have in init.vim:

lua require('plugins')

and lua/plugins.lua

return require('packer').startup(function()
  use 'wbthomason/packer.nvim'
  use {
	 "NTBBloodbath/rest.nvim",
	 requires = { "nvim-lua/plenary.nvim" },
	 config = function()
	   require("rest-nvim").setup({
	     -- Open request results in a horizontal split
	     result_split_horizontal = false,
	     -- Skip SSL verification, useful for unknown certificates
	     skip_ssl_verification = false,
	     -- Highlight request on run
	     highlight = {
		enabled = false,
		timeout = 150,
	     },
	     -- Jump to request line on run
	     jump_to_request = false,
	   })
	 end
	}
	end
	)

Thanks!

[Feature request] Support mode for env variables.

Nice work! This is the restclient I'm looking for a long time.

Here is a common case when I test restful api in day to day work.

Define a env named {{base_url}} in both production and local modes. So I could switch to local to test the code in local server, and switch to prod after deployment.

The {{base_url}} may looks like this.

In production mode, base_url is http://xyz.abc/api/v1.0/something, and in local mode base_url is http://localhost:8080.

If rest.nvim could support this, I could replace my rest client for good.

Multiple env vars in a line causes executing error

POST https://httpbin.org/post
Content-Type: application/x-www-form-urlencoded

a={{VAR_1}}&b={{VAR_2}}

message:

E5108: Error executing lua .../Nil/.vim/plugged/rest.nvim/lua/rest-nvim/utils/init.lua:74: bad argument #2 to 'gsub' (string/function/table expected)

External files: No variable substitution

Currently, there is no variable substitution for external files.

In order to implement this, the original file cannot be passed to curl anymore. Perhaps the easiest way to implement is to read the file and do the rest as with local bodys.

Cannot use nested JSON objects

E5108: Error executing lua Vim:E474: Trailing comma: }

POST https://reqres.in/api/users

Content-Type: application/json

{
    "name": "morpheus",
    "job": "leader",
    "hello": {}
}

Feature request: Adding snippets

Hello. Can you please add some snipetts for .http files to the friendly snippets or something like this snippet collection plugin?

Looking for maintainers

Hey, as you can see rest.nivm is growing and maturing by a lot, and that's pretty awesome!

But I can't be here all the time to manage issues and PRs and that's not a big deal :(

That's why I opened this issue, we're looking for maintainers to handle these things too!

I'll maybe not reply today since I'll not be at home but I'll be glad to reply when I come back :)

Regards!

Error when making the most basic GET request

Hi, my test.http have the following line: GET http://localhost:5000/items , when I run the request I get this:
E5108: Error executing lua ...te/.config/nvim/plugged/rest.nvim/lua/rest-nvim/init.lua:251: Argument "start" is higher than "end"

Treesitter parser reinstalled

Hi there,

every time :TSUpdate gets executed html parser (set up as per README) gets reinstalled even though there probably were no updates. Do you think this can be fixed somehow? Or perhaps should this parser be added to nvim-treesitter/nvim-treesitter which would simplify installation process for this plugin as well?

JSON syntax highlighting

Great new plugin!

I was wondering if it would be possible to have proper syntax highlighting for the JSON responses, possibly also the request body?

I am not really familiar with Vim's regex-based syntax highlighting, I've just had a quick look, but it seems to be highlighting everything in one color at the moment.

Perhaps we could even look into treesitter if that's an option (one can dream).

URLEncode

hello 🤚 ,

when using "?q=[1,2,3]" - it fails to load.
i expect that, [1,2,3] needs to be encoded into q=%5B1%2C2%2C3%5D before being sent.

i love this project ❤️ its like postman in vim - vimMan!

Command/binding to copy request as curl

Would be nice to share with other people as a curl command, and not just printing it for inspection.
I noticed that the curl command is including some headers from plenary. Would it be posible to keep this to the simplest for this functionality?
Thanks! :)

Feature request: preview the API request

Hi, me again:). It would be nice to be able to see what curl command has been run - either by default, or with some option to run(), like 'verbose=True' (it can also be some formatted opts table passed to curl). It will help to make sure that the headers and data were parsed correctly. I have spent some time figuring out why the headers were not picked up correctly (because of a # comment line, that seem not to be accepted), but I couldn't figure out what is the request structure.

Btw. is there any accepted way of commenting the http file?

Error parsing bug

Hello. I faced up with parsing error bug.
Look at the response of the rest.nvim
image
and now look at the response of the same request in insomnia:
image

problematic single quotes

I came across another thing. Something like this: a single single-quote

{
  "contents": "'\n"
}

throws zsh:1: unmatched "

When there is an equal number of single quotes they just get removed in the result window. Doesn't seem to happen with double quotes or backticks.

Commented headers go through to the call

Hi, it seems that the comment line is ignored if does not have colon inside - this means that commenting out headers stopped working. I guess it is about order of parsing actions. The line should be ignored completely if it starts with #.

How to use header Authorization: Bearer token

Hi, thanks for clean and fast plugin for API testing. I am trying to authorize with the Bearer token (in Postman it works), but I'm not sure it is possible with this plugin (or more generally plenary.curl). I am getting "Invalid/expired token" error from my API. The source code seems to be written with login:password authorization in mind. Am I missing something?

Here is how I specify the header in the http file:

GET <my_url>
Authorization: Bearer <my token>

BUG: send wrong request body if the last http with a header

GET https://httpbin.org/get

POST https://httpbin.org/post
X-API-KEY: 1

run the second http, the response is:

POST https://httpbin.org/post

HTTP/1.1 200 OK

HTTP/2 200 
date: Thu, 19 Aug 2021 06:14:33 GMT
content-type: application/json
content-length: 550
server: gunicorn/19.9.0
access-control-allow-origin: *
access-control-allow-credentials: true

{
  "args": {},
  "data": "",
  "files": {},
  "form": {
    "GET https://httpbin.org/getPOST https://httpbin.org/postX-API-KEY: 1": ""
  },
  "headers": {
    "Accept": "*/*",
    "Accept-Encoding": "deflate, gzip",
    "Content-Length": "68",
    "Content-Type": "application/x-www-form-urlencoded",
    "Host": "httpbin.org",
    "User-Agent": "curl/7.64.1",
    "X-Amzn-Trace-Id": "Root=1-611df6c9-77835905478000061b24e381",
    "X-Api-Key": "1"
  },
  "json": null,
  "origin": "42.3.18.110",
  "url": "https://httpbin.org/post"
}

migration from vim-rest-console

I come from https://github.com/diepm/vim-rest-console which I liked but this plugin looks more promising (treesitter support + I prefer hacking on lua).

What I like about vim-rest-console is that I can have several requests in the same file + I dont have to prefix the request with a variable let's say {{ URL }}/.health.
Is that possible with rest.nvim ? Or should I prefix all my requests with {{URL}} ?

# use with vim-rest-console
# Hit the trigger key (<C-j> by default).
http://localhost:2000

modelid = 0d6cf41efd5b3b8f55d4feded55ca367fd8eea0f0eff9305e8fcaf6f7650188d
scoreid = 9b5da9bc6538e1c0e3f955b5f49fc478cd18d94d95cbce8d0e9d9b7cac849dcd

jobid = 410de781-34e0-53b5-855a-7bffcb3bce17
--


--
# Healthcheck
GET /.health

--
# Healthcheck
GET /openapi.json

Got error when trying to make request to subdomain of 5th level

Trying to make request to a domain with number of subdomains like https://api.bitbucket.aa.bb.ru but getting the following error:

E5108: Error executing lua ...rg/.config/nvim/plugged/rest.nvim/lua/rest-nvim/init.lua:251: Argument "start" is higher than "end"

Syntax highlight for {{URL}}, and global header

Hi, I have something like this in my http file:
image
Some issues/suggestions that I have:

  1. Syntax highlight only works if the request begin with http:// or https://. Could we have syntax highlight even if the env variable is at the beginning as well?
  2. It's nice that we have global header, so I don't have to repeat Jwt-Token every time (sometimes I have more headers, so you understand the inconvenient)

Thank you so much for your time!

Feature request: import system

Hello.
I want to create system for testing API. But it slightly anoying to past manually some data into each request file. E.g token
Is it possible to store variables in done file and just import it to request files?

E488: trailing characters

using the example from readme give me the error above, what I'm missing?

GET http://localhost:3000/foo

HEADERS {
    "Content-Type": "application/json"
}

Add indication for jq version

The JSON parsing did not work with jq version 1.5, maybe indicate the required version in the Readme.

Cheers, Jim

packer: opt=true causes rest.nvim to fail

I set up rest.nvim as an optional dependency like this:

    use({
        "NTBBloodbath/rest.nvim",
        requires = { "nvim-lua/plenary.nvim" },
        opt = true,
        ft = { "http" },
        config = function()
            require("rest-nvim").setup({
                result_split_horizontal = false,
            })
            vim.cmd([[
            au FileType http nmap <buffer> <silent> <C-j> <Plug>RestNvim
            ]])
        end,
    })

When I open a file, set the file type to http and press <C-j> I get the following error:

Error executing luv callback:
...site/pack/packer/start/plenary.nvim/lua/plenary/path.lua:614: ENOENT: no such file or directory: /tmp/plenary_curl_b3524790.headers

With opt=false everything works fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.