rest-nvim / rest.nvim

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

showing curl command config not working #333

Closed JanikvA closed 7 months ago

JanikvA commented 7 months ago

Hi,

I have recently upgraded to the latest version and the configuration which shows the actual curl command that is run in the background is not working anymore.

my config in lazy:

return {
  {
    "vhyrro/luarocks.nvim",
    priority = 1000,
    config = true,
    opts = {
      rocks = { "lua-curl", "nvim-nio", "mimetypes", "xml2lua" }, -- Specify LuaRocks packages to install
    },
  },
  {
    "rest-nvim/rest.nvim",
    ft = "http",
    dependencies = { "luarocks.nvim" },
    -- keys = {
    --   { "<leader>rc", "<cmd>Rest run<cr>", decs = "Run request under the cursor" },
    -- },
    config = function()
      require("rest-nvim").setup({
        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,
            },
          },
        },
        highlight = {
          enable = true,
          timeout = 750,
        },
        keybinds = {
          {
            "<leader>rc",
            "<cmd>Rest run<cr>",
            "Run request under the cursor",
          },
        },
      })
    end,
  },
}

When I set everything to false in the result.behavior.show_info section nothing changes so this seems broken? (Note: When I e.g. change result.split.horizontal to true the result window is split horizontally instead of vertically so my config seems to be loaded correctly.)

NTBBloodbath commented 7 months ago

Hi there!

Please check out :h rest-nvim-usage-commands or removed features section from my blog post.


tl;dr

As seen in the plugin's README, we no longer use plenary.nvim's cURL implementation (which was buggy and error-prone). Now we use native bindings to libcURL, so we call cURL directly at the code level instead of calling the curl command like a wrapper. This change prevents that feature from existing anymore, since it is totally impossible because we no longer invoke the curl command.

JanikvA commented 7 months ago

That's unfortunate. it was useful to send these curl commands to colleagues when debugging failing calls.

Anyway, thanks for the clarification!