From e1949666b1fda8a862911222e0c16bb0b7e3df25 Mon Sep 17 00:00:00 2001 From: Ruslan Date: Sat, 27 Jun 2026 12:30:31 +0300 Subject: [PATCH] feat(dadbod): read databases from the encrypted file --- lua/crentist/lazy/dadbod.lua | 51 ++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/lua/crentist/lazy/dadbod.lua b/lua/crentist/lazy/dadbod.lua index 9b7701d..5d213c6 100644 --- a/lua/crentist/lazy/dadbod.lua +++ b/lua/crentist/lazy/dadbod.lua @@ -1,20 +1,37 @@ return { - 'kristijanhusak/vim-dadbod-ui', - dependencies = { - { 'tpope/vim-dadbod', lazy = true }, - { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, -- Optional - }, - cmd = { - 'DBUI', - 'DBUIToggle', - 'DBUIAddConnection', - 'DBUIFindBuffer', - }, - init = function() - -- Your DBUI configuration - vim.g.db_ui_use_nerd_fonts = 1 - vim.g.db_ui_auto_execute_table_helpers = 1 - vim.g.db_ui_win_position = 'left' - end, + 'kristijanhusak/vim-dadbod-ui', + dependencies = { + { 'tpope/vim-dadbod', lazy = true }, + { 'kristijanhusak/vim-dadbod-completion', ft = { 'sql', 'mysql', 'plsql' }, lazy = true }, -- Optional + }, + cmd = { + 'DBUI', + 'DBUIToggle', + 'DBUIAddConnection', + 'DBUIFindBuffer', + }, + init = function() + -- Your DBUI configuration + vim.g.db_ui_use_nerd_fonts = 1 + vim.g.db_ui_auto_execute_table_helpers = 1 + vim.g.db_ui_win_position = 'left' + + local sops = require('crentist.sops') + local sops_runner = sops.create_runner({}) + + local decrypted_dbs = sops_runner:to_table('~/.dotfiles/dbs.yaml') + if decrypted_dbs then + vim.g.dbs = decrypted_dbs.databases + end + + local refresh_db = function() + decrypted_dbs = sops_runner:to_table('~/.dotfiles/dbs.yaml') + if decrypted_dbs then + vim.g.dbs = decrypted_dbs.databases + end + end + + vim.api.nvim_create_user_command('DBRefresh', refresh_db, {}) + end, }