Vim-db: Modern database interface for Vim
github.com
github.com
I follow his work since I started using Vim ~ 8 years ago, the absolute pinnacle for me being vim-fugitive, I can't live without it!
Personally, if I was looking for a DB integration with VIM, I'd be looking for an interactive prompt style buffer instead of per-command executions.
I don't really use and cli tooling for DB access and querying, now being able to use a vim pane as my query entry is really nice - no switching back and forth between various applications.
An interactive prompt would be pretty nice though, agree with that.
Given that constraint, I picked up Vim and have used it for the past 6 years. Tried Emacs at first, but it didn’t play well on Windows (not sure if user error!)
So I definitely encourage “reinventing the wheel” on multiple platforms, as long as the platform is popular enough. Competition doesn’t hurt.
The thing that would get me to use Emacs is a plugin implementing Neovim's remote editing protocol. Vim is an incredibly deep state machine, and no plugins that reimplement it get things exactly right.
If you love modal editing, as I do, you can use EVIL mode to emulate Vim quite well. I used Vim for years and switched within a month, most of the transition was in getting used to all the tools built into Emacs. Movement was identical, even things like text objects and Vim-surround work well.
The quality of Emacs packages are very high and almost always “just work”. And when you do have to read the documentation it’s very easy to find and understand.
Sublime Text has a plugin which implements the API; it runs full blown vim plugins.
.. .. I didn't realize the integration was that far along. I'll have to give Sublime another look.
My response is based largely on my workflow - I use VIM as one part of my development environment (ie the shell), not as a standalone IDE. Perhaps this is the biggest difference.
I know it's possible to automate further (to make vim talk to tmux and execute the bit of SQL under the cursor, for example), but it works well for me as is.
https://blog.carbonfive.com/2011/10/17/vim-text-objects-the-...
That's probably why I ended up with Emacs/Evil mode :)
https://www.emacswiki.org/emacs/SqlMode
For me SQL is editing and sending chunks of text fluently, that exactly where vim or emacs are at their best.
But I still can't quite get past the feeling that Emacs is a clunky sedan and Vim is a sleek sports car. Vim just feels a little bit nicer, faster, smoother.
I think you need to see a screencast to understand why this approach is such an improvement, for some reason it is hard to grasp at first.
But dbext is vimscript which is very hackable like anything else in vim. If you want to use multiple connections theres nothing stopping you from writing something like
nmap <leader>se1 to run the selection with connection profile #1
nmap <leader>se2 to run the selection with connection profile #2
and so forth
Especially when "modern" is in the title, one might expect more than just a wrapper of :DB commands. Given that both Vim 8 and Neovim have a :terminal, this might as well be a collection of shell functions; it'd also be more portable.
> given the ease of switching and copy-pasting between terminals, this seems superfluous.
This really makes me think you are a prime candidate for a plugin that can easily open an interactive prompt or make the whole copy, switch terminal, paste, copy response flow one command.
This is just repl-integration for db repls (interactive prompts if you prefer).
Many people are used to this workflow:
Open your editor, open a prompt in another terminal. Write the simple stuff in the prompt, the complex stuff in your editor and then copy/paste to the prompt. Write a simple query in the prompt that ends up pretty complex, so you copy it, switch to the editor and paste, fix it up then copy, switch to prompt and paste it back. Now you copy part of the query results, switch to editor and paste so you can extract some of the results for the next complicated query.
A lot of us know this workflow, an many of us aren't aware that what we are looking for is repl integration in the editor. Same workflow, goes like this: edit query, eval, edit again, eval, etc. It is not a different way of working, it is the same way but much better.
How do you know if you want this? If you use vim and set your readline config to use vi keybindings you want this. You already noticed that editing stuff in the prompt is worse than in vim, you just picked the wrong fix for that problem.
My problem with vim-integrated shells, prompts - anything inherently interactive except for editing itself - is that it's always worse. Be it performance, integration between vim and the interactive prompt, or an impedance mismatch between vim's modal editing and an interactive prompt's non-modal editing. I'd rather switch windows and use a native shell than a kinda-working shell in vim. Same with a DB prompt. Same with pretty much every other tool I pull up in the terminal.
Honestly, it's the same reason I don't use emacs with EVIL mode: it's not quite vim, and those speedbumps absolutely kill my "Flow". Any gains from a rich editing environment are lost (with interest) by trying to figure out how to get the non-editing part of that environment to behave correctly. And I even use emacs bindings in bash (no, not zsh or fish or...); because then when I go to remote servers, everything just works.
That's my opinion, at least.
This isn't a vim-integrated shell solution, it's a way to avoid those, for exactly the reasons you say. Repl integration isn't about embedding a prompt in your editor, it's about bypassing the interactive prompt because you already have a place to write and read text - an editor buffer. I should have used a different term obviously, that one is actually misleading.
Part of the reason I'm curious is I regularly do Clojure training and see this pattern over and over: "I don't like working that way, that sounds bad. [hours later it clicks] Oh! I see what you mean, this is great. This is the way I like working but easier! I thought you meant something different".
Looks pretty similar to yours. I definitely like that model of editing / execution.
Look at Amazon, aggressively trying to move away from Oracle yet still far away.
He only just released it today so there's time to add the others.
Odds are he built it to use the DBs he uses, now it's your turn to contribute back the adapter for the DB you use.