plugins/utils/project-nvim: take ownership of telescope integration (#1236)

This commit is contained in:
Austin Horstman 2024-03-13 08:43:39 -05:00 committed by GitHub
parent c2cd3cb7a1
commit 29b6ede12f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 30 additions and 17 deletions

View file

@ -14,7 +14,6 @@ in {
./fzf-native.nix
./fzy-native.nix
./media-files.nix
./project-nvim.nix
./ui-select.nix
./undo.nix
];

View file

@ -1,16 +0,0 @@
{
lib,
config,
...
}:
with lib; let
cfg = config.plugins.telescope.extensions.project-nvim;
in {
options.plugins.telescope.extensions.project-nvim = {
enable = mkEnableOption "project-nvim telescope extension";
};
config = mkIf cfg.enable {
plugins.telescope.enabledExtensions = ["projects"];
};
}

View file

@ -8,6 +8,12 @@
with lib; let
cfg = config.plugins.project-nvim;
in {
imports = [
(lib.mkRenamedOptionModule
["plugins" "telescope" "extensions" "project-nvim" "enable"]
["plugins" "project-nvim" "enableTelescope"])
];
options.plugins.project-nvim =
helpers.neovim-plugin.extraOptionsOptions
// {
@ -67,9 +73,20 @@ in {
(with types; either str helpers.nixvimTypes.rawLua)
''{__raw = "vim.fn.stdpath('data')";}''
"Path where project.nvim will store the project history for use in telescope.";
enableTelescope = mkEnableOption ''
When set to true, enabled project-nvim telescope integration.
'';
};
config = mkIf cfg.enable {
warnings =
optional
(cfg.enableTelescope && (!config.plugins.telescope.enable))
''
Telescope support for project-nvim is enabled but the telescope plugin is not.
'';
extraPlugins = [cfg.package];
extraConfigLua = let
@ -89,5 +106,7 @@ in {
in ''
require('project_nvim').setup(${helpers.toLuaObject setupOptions})
'';
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope ["projects"];
};
}

View file

@ -3,6 +3,17 @@
plugins.project-nvim.enable = true;
};
telescopeEnabled = {
plugins.telescope = {
enable = true;
};
plugins.project-nvim = {
enable = true;
enableTelescope = true;
};
};
defaults = {
plugins.project-nvim = {
enable = true;