rest-nvim / rest.nvim

A fast Neovim http client written in Lua
GNU General Public License v3.0
1.52k stars 141 forks source link

The rest nvim is not working with default configuration #375

Closed Demianeen closed 4 months ago

Demianeen commented 5 months ago

After update rest.nvim stopped working for me and I found that it don't work for me even with minimal repro of default setup:

-- lazy.nvim default repro
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
    vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    -- default setup from website
    {
        "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,
    },
    {
        "nvim-treesitter/nvim-treesitter",
        opts = {
            ensure_installed = { "lua", "xml", "http", "json", "graphql" },
        },
    },
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Take a look:

https://github.com/rest-nvim/rest.nvim/assets/51330172/5c1ed09d-510f-469f-8ef3-30bffb39210c

nvim version:

NVIM v0.10.0-dev-3007+ga736e845a
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

Have I done something wrong?

tatumroaquin commented 5 months ago

This is also the case for me, but I found a work around for my system. I looked at the Neovim :checkhealth rest-nvim entries for rest-nvim and manually installed all the dependencies mentioned in the opts table using luarocks.

cd $HOME
luarocks --local --lua-version=5.1 install xml2lua
luarocks --local --lua-version=5.1 install lua-curl
luarocks --local --lua-version=5.1 install mimetypes

This should create a directory in your home called ~/.luarocks and neovim should not emit any more errors afterwards.

Because I use Arch Linux my Lua version is updated to 5.4 but I think this plugin requires Lua version 5.1 according to the error logs. Not sure though.

Error: Failed installing dependency: https://luarocks.org/lua-curl-0.3.13-1.src.rock - Build error: Lua header lua.h found at /usr/include does not match Lua version 5.1. You can use luarocks config variables.LUA_INCDIR <path> to set the correct location.

Demianeen commented 5 months ago

Thanks! I checked the health of rest.nvim and found that it installs xml2lua:


==============================================================================
rest-nvim: require("rest-nvim.health").check()

Installation ~
- OK Found `luarocks` installed in your system
- OK Found Luarocks PATHs in your Neovim's Lua `package.path`
- OK Dependency `nvim-treesitter` was found
- OK Dependency `mimetypes` was found
- OK Dependency `xml2lua` was found
- OK Dependency `nvim-nio` was found
- OK Dependency `lua-curl` was found
- OK Tree-sitter `http` parser is installed

Configuration ~
- OK No unrecognized configuration options were found
- OK Formatter for `html` is set to `tidy` and rest.nvim found it in your system
- OK Formatter for `json` is set to `jq` and rest.nvim found it in your system

But when I make a request I still get the same error:

GET http://localhost:8080/
HTTP/1.1 200 OK

#+RES
Config: missing or malformed argument for option: show-body-only
Error: Can't open "auto"

#+END

There was a similar issue but they solved it by manually setting luarocks to install. Which I also do in the configuration above.

Do you know what I can look into next to solve the issue?

tatumroaquin commented 5 months ago

Sorry I don't know, so far the plugin works perfectly for me. I tried to do the same query as you, but with https://google.com

GET https://www.google.com

The response was OK, so I'm not sure if this is still a problem relevant to the plugin itself. Maybe it's related the web app your interfacing with, but I still haven't done any POST requests with JSON bodies so, I don't know.

2024-05-01_15 33 46

Kryvonis commented 4 months ago

Get the same issue, just fresh install with lazyvim. Healthcheck also give

rest-nvim: require("rest-nvim.health").check()
Installation ~
- OK Found `luarocks` installed in your system
- OK Found Luarocks PATHs in your Neovim's Lua `package.path`
- OK Dependency `mimetypes` was found
- OK Dependency `nvim-treesitter` was found
- OK Dependency `xml2lua` was found
- OK Dependency `nvim-nio` was found
- OK Dependency `lua-curl` was found
- OK Tree-sitter `http` parser is installed

Configuration ~
- OK No unrecognized configuration options were found
- OK Formatter for `json` is set to `jq` and rest.nvim found it in your system
- OK Formatter for `html` is set to `tidy` and rest.nvim found it in your system

And yes, the same response.

image
Kryvonis commented 4 months ago

Ok, fixed for me by updating tidy

brew update
brew install tidy-html5
Demianeen commented 4 months ago

@Kryvonis, fixed it for me!