kristijanhusak / vim-dadbod-ui

Simple UI for https://github.com/tpope/vim-dadbod
MIT License
1.48k stars 86 forks source link

Hooks support #202

Open alondahari opened 11 months ago

alondahari commented 11 months ago

I was wondering if we could add support for custom callbacks that could run on certain events, hooks style. My desire is to load up the connection string from my password manager and create a tunnel when I try to connect to the db. What do you think?

neilsimp1 commented 2 months ago

Being able to run some arbitrary command like https://stackoverflow.com/a/1968446/4265939 before connecting would be really useful.

kristijanhusak commented 2 months ago

I recently added an ability to run a function for a connection. You should be able to do anything in the function and just return the connection string. You can see the example here https://github.com/kristijanhusak/vim-dadbod-ui#via-gdbs-global-variable

neilsimp1 commented 2 months ago

Hmm.. I was hoping to be able to do it from https://github.com/kristijanhusak/vim-dadbod-ui?tab=readme-ov-file#via-dbuiaddconnection-command but this should work for what I needed. Thank you!

kristijanhusak commented 2 months ago

@neilsimp1 how would you suggest it works from the connection? Assuming that i have to store it as a string, what would you put inside of it?

neilsimp1 commented 2 months ago

I see your point, it would not work well as part of a Connection String. It would have to some other property stored alongside the connection string. Some other property that could hold arbitrary commands to execute. I would certainly understand if you viewed this as out of scope, though.

For background, I am transitioning from MySql Workbench to this. Workbench allowed storing Connection profiles as a DB connection over an SSH tunnel. That's where I was coming from mentally and how I ended up finding this Issue.