mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
treewide: use mkWarnings wherever possible
This commit is contained in:
parent
02e16b2a76
commit
2ec6218f87
7 changed files with 72 additions and 59 deletions
|
@ -1,10 +1,8 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
lib.nixvim.plugins.mkVimPlugin {
|
||||
name = "haskell-scope-highlighting";
|
||||
packPathName = "haskell-scope-highlighting.nvim";
|
||||
|
@ -13,9 +11,12 @@ lib.nixvim.plugins.mkVimPlugin {
|
|||
maintainers = [ lib.maintainers.GaetanLepage ];
|
||||
|
||||
extraConfig = {
|
||||
warnings = optional (!config.plugins.treesitter.enable) ''
|
||||
Nixvim (plugins.haskell-scope-highlighting): haskell-scope-highlighting needs treesitter to function as intended.
|
||||
Please, enable it by setting `plugins.treesitter.enable` to `true`.
|
||||
'';
|
||||
warnings = lib.nixvim.mkWarnings "plugins.haskell-scope-highlighting" {
|
||||
when = !config.plugins.treesitter.enable;
|
||||
message = ''
|
||||
haskell-scope-highlighting needs treesitter to function as intended.
|
||||
Please, enable it by setting `plugins.treesitter.enable` to `true`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -189,12 +189,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
warnings =
|
||||
optional
|
||||
((isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable)
|
||||
''
|
||||
Nixvim (plugins.nvim-autopairs): You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin.
|
||||
We suggest you to set `plugins.treesitter.enable` to `true`.
|
||||
'';
|
||||
warnings = lib.nixvim.mkWarnings "plugins.nvim-autopairs" {
|
||||
when = (isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable;
|
||||
message = ''
|
||||
You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin.
|
||||
We suggest you to set `plugins.treesitter.enable` to `true`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -249,13 +249,16 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
warnings =
|
||||
let
|
||||
nvimCmpEnabled = isBool cfg.settings.completion.nvim_cmp && cfg.settings.completion.nvim_cmp;
|
||||
in
|
||||
optional (nvimCmpEnabled && !config.plugins.cmp.enable) ''
|
||||
Nixvim (plugins.obsidian): You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`.
|
||||
warnings = lib.nixvim.mkWarnings "plugins.obsidian" {
|
||||
when =
|
||||
let
|
||||
nvimCmpEnabled = isBool cfg.settings.completion.nvim_cmp && cfg.settings.completion.nvim_cmp;
|
||||
in
|
||||
nvimCmpEnabled && (!config.plugins.cmp.enable);
|
||||
message = ''
|
||||
You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`.
|
||||
You should probably enable `nvim-cmp`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -68,19 +68,19 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
];
|
||||
|
||||
# TODO: remove after 24.11
|
||||
warnings =
|
||||
optional
|
||||
(hasAttrByPath [
|
||||
"settings"
|
||||
"server"
|
||||
"settings"
|
||||
] cfg)
|
||||
''
|
||||
The `plugins.rustaceanvim.settings.server.settings' option has been renamed to `plugins.rustaceanvim.settings.server.default_settings'.
|
||||
warnings = lib.nixvim.mkWarnings "plugins.rustaceanvim" {
|
||||
when = hasAttrByPath [
|
||||
"settings"
|
||||
"server"
|
||||
"settings"
|
||||
] cfg;
|
||||
message = ''
|
||||
The `settings.server.settings' option has been renamed to `settings.server.default_settings'.
|
||||
|
||||
Note that if you supplied an attrset and not a function you need to set this attr set in:
|
||||
`plugins.rustaceanvim.settings.server.default_settings.rust-analyzer'.
|
||||
'';
|
||||
Note that if you supplied an attrset and not a function you need to set this attr set in:
|
||||
`settings.server.default_settings.rust-analyzer'.
|
||||
'';
|
||||
};
|
||||
}
|
||||
# If nvim-lspconfig is enabled:
|
||||
(mkIf config.plugins.lsp.enable {
|
||||
|
|
|
@ -70,11 +70,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
warnings =
|
||||
optional
|
||||
((isBool cfg.settings.treesitter) && cfg.settings.treesitter && (!config.plugins.treesitter.enable))
|
||||
''
|
||||
Nixvim (plugins.twilight): You have set `plugins.twilight.treesitter` to `true` but `plugins.treesitter.enable` is false.
|
||||
'';
|
||||
warnings = lib.nixvim.mkWarnings "plugins.twilight" {
|
||||
when =
|
||||
(isBool cfg.settings.treesitter) && cfg.settings.treesitter && (!config.plugins.treesitter.enable);
|
||||
message = ''
|
||||
You have set `plugins.twilight.treesitter` to `true` but `plugins.treesitter.enable` is false.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -58,22 +58,29 @@ in
|
|||
config = lib.mkIf (cfg.enable && cfg.autoEnableSources) (
|
||||
lib.mkMerge [
|
||||
{
|
||||
warnings =
|
||||
warnings = lib.nixvim.mkWarnings "plugins.cmp" [
|
||||
# TODO: expand this warning to ft & cmd sources lists and `showDefs` the offending definitions
|
||||
lib.optional (lib.types.isRawType cfg.settings.sources) ''
|
||||
Nixvim (plugins.cmp): You have enabled `autoEnableSources` that tells Nixvim to automatically
|
||||
enable the source plugins with respect to the list of sources provided in `settings.sources`.
|
||||
However, the latter is proveded as a raw lua string which is not parseable by Nixvim.
|
||||
{
|
||||
when = lib.types.isRawType cfg.settings.sources;
|
||||
message = ''
|
||||
You have enabled `autoEnableSources` that tells Nixvim to automatically
|
||||
enable the source plugins with respect to the list of sources provided in `settings.sources`.
|
||||
However, the latter is proveded as a raw lua string which is not parseable by Nixvim.
|
||||
|
||||
If you want to keep using raw lua for defining your sources:
|
||||
- Ensure you enable the relevant plugins manually in your configuration;
|
||||
- Dismiss this warning by explicitly setting `autoEnableSources` to `false`;
|
||||
''
|
||||
If you want to keep using raw lua for defining your sources:
|
||||
- Ensure you enable the relevant plugins manually in your configuration;
|
||||
- Dismiss this warning by explicitly setting `autoEnableSources` to `false`;
|
||||
'';
|
||||
}
|
||||
# TODO: Added 2024-09-22; remove after 24.11
|
||||
++ lib.optional (lib.elem "otter" enabledSources) ''
|
||||
Nixvim (plugins.cmp): "otter" is listed in `settings.sources`, however it is no longer a cmp source.
|
||||
Instead, you should enable `plugins.otter` and use the "cmp-nvim-lsp" completion source.
|
||||
'';
|
||||
{
|
||||
when = lib.elem "otter" enabledSources;
|
||||
message = ''
|
||||
"otter" is listed in `settings.sources`, however it is no longer a cmp source.
|
||||
Instead, you should enable `plugins.otter` and use the "cmp-nvim-lsp" completion source.
|
||||
'';
|
||||
}
|
||||
];
|
||||
|
||||
# If the user has enabled the `foo` and `bar` sources, then `plugins` will look like:
|
||||
# {
|
||||
|
|
|
@ -116,14 +116,15 @@ lib.nixvim.plugins.mkNeovimPlugin {
|
|||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
warnings =
|
||||
lib.optional
|
||||
(
|
||||
(lib.isBool cfg.settings.devicons) && cfg.settings.devicons && (!config.plugins.web-devicons.enable)
|
||||
)
|
||||
''
|
||||
Nixvim (colorschemes.monokai-pro): You have enabled `settings.devicons` but `plugins.web-devicons.enable` is `false`.
|
||||
Consider enabling the plugin for proper devicons support.
|
||||
'';
|
||||
warnings = lib.nixvim.mkWarnings "colorschemes.monokai-pro" {
|
||||
when =
|
||||
(lib.isBool cfg.settings.devicons)
|
||||
&& cfg.settings.devicons
|
||||
&& (!config.plugins.web-devicons.enable);
|
||||
message = ''
|
||||
You have enabled `settings.devicons` but `plugins.web-devicons.enable` is `false`.
|
||||
Consider enabling the plugin for proper devicons support.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue