hudclark / grpc-nvim

Grpc Client for Neovim
MIT License
31 stars 1 forks source link

Support arguments with spaces #1

Closed antosha417 closed 1 year ago

antosha417 commented 1 year ago

Hey! Very like idea of the plugin, great job! I'm using https://github.com/rest-nvim/rest.nvim for the similar purpose but for http requests.

I'm trying to get it working with Authorization header and get an error. I'm executing :Grpc command on a line that looks like: grpc -H "Authorization:Bearer blablabla" localhost:443 com.actions.v2.Service/List

And see output:

// grpcurl -H "Authorization:Bearer blablabla" localhost:443 com.actions.v2.Service/List
Too many arguments.
Try 'grpcurl -help' for more details.

However if I copy the first commented line from output and execute it in terminal I see the response.

Can we add a support for headers such headers?

Also would be cool to somehow specify this header only once and have it on every request. Can be done per buffer variables I think. So I would not have to specify this header on each query. What do you think?

antosha417 commented 1 year ago

Another unrelated question: How do you get syntax highlighting in grpc file? I don't get any.

antosha417 commented 1 year ago

I took a bit closer look at this plugin and found the problem. In read-request-args arguments are separated by space. But my argument should contain space after the word Bearer.

I think we can use bash treesitter parcer to parce arguments. It seems to work fine for this situation

Screen Shot 2023-01-07 at 14 38 17
antosha417 commented 1 year ago

@hudclark what do you think about it? I think I can open a pr for this one

hudclark commented 1 year ago

@antosha417 Sorry for my late reply!

That sounds like a great patch to make. If you put up a PR, I would be happy to review & merge it. Thank you

hudclark commented 1 year ago

Another unrelated question: How do you get syntax highlighting in grpc file? I don't get any.

I have not written grpc-nvim specific syntax highlighting yet, but I if you set the filetype of the .grpc file to javascript, you can get reasonable syntax highlighting.

antosha417 commented 1 year ago

Hey @hudclark! How you doing? I created a simple tree sitter grammar for *.grpc files. I wanted to combine bash and json treesitter grammars but didn't find a way to do it. So I extended bash grammar and copied json into it. We can now use it for syntax highlighting and arguments parsing.