-
-
Notifications
You must be signed in to change notification settings - Fork 295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugins/project-nvim: take ownership of telescope integration #1236
Conversation
I'd rather add a warning than toggling it explictely |
I'm not sure why, though. If I enable the extension manually I expected it to enable the plugin that it's dependent on for me. It's a bug currently to try and load an extension that doesn't exist and breaks your init.lua just enabling this alone. The other instances of extensions fetch the package for you, as well. I started going through and writing a warning, but it felt weird wording it basically saying that this option does nothing by itself other than cause errors so please go enable another option manually. |
I wrote the warning around the concept of you possibly supplying the project-nvim outside of the nixvim options, if that was what you were thinking. This would require changing the default of project-nvim enable to be nullable, otherwise it's always false and will always show the warning. { lib
, config
, ...
}:
with lib; let
cfg = config.plugins.telescope.extensions.project-nvim;
project-nvim-cfg = config.plugins.project-nvim;
in
{
options.plugins.telescope.extensions.project-nvim = {
enable = mkEnableOption "project-nvim telescope extension";
};
config = mkIf cfg.enable {
plugins.telescope.enabledExtensions = [ "projects" ];
warnings = optional (!project-nvim-cfg.enable)
''
You have enabled the `project-nvim` extension in telescope.
You need to provide the project-nvim plugin itself otherwise this option will break your config.
- To enable this extension, set `plugins.project-nvim.enable` to `true`.
- If you've supplied the plugin outside of Nixvim, to silence this warning, explicitly set the option to `false`.
'';
};
} Unless you were thinking something simpler in another example in the repo of, but this one implies it shouldn't break your config and just might have missing functionality... right now, loading an extension that doesn't exist causes lua errors: in {
meta.maintainers = [maintainers.GaetanLepage];
options.plugins.hmts = {
enable = mkEnableOption "hmts.nvim";
package = helpers.mkPackageOption "hmts.nvim" pkgs.vimPlugins.hmts-nvim;
};
config = mkIf cfg.enable {
warnings = optional (!config.plugins.treesitter.enable) [
"Nixvim: treesitter-refactor needs treesitter to function as intended"
];
extraPlugins = [cfg.package];
};
} |
Well if it breaks I'd suggest adding an assertion (so an error) instead of a warning, but I'd prefer we avoid having too much magic. Ultimately I think I'd prefer having an option in the project.nvim plugin options called I feel like it is more appropriate to have project.nvim manage this (and maybe warn the user if enableTelescope is set to |
I agree with this sentiment. I'll go this direction. |
In testing, I noticed telescope is automatically enabled in yanky and todo-comments. So I had to mkForce disable to test the warning. Should that be removed to get rid of the magic you were talking about? I also saw that harpoon is doing an assertion instead of a warning for the telescope integration. Should we change that to a warning like this or make this one an assertion? Looks like others are warnings, as well and that's the outlier. |
Telescope extension option being toggled independently will throw an error in config trying to load a non existent plugin.