From 380435c555ced04c9aca51f3d37f81b8fabed6e0 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 6 Apr 2025 01:57:17 +0200 Subject: [PATCH] plugins/telescope/zoxide: init --- flake/dev/list-plugins/list-plugins.py | 1 + .../by-name/telescope/extensions/default.nix | 1 + .../by-name/telescope/extensions/zoxide.nix | 21 +++++ .../plugins/by-name/telescope/zoxide.nix | 88 +++++++++++++++++++ typos.toml | 1 + 5 files changed, 112 insertions(+) create mode 100644 plugins/by-name/telescope/extensions/zoxide.nix create mode 100644 tests/test-sources/plugins/by-name/telescope/zoxide.nix diff --git a/flake/dev/list-plugins/list-plugins.py b/flake/dev/list-plugins/list-plugins.py index 7d9864b8..fdaf886c 100755 --- a/flake/dev/list-plugins/list-plugins.py +++ b/flake/dev/list-plugins/list-plugins.py @@ -87,6 +87,7 @@ for telescope_extension_name, has_depr_warnings in { "project": False, "ui-select": False, "undo": True, + "zoxide": False, }.items(): KNOWN_PATHS[ f"plugins/by-name/telescope/extensions/{telescope_extension_name}.nix" diff --git a/plugins/by-name/telescope/extensions/default.nix b/plugins/by-name/telescope/extensions/default.nix index 54d73f6c..568d95b7 100644 --- a/plugins/by-name/telescope/extensions/default.nix +++ b/plugins/by-name/telescope/extensions/default.nix @@ -10,5 +10,6 @@ ./project.nix ./ui-select.nix ./undo.nix + ./zoxide.nix ]; } diff --git a/plugins/by-name/telescope/extensions/zoxide.nix b/plugins/by-name/telescope/extensions/zoxide.nix new file mode 100644 index 00000000..52f38805 --- /dev/null +++ b/plugins/by-name/telescope/extensions/zoxide.nix @@ -0,0 +1,21 @@ +let + mkExtension = import ./_mk-extension.nix; +in +mkExtension { + name = "zoxide"; + package = "telescope-zoxide"; + + settingsExample = { + prompt_title = "Zoxide Folder List"; + mappings = { + "" = { + keepinsert = true; + action.__raw = '' + function(selection) + file_browser.file_browser({ cwd = selection.path }) + end + ''; + }; + }; + }; +} diff --git a/tests/test-sources/plugins/by-name/telescope/zoxide.nix b/tests/test-sources/plugins/by-name/telescope/zoxide.nix new file mode 100644 index 00000000..e8d6a6a0 --- /dev/null +++ b/tests/test-sources/plugins/by-name/telescope/zoxide.nix @@ -0,0 +1,88 @@ +{ + empty = { + plugins = { + telescope = { + enable = true; + extensions.zoxide.enable = true; + }; + web-devicons.enable = true; + }; + }; + + defaults = { + plugins = { + web-devicons.enable = true; + telescope = { + enable = true; + + extensions.zoxide = { + enable = true; + + settings = { + prompt_title = "[ Zoxide List ]"; + list_command = "zoxide query -ls"; + mappings = { + default = { + action.__raw = '' + function(selection) + vim.cmd.cd(selection.path) + end + ''; + after_action.__raw = '' + function(selection) + vim.notify("Directory changed to " .. selection.path) + end + ''; + }; + "".action.__raw = + "require('telescope._extensions.zoxide.utils').create_basic_command('split')"; + "".action.__raw = + "require('telescope._extensions.zoxide.utils').create_basic_command('vsplit')"; + "".action.__raw = "require('telescope._extensions.zoxide.utils').create_basic_command('edit')"; + "" = { + keepinsert = true; + action.__raw = '' + function(selection) + builtin.find_files({ cwd = selection.path }) + end + ''; + }; + "".action.__raw = '' + function(selection) + vim.cmd.tcd(selection.path) + end + ''; + }; + }; + }; + }; + }; + }; + + example = { + plugins = { + web-devicons.enable = true; + telescope = { + enable = true; + + extensions.zoxide = { + enable = true; + + settings = { + prompt_title = "Zoxide Folder List"; + mappings = { + "" = { + keepinsert = true; + action.__raw = '' + function(selection) + file_browser.file_browser({ cwd = selection.path }) + end + ''; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/typos.toml b/typos.toml index 863ad310..79d1d669 100644 --- a/typos.toml +++ b/typos.toml @@ -16,6 +16,7 @@ tro = "tro" # ./plugins/utils/spectre.nix protols = "protols" # ./plugins/lsp/lsp-packages.nix compatibilty = "compatibilty" # ./plugins/by-name/visual-multi/default.nix Maco = "Maco" # ./plugins/by-name/femaco +Typ = "Typ" # ./flake/dev/list-plugins/list-plugins.py [type.patch] extend-glob = ["*.patch"]