plugins/lsp: normalize plugin defaults

This commit is contained in:
Matt Sturgeon 2024-06-11 16:53:12 +01:00
parent 6f408f2bd0
commit 0f07201a0c
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
10 changed files with 205 additions and 199 deletions

View file

@ -15,74 +15,74 @@ in
package = helpers.mkPluginPackageOption "conform-nvim" pkgs.vimPlugins.conform-nvim;
formattersByFt =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "see documentation"
''
```nix
# Map of filetype to formatters
formattersByFt =
{
lua = [ "stylua" ];
# Conform will run multiple formatters sequentially
python = [ "isort" "black" ];
# Use a sub-list to run only the first available formatter
javascript = [ [ "prettierd" "prettier" ] ];
# Use the "*" filetype to run formatters on all filetypes.
"*" = [ "codespell" ];
# Use the "_" filetype to run formatters on filetypes that don't
# have other formatters configured.
"_" = [ "trim_whitespace" ];
};
```
'';
formatOnSave =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
either strLuaFn (submodule {
options = {
lspFallback = mkOption {
type = types.bool;
default = true;
description = "See :help conform.format for details.";
};
timeoutMs = mkOption {
type = types.int;
default = 500;
description = "See :help conform.format for details.";
};
formattersByFt = helpers.defaultNullOpts.mkAttrsOf' {
type = types.anything;
# Unknown plugin default
description = ''
```nix
# Map of filetype to formatters
formattersByFt =
{
lua = [ "stylua" ];
# Conform will run multiple formatters sequentially
python = [ "isort" "black" ];
# Use a sub-list to run only the first available formatter
javascript = [ [ "prettierd" "prettier" ] ];
# Use the "*" filetype to run formatters on all filetypes.
"*" = [ "codespell" ];
# Use the "_" filetype to run formatters on filetypes that don't
# have other formatters configured.
"_" = [ "trim_whitespace" ];
};
})
)
"see documentation"
''
If this is set, Conform will run the formatter on save.
It will pass the table to conform.format().
This can also be a function that returns the table.
See :help conform.format for details.
'';
```
'';
};
formatAfterSave =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
either strLuaFn (submodule {
options = {
lspFallback = mkOption {
type = types.bool;
default = true;
description = "See :help conform.format for details.";
};
formatOnSave = helpers.defaultNullOpts.mkNullable' {
type =
with helpers.nixvimTypes;
either strLuaFn (submodule {
options = {
lspFallback = mkOption {
type = types.bool;
default = true;
description = "See :help conform.format for details.";
};
})
)
"see documentation"
''
If this is set, Conform will run the formatter asynchronously after save.
It will pass the table to conform.format().
This can also be a function that returns the table.
'';
timeoutMs = mkOption {
type = types.int;
default = 500;
description = "See :help conform.format for details.";
};
};
});
# Unknown plugin default
description = ''
If this is set, Conform will run the formatter on save.
It will pass the table to conform.format().
This can also be a function that returns the table.
See :help conform.format for details.
'';
};
formatAfterSave = helpers.defaultNullOpts.mkNullable' {
type =
with helpers.nixvimTypes;
either strLuaFn (submodule {
options = {
lspFallback = mkOption {
type = types.bool;
default = true;
description = "See :help conform.format for details.";
};
};
});
# Unknown plugin default
description = ''
If this is set, Conform will run the formatter asynchronously after save.
It will pass the table to conform.format().
This can also be a function that returns the table.
'';
};
logLevel = helpers.defaultNullOpts.mkLogLevel "error" ''
Set the log level. Use `:ConformInfo` to see the location of the log file.
@ -90,9 +90,11 @@ in
notifyOnError = helpers.defaultNullOpts.mkBool true "Conform will notify you when a formatter errors";
formatters =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) "see documentation"
"Custom formatters and changes to built-in formatters";
formatters = helpers.defaultNullOpts.mkAttrsOf' {
type = types.anything;
# Unknown plugin default
description = "Custom formatters and changes to built-in formatters";
};
};
config =