A Modern SQL UI for NeoVim written in Lua emphasizing speed and simplicity, turning NeoVim into a full-fledged SQL IDE.
Currently supported DBMS:
- SnowFlake
- PostgreSQL
- MySQL
- MariaDB
- SQLite
{
'xemptuous/sqlua.nvim',
lazy = true,
cmd = 'SQLua',
config = function() require('sqlua').setup() end
}
Plug 'xemptuous/sqlua.nvim'
use "xemptuous/sqlua.nvim"
To launch SQLua quickly, consider adding an alias to your shell config
alias nvsql="nvim '+SQLua'"
Neovim 0.10.0+
Based on the DBMS' used, different cli tools will be required.
PostgreSQL
: psqlMariaDB
: mariadbMySQL
: mysqlSnowflake
: snowsqlSQLite
: sqlite3
The connections.json
file is an array of json objects contains all connection information. The required keys are name
and url
.
Specific formatting is required for certain databases. Here are some samples of entries for connections.json
based on dbms:
PostgreSQL
{
"name": "mydb",
"url": "postgres://admin:pass@localhost:5432/mydb"
}
MariaDB
{
"name": "mydb",
"url": "mariadb://admin:pass@localhost:5432/mydb"
}
MySQL
{
"name": "mydb",
"url": "mysql://admin:pass@localhost:5432/mydb"
}
Snowflake
snowsql client will handle all connections
{
"name": "mydb",
"url": "snowflake"
}
SQLite
{
"name": "mydb",
"url": "/path/to/database/file.db"
}
You can override the default settings by feeding the table as a table to the setup() function:
{
-- the parent folder that databases will be placed, holding
-- various tmp files and other saved queries.
db_save_location = "~/.local/share/nvim/sqlua/",
-- where to save the json config containing connection information
connections_save_location = "~/.local/share/nvim/sqlua/connections.json"
-- the default limit attached to queries
-- currently only works on "Data" command under a table
default_limit = 200,
-- whether to introspect the database on SQLua open or when first expanded
-- through the sidebar
load_connections_on_start = false,
keybinds = {
execute_query = "<leader>r",
activate_db = "<C-a>"
}
}
Open SQLua with the command :SQLua
Edit connections with :SQLuaEdit
Queries run in the editor buffers will use the currently active db, which will be highlighted on the sidebar. The desired connection
can be set to "active" using the activate_db
keybind, normally Ctrl+a
By default, the keymap to execute commands is set to <leader>r
, acting differently based on mode:
<leader>r (normal mode): Runs the entire buffer as a query. <leader>r (visual mode): Runs the selected lines as a query. (visual, visual block, and/or visual line)
Upon executing a query, the results will be shown in a results buffer.
Note: template DDL statements do not need to set the active DB; i.e., they will always be run based on the parent table, schema, and database.
Each database will have a Queries
folder which corresponds to the directory named after the connection, found in ~/.local/share/nvim/sqlua/
Files can be added and deleted using a and d inside this node of the sidebar tree.
o will toggle the fold for the current level, expanding the node under the cursor, or collapsing the direct parent.
O will collapse the entire database connection in the sidebar.
This project is actively being developed, and will hopefully serve as NeoVim's full-fledged SQL IDE moving forward, eliminating the need for long load times and multiple vim extensions.
- Create functional connection for psql
- Be able to execute queries from buffer
- Create a minimal UI structure
- Make a functional NvimTree-sidebar for navigating the DB
- Implement multiple db's available in sidebar at once (easily jumping between them)
- Implement queries, ddl, and other template queries into the sidebar tree.
- Create asynchronous jobs for queries and connections.
- Create db-specific sql files to be stored in sqlua/dbs/ folder
- Add default limit functionality
- Implement Nvim-Tree QoL features into sidebar
- Add DB Inspection + nvim-cmp completions
- Implement connection sessions and active connections
- Add an option for "fancier" results pane output
- Implement syntax highlighting for dbout similar to other SQL IDE's (datetime, numbers, strings, null, etc.)
- Include fancy ui functionality to make SQLua sexy