File tree Expand file tree Collapse file tree 4 files changed +48
-1
lines changed
Expand file tree Collapse file tree 4 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ as dependencies in your package manager:
3232- [ nvim.lua] ( https://github.com/norcalli/nvim.lua )
3333- [ nvim-web-devicons] ( https://github.com/kyazdani42/nvim-web-devicons )
3434- [ fidget.nvim] ( https://github.com/j-hui/fidget.nvim )
35+ - [ sqls.nvim] ( https://github.com/nanotee/sqls.nvim )
3536
3637## Installation
3738
8586 " rebelot/heirline.nvim" ,
8687 " kyazdani42/nvim-web-devicons" ,
8788 " j-hui/fidget.nvim" ,
89+ " nanotee/sqls.nvim" ,
8890 },
8991 config = function ()
9092 require (" arshlib.quick" ).autocmd ({" UIEnter" , " *" , function ()
Original file line number Diff line number Diff line change @@ -347,6 +347,25 @@ table.insert(components.active[3], {
347347})
348348-- }}}
349349
350+ -- SQLs Info {{{
351+ table.insert (components .active [3 ], {
352+ provider = " sqls_status" ,
353+ enabled = function ()
354+ return vim .bo .filetype == " sql" and pcall (require , " sqls.commands" )
355+ end ,
356+ truncate_hide = true ,
357+ hl = right_ribbon_hl ,
358+ left_sep = {
359+ str = " " ,
360+ hl = {
361+ bg = " statusline_bg" ,
362+ fg = " mid_bg" ,
363+ style = " bold" ,
364+ },
365+ },
366+ })
367+ -- }}}
368+
350369-- File Icon {{{
351370table.insert (components .active [3 ], {
352371 priority = 7 ,
@@ -725,6 +744,7 @@ require("feline").setup({ -- {{{
725744 diag_hints = util .diagnostic_hints ,
726745 lsp_clients = util .lsp_client_names ,
727746 fold_method = util .fold_method ,
747+ sqls_status = util .sqls_status ,
728748 },
729749})
730750-- }}}
Original file line number Diff line number Diff line change 1- local nvim = require (" nvim" )
21local utils = require (" heirline.utils" )
32
43local M = {}
@@ -439,10 +438,35 @@ function M.diagnostic_info() --{{{
439438 return diagnostics (vim .diagnostic .severity .INFO ), " "
440439end -- }}}
441440
441+ local sqls_status = {
442+ subscribed = false ,
443+ connection = nil ,
444+ database = " default" ,
445+ }
442446
447+ function M .sqls_status () -- {{{
448+ local ok , events = pcall (require , " sqls.events" )
449+ if not ok then
450+ return " "
451+ end
452+ if not sqls_status .subscribed then
453+ events .add_subscriber (" connection_choice" , function (event )
454+ local items = vim .split (event .choice , " " )
455+ sqls_status .connection = items [3 ]
456+ local _ , _ , name = event .choice :find (" dbname=([^ ]+)" )
457+ sqls_status .database = name or " Unknown"
458+ end )
459+ events .add_subscriber (" database_choice" , function (event )
460+ sqls_status .database = event .choice
461+ end )
462+ sqls_status .sqls_subscribed = true
463+ end
443464
465+ if not sqls_status .connection or not sqls_status .database then
466+ return " "
444467 end
445468
469+ return sqls_status .connection .. M .separators .database .. sqls_status .database
446470end -- }}}
447471
448472return M
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ local libs = {
1010 heirline = " rebelot/heirline.nvim" ,
1111 [" fidget.nvim" ] = " j-hui/fidget.nvim" ,
1212 [" nvim-web-devicons" ] = " kyazdani42/nvim-web-devicons" ,
13+ [" sqls.nvim" ] = " nanotee/sqls.nvim" ,
1314}
1415
1516M .check = function ()
You can’t perform that action at this time.
0 commit comments