From c457fe942474c6888639c432a05f7cf200454d15 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Fri, 23 May 2025 17:16:21 +0200 Subject: [PATCH] plugins/dbee: init --- plugins/by-name/dbee/default.nix | 15 + .../plugins/by-name/dbee/default.nix | 336 ++++++++++++++++++ 2 files changed, 351 insertions(+) create mode 100644 plugins/by-name/dbee/default.nix create mode 100644 tests/test-sources/plugins/by-name/dbee/default.nix diff --git a/plugins/by-name/dbee/default.nix b/plugins/by-name/dbee/default.nix new file mode 100644 index 00000000..89f7bcd7 --- /dev/null +++ b/plugins/by-name/dbee/default.nix @@ -0,0 +1,15 @@ +{ lib, ... }: +lib.nixvim.plugins.mkNeovimPlugin { + name = "dbee"; + packPathName = "nvim-dbee"; + package = "nvim-dbee"; + + maintainers = [ lib.maintainers.GaetanLepage ]; + + settingsExample = { + default_connection = "wtg"; + sources = [ + (lib.nixvim.nestedLiteralLua "require('dbee.sources').FileSource:new(vim.fn.stdpath('cache') .. '/dbee/persistence.json')") + ]; + }; +} diff --git a/tests/test-sources/plugins/by-name/dbee/default.nix b/tests/test-sources/plugins/by-name/dbee/default.nix new file mode 100644 index 00000000..d1090454 --- /dev/null +++ b/tests/test-sources/plugins/by-name/dbee/default.nix @@ -0,0 +1,336 @@ +{ lib, ... }: +{ + empty = { + plugins.dbee.enable = true; + }; + + defaults = { + plugins.dbee = { + enable = true; + settings = { + default_connection = null; + sources = [ + (lib.nixvim.mkRaw "require('dbee.sources').EnvSource:new('DBEE_CONNECTIONS')") + (lib.nixvim.mkRaw "require('dbee.sources').FileSource:new(vim.fn.stdpath('state') .. '/dbee/persistence.json')") + ]; + extra_helpers = { }; + float_options = { }; + drawer = { + window_options = { }; + buffer_options = { }; + disable_help = false; + mappings = [ + { + key = "r"; + mode = "n"; + action = "refresh"; + } + { + key = ""; + mode = "n"; + action = "action_1"; + } + { + key = "cw"; + mode = "n"; + action = "action_2"; + } + { + key = "dd"; + mode = "n"; + action = "action_3"; + } + { + key = "o"; + mode = "n"; + action = "toggle"; + } + { + key = ""; + mode = "n"; + action = "menu_confirm"; + } + { + key = "y"; + mode = "n"; + action = "menu_yank"; + } + { + key = ""; + mode = "n"; + action = "menu_close"; + } + { + key = "q"; + mode = "n"; + action = "menu_close"; + } + ]; + disable_candies = false; + candies = { + history = { + icon = ""; + icon_highlight = "Constant"; + text_highlight = ""; + }; + note = { + icon = ""; + icon_highlight = "Character"; + text_highlight = ""; + }; + connection = { + icon = "󱘖"; + icon_highlight = "SpecialChar"; + text_highlight = ""; + }; + database_switch = { + icon = ""; + icon_highlight = "Character"; + text_highlight = ""; + }; + schema = { + icon = ""; + icon_highlight = "Removed"; + text_highlight = ""; + }; + table = { + icon = ""; + icon_highlight = "Conditional"; + text_highlight = ""; + }; + streaming_table = { + icon = ""; + icon_highlight = "Conditional"; + text_highlight = ""; + }; + managed = { + icon = ""; + icon_highlight = "Conditional"; + text_highlight = ""; + }; + view = { + icon = ""; + icon_highlight = "Debug"; + text_highlight = ""; + }; + materialized_view = { + icon = ""; + icon_highlight = "Type"; + text_highlight = ""; + }; + sink = { + icon = ""; + icon_highlight = "String"; + text_highlight = ""; + }; + column = { + icon = "󰠵"; + icon_highlight = "WarningMsg"; + text_highlight = ""; + }; + add = { + icon = ""; + icon_highlight = "String"; + text_highlight = "String"; + }; + edit = { + icon = "󰏫"; + icon_highlight = "Directory"; + text_highlight = "Directory"; + }; + remove = { + icon = "󰆴"; + icon_highlight = "SpellBad"; + text_highlight = "SpellBad"; + }; + help = { + icon = "󰋖"; + icon_highlight = "Title"; + text_highlight = "Title"; + }; + source = { + icon = "󰃖"; + icon_highlight = "MoreMsg"; + text_highlight = "MoreMsg"; + }; + none = { + icon = " "; + icon_highlight = ""; + text_highlight = ""; + }; + none_dir = { + icon = ""; + icon_highlight = "NonText"; + text_highlight = ""; + }; + node_expanded = { + icon = ""; + icon_highlight = "NonText"; + text_highlight = ""; + }; + node_closed = { + icon = ""; + icon_highlight = "NonText"; + text_highlight = ""; + }; + }; + }; + result = { + window_options = { }; + buffer_options = { }; + page_size = 100; + focus_result = true; + progress = { + spinner = [ + "⠋" + "⠙" + "⠹" + "⠸" + "⠼" + "⠴" + "⠦" + "⠧" + "⠇" + "⠏" + ]; + text_prefix = "Executing..."; + }; + mappings = [ + { + key = "L"; + mode = ""; + action = "page_next"; + } + { + key = "H"; + mode = ""; + action = "page_prev"; + } + { + key = "E"; + mode = ""; + action = "page_last"; + } + { + key = "F"; + mode = ""; + action = "page_first"; + } + { + key = "yaj"; + mode = "n"; + action = "yank_current_json"; + } + { + key = "yaj"; + mode = "v"; + action = "yank_selection_json"; + } + { + key = "yaJ"; + mode = ""; + action = "yank_all_json"; + } + { + key = "yac"; + mode = "n"; + action = "yank_current_csv"; + } + { + key = "yac"; + mode = "v"; + action = "yank_selection_csv"; + } + { + key = "yaC"; + mode = ""; + action = "yank_all_csv"; + } + { + key = ""; + mode = ""; + action = "cancel_call"; + } + ]; + }; + editor = { + window_options = { }; + buffer_options = { }; + mappings = [ + { + key = "BB"; + mode = "v"; + action = "run_selection"; + } + { + key = "BB"; + mode = "n"; + action = "run_file"; + } + ]; + }; + call_log = { + window_options = { }; + buffer_options = { }; + mappings = [ + { + key = ""; + mode = ""; + action = "show_result"; + } + { + key = ""; + mode = ""; + action = "cancel_call"; + } + ]; + disable_candies = false; + candies = { + unknown = { + icon = ""; + icon_highlight = "NonText"; + text_highlight = ""; + }; + executing = { + icon = "󰑐"; + icon_highlight = "Constant"; + text_highlight = "Constant"; + }; + executing_failed = { + icon = "󰑐"; + icon_highlight = "Error"; + text_highlight = ""; + }; + retrieving = { + icon = ""; + icon_highlight = "String"; + text_highlight = "String"; + }; + retrieving_failed = { + icon = ""; + icon_highlight = "Error"; + text_highlight = ""; + }; + archived = { + icon = ""; + icon_highlight = "Title"; + text_highlight = ""; + }; + archive_failed = { + icon = ""; + icon_highlight = "Error"; + text_highlight = ""; + }; + canceled = { + icon = ""; + icon_highlight = "Error"; + text_highlight = ""; + }; + }; + }; + + window_layout = lib.nixvim.mkRaw "require('dbee.layouts').Default:new()"; + }; + }; + }; +}