Skip to content

Commit

Permalink
added default conection option in config
Browse files Browse the repository at this point in the history
  • Loading branch information
kndndrj committed Jan 8, 2024
1 parent 43e3df5 commit 3d62d1e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lua/dbee/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ local config = {}

-- Configuration object.
---@class Config
---@field sources Source[] list of connection sources
---@field extra_helpers table<string, table<string, string>>
---@field drawer drawer_config
---@field editor editor_config
---@field result result_config
---@field call_log call_log_config
---@field window_layout Layout
---@field default_connection? string
---@field sources? Source[] list of connection sources
---@field extra_helpers? table<string, table<string, string>>
---@field drawer? drawer_config
---@field editor? editor_config
---@field result? result_config
---@field call_log? call_log_config
---@field window_layout? Layout

---@class Candy
---@field icon string
Expand Down Expand Up @@ -41,6 +42,9 @@ local config = {}
---To see defaults, run :lua= require"dbee.config".default
---@type Config config
config.default = {
-- you can specify an optional default connection id and it will be the active one
-- when dbee starts
default_connection = nil,
-- loads connections from files and environment variables
sources = {
require("dbee.sources").EnvSource:new("DBEE_CONNECTIONS"),
Expand Down
5 changes: 5 additions & 0 deletions lua/dbee/entry/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ local function setup_handler()
m.handler = Handler:new(m.config.sources)
m.handler:add_helpers(m.config.extra_helpers)

-- activate default connection if present
if m.config.default_connection then
pcall(m.handler.set_current_connection, m.handler, m.config.default_connection)
end

m.core_loaded = true
end

Expand Down

0 comments on commit 3d62d1e

Please sign in to comment.