File tree Expand file tree Collapse file tree 3 files changed +105
-0
lines changed
Expand file tree Collapse file tree 3 files changed +105
-0
lines changed Original file line number Diff line number Diff line change 1+ # sqlit.nvim
2+
3+ Neovim integration for [ sqlit] ( https://github.com/Maxteabag/sqlit ) .
4+
5+ ## Install
6+
7+ Requires sqlit in your PATH.
8+
9+ ### lazy.nvim
10+
11+ ``` lua
12+ {
13+ " Maxteabag/sqlit" ,
14+ subdir = " extras/nvim" ,
15+ opts = {},
16+ }
17+ ```
18+
19+ ### With options
20+
21+ ``` lua
22+ {
23+ " Maxteabag/sqlit" ,
24+ subdir = " extras/nvim" ,
25+ opts = {
26+ theme = " dracula" ,
27+ keymap = " <leader>D" ,
28+ args = " " ,
29+ },
30+ }
31+ ```
32+
33+ ## Usage
34+
35+ ` <leader>D ` or ` :Sqlit `
36+
37+ ## Options
38+
39+ | Option | Default | Description |
40+ | --------| ---------| -------------|
41+ | ` theme ` | ` "textual-ansi" ` | sqlit theme (` nil ` for default) |
42+ | ` keymap ` | ` "<leader>D" ` | Keymap to open (` false ` to disable) |
43+ | ` args ` | ` "" ` | Extra CLI arguments |
Original file line number Diff line number Diff line change 1+ local M = {}
2+
3+ M .config = {
4+ theme = " textual-ansi" ,
5+ keymap = " <leader>D" ,
6+ desc = " Database (sqlit)" ,
7+ args = " " ,
8+ }
9+
10+ local function build_cmd ()
11+ local cmd = " sqlit"
12+ if M .config .theme then
13+ cmd = cmd .. " --theme " .. M .config .theme
14+ end
15+ if M .config .args and M .config .args ~= " " then
16+ cmd = cmd .. " " .. M .config .args
17+ end
18+ return cmd
19+ end
20+
21+ function M .open ()
22+ local cmd = build_cmd ()
23+
24+ local ok , snacks = pcall (require , " snacks" )
25+ if ok and snacks .terminal then
26+ snacks .terminal (cmd )
27+ return
28+ end
29+
30+ local tok , toggleterm = pcall (require , " toggleterm.terminal" )
31+ if tok then
32+ local Terminal = toggleterm .Terminal
33+ local sqlit = Terminal :new ({
34+ cmd = cmd ,
35+ direction = " float" ,
36+ hidden = true ,
37+ on_open = function ()
38+ vim .cmd (" startinsert!" )
39+ end ,
40+ })
41+ sqlit :toggle ()
42+ return
43+ end
44+
45+ vim .cmd (" tabnew | terminal " .. cmd )
46+ vim .cmd (" startinsert" )
47+ end
48+
49+ function M .setup (opts )
50+ M .config = vim .tbl_deep_extend (" force" , M .config , opts or {})
51+
52+ if M .config .keymap then
53+ vim .keymap .set (" n" , M .config .keymap , function ()
54+ M .open ()
55+ end , { desc = M .config .desc })
56+ end
57+ end
58+
59+ return M
Original file line number Diff line number Diff line change 1+ vim .api .nvim_create_user_command (" Sqlit" , function ()
2+ require (" sqlit" ).open ()
3+ end , { desc = " Open sqlit" })
You can’t perform that action at this time.
0 commit comments