8000 GitHub - eric-hansen/sqlua.nvim: A SQL IDE and UI for NeoVim written in Lua. Inspired by vim-dadbod vim-dadbod-ui.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

eric-hansen/sqlua.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛢️ SQLua.nvim

A Modern SQL UI for NeoVim written in Lua emphasizing speed and simplicity, turning NeoVim into a full-fledged SQL IDE.

SQLua

Currently supported DBMS:

  • SnowFlake
  • PostgreSQL
  • MySQL
  • MariaDB
  • SQLite

Installation

Lazy

{
    'xemptuous/sqlua.nvim',
    lazy = true,
    cmd = 'SQLua',
    config = function() require('sqlua').setup() end
}

vim-plug

Plug 'xemptuous/sqlua.nvim'

Packer

use "xemptuous/sqlua.nvim"

To launch SQLua quickly, consider adding an alias to your shell config

alias nvsql="nvim '+SQLua'"

Requirements

Neovim 0.10.0+

Based on the DBMS' used, different cli tools will be required.

  • PostgreSQL: psql
  • MariaDB: mariadb
  • MySQL: mysql
  • Snowflake: snowsql
  • SQLite: sqlite3

Setup

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"
}

Default Config

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>"
    }
}

Usage:

Open SQLua with the command :SQLua

Edit connections with :SQLuaEdit

Executing Queries

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.

Saved Files

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.

Quicker Navigation

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.

Roadmap

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

About

A SQL IDE and UI for NeoVim written in Lua. Inspired by vim-dadbod vim-dadbod-ui.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%
0