nanotee / sqls.nvim

Neovim plugin for sqls that leverages the built-in LSP client

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Show the query together with the result

tssm opened this issue · comments

Sometimes I run more than one complex query and after a while navigating their output may become hard if I forget which query corresponds to which output. Is it possible to include it above or after the result? Or even set it into a buffer variable? I'm trying to do it myself, but I'm not that familiar with the LSP API, and reading the code, it seems the query is extracted and executed by it without the plugin ever getting it, am I right? If so, I would appreciate any idea of how to proceed.

Thanks beforehand

it seems the query is extracted and executed by it without the plugin ever getting it, am I right?

Yup, I only send the range coordinates to the language server and let it handle the rest

Is it possible to include it above or after the result? Or even set it into a buffer variable?

They could be inserted in the table passed to nvim_buf_set_lines() (but really big queries should probably be cut off to avoid making the output too noisy). I think the hardest part is extracting a char-wise range from a buffer because Neovim doesn't have nvim_buf_get_text() yet

Thanks for the answer! I was thinking about long queries too. I know dadbod creates and alternate file that I was using to retrieve it, but now I'm more incline to print a reference to the query in the result buffer, something like /path/to/file:lnr:cnr, which, if I understand correctly, we already have. Does it sound like something you would be interested in getting implemented?

I know dadbod creates and alternate file that I was using to retrieve it

I had no idea dadbod did this, thanks for the tip!

Does it sound like something you would be interested in getting implemented?

Definitely! That sounds like a nice UX improvement

It is not documented, I found it on a comment on the issue tracker if I remember correctly. You can take the name of a dadbod buffer, change its extension to .sql and on that file you will find the query. I used it to show the query in the status line, but as you mentioned, long queries get problematic. I'll give a try to a "jump to query in the previous window" feature