Closed weirdan closed 5 months ago
Agree, it would be super nice!
Minor update: I probably won't find the time to implement something like this anytime soon - and I have enough work with core already.
>>BUT<< in the refactor/first
branch, which should be merged soon, there is an api exposed and it should enable an "external" plugin author to implement something like this.
Update: @MattiasMTS started working on completion extension: https://github.com/MattiasMTS/cmp-dbee
Once complete, let's add something to the docs to point people to the extension.
The cmp-dbee has now been tested a bit, when I finally had some free time from work. Sorry for the delay 😬. Feel free to try it out and open any issue you find'! Hopefully we can make it an awesome plug-in woo 😄
@MattiasMTS , I worked with it for several minutes, looks fine.
The only thing I noticed is that I have to use schema.
For example, Intellij Idea DB plugin (as well as psql) gives completion:
select * from de | <it suggests 'device'>
You cmp-dbee plugin suggests public
. If you write
select * from de | <it suggests nothing>
But if you write:
select * from | <it suggests 'public'>
select * from public.de | <it suggests 'device'>
I used Postgres, OSX: 13.6.2 (22G320) NVIM v0.9.5
Thanks for the feedback @D00mch !! Super glad you worked with it for a while 🌟 I've some stuff that I need to add, e.g. availability, lazy loading, testing, docs, heh.. So, I'm extremely grateful for early-testers 🤝
The default out of the box suggestion is indeed schemas (or aliases/cte if they exist). We can for sure extend this to also include models (=tables/views/functions) directly out of the box as well. However, the main reason why I didn't add this in the first place is because I like explicitly over implicitly (heh..). For example, the column completion is done by triggering the Columns
method, and for postgres adapter it needs the schema (see (https://github.com/kndndrj/nvim-dbee/blob/master/dbee/adapters/postgres_driver.go#L39-L47)).
However, if we find the table -> we can also find the schema (thanks to the nice interface done by @kndndrj 😉 ). So, if this is a feature you would like to have, i.e. having models suggested out of the box as well, I can try to carve out some time for it.
Feel free to +1 this comment or open an issue on the repo for this 😄 Again, thanks for the testing! ✋ 5️⃣
I've now added a suggestion on table/views/functions out of the box with a little twist that I think is awesome. Here is the PR https://github.com/MattiasMTS/cmp-dbee/pull/15. Feel free to try it out!
EDIT at @D00mch
Hey, since @MattiasMTS created the extension, I think this issue can be closed.
I mentioned the extension in the README.
Further discussion can be had in extension's repo.
With the knowledge of the DB structure
nvim-dbee
has, it would be nice if it could expose it as a completion source (e.g. fornvim-cmp
), similar to https://github.com/kristijanhusak/vim-dadbod-completion