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
{
'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'"
To use, require the setup:
:lua require('sqlua').setup(opts)
After the first time running the setup() function, a folder for SQLua will be created in the neovim data directory (~/.local/share/nvim/sqlua/)
The connections.json
file here will contain your DB URL's, as well as friendly names to call them by.
Note:
for SnowFlake, you will need the snowsql
client. In the connections.json
file, use snowflake
for both the name and url, and ensure all configuration is done in your snowsql config file.
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>"
}
}
Current commands include:
:SQLua <dbname(s)> - launches the SQLua UI with the listed DB's
:SQLuaExecute - (executed by keybind in buffer) executes the buffer (in normal mode) or selection (in a visual mode)
:SQLuaAddConnection - prompts the user to add a connection to the connections file
After using :SQLuaAddConnection
you will be prompted to enter a database url and a name for the database.
The url should follow standard jdbc url format:
rdbms://[user][:password]@[host][:port][/db][?args*]
The url will be parsed to be used with the appropriate CLI command through args as necessary.
The name given will be shown in the sidebar, and will not be used to connect to the specified db.
Alternatively, you can manually edit the connections.json
file.
The sidebar navigator can be used to explore the DB and its various schema and tables, as well as creating various template queries.
The editor buffer(s) are used to run queries.
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.
The DB used will be highlighted and set to the "active" DB. Using the activate_db
keybind will change which DB is considered the active one for each query.
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.
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
- Implement Nvim-Tree QoL features into sidebar
- Add DB Inspection + nvim-cmp completions
- Implement active connection variables to be set for the connections' lifetimes
- Add default limit functionality
- 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