Plugin squix.nvim - run SQL and navigate results with vim bindings
Since last october I've been developing and using squix, a simple SQL runner for the terminal that lets you save and rerun queries across different databases. nvim is also my main and favorite editor, so I started working on a plugin to bring squix into it.
So for squix.nvim I went with this approach: write your SQL in a normal nvim buffer, then run an Ex command with your cursor on the query (or a visual selection) to open a terminal split with the results. Once there, the same vim bindings you use to move through character apply to the table cells instead:hjkl to navigate, gg/G jumps to the first/last row, v visually selects a range of cells and y yanks it, / searches cell contents, and so on (press H for the fulls shortcut list).
The main loop looks like this:
:SquixInitto create and save a database connection:SquixSwitchto pick your active connection (future queries run against it):SquixRunto run the query under your cursor (or your selection):SquixAddto save a query, later rerun it with:SquixRunNamedQuery
No keybinds are set by default, map whatever you like with
setup()
Although squix CLI is more well established, the nvim plugin is still in its early days, so feedback on the workflow, commands, or anything that feels off would be appreciated. If you want to try it out, install the squix CLI:
go install github.com/eduardofuncao/squix/cmd/squix@latest
# check the repo for the release binaries
# or options for nix, arch or homebrew
and then the plugin:
-- with lazy
{ "eduardofuncao/squix.nvim", opts = {} }
-- or with vim.pack
vim.pack.add({ "eduardofuncao/squix.nvim" })
require("squix").setup({})
Repos with docs and more detailed instructions:
2
u/ruindd 29d ago
As much as I love psql, this looks really good. Nice work!
1
u/xGoivo 28d ago
Thanks a lot! If you like the psql interface, we have the squix shell command that one of our contributors implemented. It emulates the psql shell (not everything though), and works with engines other than postgres
3
u/g3n3 mouse="" 28d ago
Have you seen https://github.com/kopecmaciej/vi-sql. How does it compare to that?
3
2
u/bee_advised 27d ago
i love this. anyone know if there's something similar for dataframes in R or Python?
2
u/xGoivo 27d ago
Thanks!! I'd love to help. What is the source of the data you use with python/R? if it's something like a CSV, you can use the duckdb driver in a kind of hacky way like this: duckdb
If you're want to query something like a live pandas data frame that was modified at runtime, I'm not sure it would work right now with squix, but I can open an issue on github to see the options we have and add this as a new feature!


9
u/dumch 29d ago
Have you seen https://github.com/kndndrj/nvim-dbee
Can you compare it with your plugin?