diff --git a/plugins/telescope/default.nix b/plugins/telescope/default.nix index e6ea4d25..d5fb974c 100644 --- a/plugins/telescope/default.nix +++ b/plugins/telescope/default.nix @@ -14,7 +14,6 @@ in { ./fzf-native.nix ./fzy-native.nix ./media-files.nix - ./project-nvim.nix ./ui-select.nix ./undo.nix ]; diff --git a/plugins/telescope/project-nvim.nix b/plugins/telescope/project-nvim.nix deleted file mode 100644 index 1f6e3a5c..00000000 --- a/plugins/telescope/project-nvim.nix +++ /dev/null @@ -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"]; - }; -} diff --git a/plugins/utils/project-nvim.nix b/plugins/utils/project-nvim.nix index adc8a66f..f65e331b 100644 --- a/plugins/utils/project-nvim.nix +++ b/plugins/utils/project-nvim.nix @@ -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"]; }; } diff --git a/tests/test-sources/plugins/utils/project-nvim.nix b/tests/test-sources/plugins/utils/project-nvim.nix index 60aa6ee8..8af10ea3 100644 --- a/tests/test-sources/plugins/utils/project-nvim.nix +++ b/tests/test-sources/plugins/utils/project-nvim.nix @@ -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;