rest-nvim / rest.nvim

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

Bug. The empty parameter still doesn't seem to work #371

Closed daniilrozanov closed 1 month ago

daniilrozanov commented 2 months ago

This issue relates to tree-sitter-http/pull/25.

I removed rest.nvim and :TSUninstall http, then install both again. Problem still here, query like

GET https://echo.free.beeceptor.com/api?page[number]=3&fields[available]&available (from pull request.txt) produces error

Error executing Lua callback: .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:114: attempt to index local 'req_node' (a nil value)
stack traceback:
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:114: in function 'traverse_request'
    .../share/nvim/lazy/rest.nvim/lua/rest-nvim/parser/init.lua:432: in function 'parse'
    ...al/share/nvim/lazy/rest.nvim/lua/rest-nvim/functions.lua:61: in function 'exec'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:44: in function 'impl'
    ...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:182: in function <...cal/share/nvim/lazy/rest.nvim/lua/rest-nvim/commands.lua:165>

TSPlayground for file with only this query gives

ERROR [0, 0] - [0, 82]
  method [0, 0] - [0, 3]
  scheme [0, 4] - [0, 9]
  host [0, 12] - [0, 35]
    identifier [0, 12] - [0, 35]
  path [0, 35] - [0, 39]
    identifier [0, 36] - [0, 39]
  ERROR [0, 40] - [0, 45]
    identifier [0, 40] - [0, 44]
    ERROR [0, 44] - [0, 45]
  query_param [0, 45] - [0, 54]
    key: key [0, 45] - [0, 51]
    ERROR [0, 51] - [0, 52]
      ERROR [0, 51] - [0, 52]
    value: value [0, 53] - [0, 54]
  ERROR [0, 55] - [0, 73]
    identifier [0, 55] - [0, 61]
    ERROR [0, 61] - [0, 62]
    identifier [0, 62] - [0, 71]
    ERROR [0, 71] - [0, 72]
  identifier [0, 73] - [0, 82]

Also, if i add another query after that, second query will be parsed like part of first one. Am i doing something wrong?

NTBBloodbath commented 2 months ago

Did you also update nvim-treesitter before updating the parser? That's odd as the HTTP parser tests are passing

Rasmus-Bertell commented 2 months ago

As @NTBBloodbath said, check that you have updated treesitter and the parser. I'm running treesitter commit b04ccbd and have http parser installed normally.

GET https://echo.free.beeceptor.com/api?page[number]=3&fields[available]&available
Accept: application/json

gives me the following syntax tree with :InspectTree

(request) ; [1:1 - 3:0]
 (method) ; [1:1 - 3]
 (target_url) ; [1:5 - 82]
  (scheme) ; [1:5 - 9]
  (host) ; [1:13 - 35]
   (identifier) ; [1:13 - 35]
  (path) ; [1:36 - 39]
   (identifier) ; [1:37 - 39]
  (query_param) ; [1:41 - 54]
   key: (key) ; [1:41 - 52]
   value: (value) ; [1:53 - 54]
  (query_param) ; [1:55 - 72]
   key: (key) ; [1:56 - 72]
  (query_param) ; [1:73 - 82]
   key: (key) ; [1:74 - 82]
 (header) ; [2:1 - 3:0]
  name: (name) ; [2:1 - 6]
  value: (value) ; [2:8 - 3:0]

Having multiple requests doesn't seem to have an effect, they are all parsed separately.

daniilrozanov commented 1 month ago

Yes, all work after update