mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-09-06 10:21:31 +00:00
languages: allow listOf format.type
This commit is contained in:
parent
a2b3010bb3
commit
70555904a0
22 changed files with 265 additions and 357 deletions
|
@ -33,14 +33,11 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "sqlfluff";
|
||||
defaultFormat = ["sqlfluff"];
|
||||
formats = {
|
||||
sqlfluff = {
|
||||
package = sqlfluffDefault;
|
||||
config = {
|
||||
command = getExe cfg.format.package;
|
||||
append_args = ["--dialect=${cfg.dialect}"];
|
||||
};
|
||||
command = getExe sqlfluffDefault;
|
||||
append_args = ["--dialect=${cfg.dialect}"];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -88,16 +85,10 @@ in {
|
|||
enable = mkEnableOption "SQL formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
type = enum (attrNames formats);
|
||||
type = singleOrListOf (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "SQL formatter to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
description = "SQL formatter package";
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
|
@ -133,8 +124,13 @@ in {
|
|||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.sql = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
||||
setupOpts.formatters_by_ft.sql = cfg.format.type;
|
||||
setupOpts.formatters =
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = formats.${name};
|
||||
})
|
||||
cfg.format.type;
|
||||
};
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue