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
|
@ -8,7 +8,7 @@
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package bool;
|
inherit (lib.types) enum bool;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.types) diagnostics mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) diagnostics mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
@ -30,10 +30,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "shfmt";
|
defaultFormat = ["shfmt"];
|
||||||
formats = {
|
formats = {
|
||||||
shfmt = {
|
shfmt = {
|
||||||
package = pkgs.shfmt;
|
command = getExe pkgs.shfmt;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,16 +68,10 @@ in {
|
||||||
description = "Enable Bash formatting";
|
description = "Enable Bash formatting";
|
||||||
};
|
};
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Bash formatter to use";
|
description = "Bash formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Bash formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
@ -108,10 +102,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.sh = [cfg.format.type];
|
setupOpts.formatters_by_ft.sh = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,8 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.types) enum listOf;
|
||||||
inherit (lib.types) enum either listOf package str;
|
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
cfg = config.vim.languages.clojure;
|
cfg = config.vim.languages.clojure;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
@ -30,34 +30,18 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "prettier";
|
defaultFormat = ["prettier"];
|
||||||
formats = {
|
formats = {
|
||||||
prettier = {
|
prettier = {
|
||||||
package = pkgs.prettier;
|
command = getExe pkgs.prettier;
|
||||||
};
|
};
|
||||||
|
|
||||||
prettierd = {
|
prettierd = {
|
||||||
package = pkgs.prettierd;
|
command = getExe pkgs.prettierd;
|
||||||
nullConfig = ''
|
|
||||||
table.insert(
|
|
||||||
ls_sources,
|
|
||||||
null_ls.builtins.formatting.prettier.with({
|
|
||||||
command = "${cfg.format.package}/bin/prettierd",
|
|
||||||
})
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
biome = {
|
biome = {
|
||||||
package = pkgs.biome;
|
command = getExe pkgs.biome;
|
||||||
nullConfig = ''
|
|
||||||
table.insert(
|
|
||||||
ls_sources,
|
|
||||||
null_ls.builtins.formatting.biome.with({
|
|
||||||
command = "${cfg.format.package}/bin/biome",
|
|
||||||
})
|
|
||||||
)
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -85,15 +69,9 @@ in {
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "CSS formatter to use";
|
description = "CSS formatter to use";
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
description = "CSS formatter package";
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,10 +93,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.css = [cfg.format.type];
|
setupOpts.formatters_by_ft.css = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
@ -40,13 +40,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "mix";
|
defaultFormat = ["mix"];
|
||||||
formats = {
|
formats = {
|
||||||
mix = {
|
mix = {
|
||||||
package = pkgs.elixir;
|
command = "${pkgs.elixir}/bin/mix";
|
||||||
config = {
|
|
||||||
command = "${cfg.format.package}/bin/mix";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -73,16 +70,10 @@ in {
|
||||||
enable = mkEnableOption "Elixir formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "Elixir formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Elixir formatter to use";
|
description = "Elixir formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Elixir formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
elixir-tools = {
|
elixir-tools = {
|
||||||
|
@ -112,9 +103,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.elixir = [cfg.format.type];
|
setupOpts.formatters_by_ft.elixir = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} =
|
setupOpts.formatters =
|
||||||
formats.${cfg.format.type}.config;
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.types) package enum;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
@ -51,10 +51,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "fantomas";
|
defaultFormat = ["fantomas"];
|
||||||
formats = {
|
formats = {
|
||||||
fantomas = {
|
fantomas = {
|
||||||
package = pkgs.fantomas;
|
command = getExe pkgs.fantomas;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -81,16 +81,10 @@ in {
|
||||||
enable = mkEnableOption "F# formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "F# formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "F# formatter to use";
|
description = "F# formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "F# formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -113,10 +107,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.fsharp = [cfg.format.type];
|
setupOpts.formatters_by_ft.fsharp = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -59,19 +59,16 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "gofmt";
|
defaultFormat = ["gofmt"];
|
||||||
formats = {
|
formats = {
|
||||||
gofmt = {
|
gofmt = {
|
||||||
package = pkgs.go;
|
command = "${pkgs.go}/bin/gofmt";
|
||||||
config.command = "${cfg.format.package}/bin/gofmt";
|
|
||||||
};
|
};
|
||||||
gofumpt = {
|
gofumpt = {
|
||||||
package = pkgs.gofumpt;
|
command = getExe pkgs.gofumpt;
|
||||||
config.command = getExe cfg.format.package;
|
|
||||||
};
|
};
|
||||||
golines = {
|
golines = {
|
||||||
package = pkgs.golines;
|
command = "${pkgs.golines}/bin/golines";
|
||||||
config.command = "${cfg.format.package}/bin/golines";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -113,15 +110,9 @@ in {
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Go formatter to use";
|
description = "Go formatter to use";
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
description = "Go formatter package";
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dap = {
|
dap = {
|
||||||
|
@ -163,8 +154,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.go = [cfg.format.type];
|
setupOpts.formatters_by_ft.go = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
setupOpts.formatters =
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) package bool enum listOf;
|
inherit (lib.types) bool enum listOf;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
cfg = config.vim.languages.hcl;
|
cfg = config.vim.languages.hcl;
|
||||||
|
@ -24,10 +24,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "hclfmt";
|
defaultFormat = ["hclfmt"];
|
||||||
formats = {
|
formats = {
|
||||||
hclfmt = {
|
hclfmt = {
|
||||||
package = pkgs.hclfmt;
|
command = getExe pkgs.hclfmt;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -55,15 +55,10 @@ in {
|
||||||
description = "Enable HCL formatting";
|
description = "Enable HCL formatting";
|
||||||
};
|
};
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "HCL formatter to use";
|
description = "HCL formatter to use";
|
||||||
};
|
};
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "HCL formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -103,10 +98,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.hcl = [cfg.format.type];
|
setupOpts.formatters_by_ft.hcl = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) bool enum package;
|
inherit (lib.types) bool enum;
|
||||||
inherit (lib.lists) optional;
|
inherit (lib.lists) optional;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
@ -25,14 +25,11 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "superhtml";
|
defaultFormat = ["superhtml"];
|
||||||
formats = {
|
formats = {
|
||||||
superhtml = {
|
superhtml = {
|
||||||
package = pkgs.writeShellApplication {
|
command = "${pkgs.superhtml}/bin/superhtml";
|
||||||
name = "superhtml_fmt";
|
args = ["fmt" "-"];
|
||||||
runtimeInputs = [pkgs.superhtml];
|
|
||||||
text = "superhtml fmt -";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,16 +65,10 @@ in {
|
||||||
enable = mkEnableOption "HTML formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "HTML formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "HTML formatter to use";
|
description = "HTML formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "HTML formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
@ -119,10 +110,13 @@ in {
|
||||||
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.html = [cfg.format.type];
|
setupOpts.formatters_by_ft.html = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.meta) getExe' getExe;
|
inherit (lib.meta) getExe' getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
@ -24,15 +24,12 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "jsonfmt";
|
defaultFormat = ["jsonfmt"];
|
||||||
|
|
||||||
formats = {
|
formats = {
|
||||||
jsonfmt = {
|
jsonfmt = {
|
||||||
package = pkgs.writeShellApplication {
|
command = getExe pkgs.jsonfmt;
|
||||||
name = "jsonfmt";
|
args = ["-w" "-"];
|
||||||
runtimeInputs = [pkgs.jsonfmt];
|
|
||||||
text = "jsonfmt -w -";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -60,15 +57,9 @@ in {
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "JSON formatter to use";
|
description = "JSON formatter to use";
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
description = "JSON formatter package";
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,10 +81,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.json = [cfg.format.type];
|
setupOpts.formatters_by_ft.json = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.types) bool enum listOf package;
|
inherit (lib.types) bool enum listOf;
|
||||||
inherit (lib.nvim.types) diagnostics mkGrammarOption;
|
inherit (lib.nvim.types) diagnostics mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.dag) entryBefore;
|
inherit (lib.nvim.dag) entryBefore;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "stylua";
|
defaultFormat = ["stylua"];
|
||||||
formats = {
|
formats = {
|
||||||
stylua = {
|
stylua = {
|
||||||
package = pkgs.stylua;
|
command = getExe pkgs.stylua;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -79,16 +79,10 @@ in {
|
||||||
description = "Enable Lua formatting";
|
description = "Enable Lua formatting";
|
||||||
};
|
};
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Lua formatter to use";
|
description = "Lua formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Lua formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
@ -132,10 +126,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.lua = [cfg.format.type];
|
setupOpts.formatters_by_ft.lua = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames warn;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.types) bool enum package listOf str nullOr;
|
inherit (lib.types) bool enum listOf str nullOr;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption singleOrListOf;
|
inherit (lib.nvim.types) diagnostics mkGrammarOption mkPluginSetupOption singleOrListOf;
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
|
@ -25,17 +25,17 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "deno_fmt";
|
defaultFormat = ["deno_fmt"];
|
||||||
formats = {
|
formats = {
|
||||||
# for backwards compatibility
|
# for backwards compatibility
|
||||||
denofmt = {
|
denofmt = {
|
||||||
package = pkgs.deno;
|
command = getExe pkgs.deno;
|
||||||
};
|
};
|
||||||
deno_fmt = {
|
deno_fmt = {
|
||||||
package = pkgs.deno;
|
command = getExe pkgs.deno;
|
||||||
};
|
};
|
||||||
prettierd = {
|
prettierd = {
|
||||||
package = pkgs.prettierd;
|
command = getExe pkgs.prettierd;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
defaultDiagnosticsProvider = ["markdownlint-cli2"];
|
defaultDiagnosticsProvider = ["markdownlint-cli2"];
|
||||||
|
@ -72,17 +72,11 @@ in {
|
||||||
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "Markdown formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Markdown formatter to use. `denofmt` is deprecated and currently aliased to deno_fmt.";
|
description = "Markdown formatter to use. `denofmt` is deprecated and currently aliased to deno_fmt.";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Markdown formatter package";
|
|
||||||
};
|
|
||||||
|
|
||||||
extraFiletypes = mkOption {
|
extraFiletypes = mkOption {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = [];
|
default = [];
|
||||||
|
@ -157,14 +151,22 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.markdown = [cfg.format.type];
|
setupOpts.formatters_by_ft.markdown = cfg.format.type;
|
||||||
setupOpts.formatters.${
|
setupOpts.formatters = let
|
||||||
if cfg.format.type == "denofmt"
|
names = map (name:
|
||||||
then "deno_fmt"
|
if name == "denofmt"
|
||||||
else cfg.format.type
|
then
|
||||||
} = {
|
warn ''
|
||||||
command = getExe cfg.format.package;
|
vim.languages.markdown.format.type: "denofmt" is renamed to "deno_fmt".
|
||||||
};
|
'' "deno_fmt"
|
||||||
|
else name)
|
||||||
|
cfg.format.type;
|
||||||
|
in
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
names;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.meta) getExe';
|
inherit (lib.meta) getExe';
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
@ -37,13 +37,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "nimpretty";
|
defaultFormat = ["nimpretty"];
|
||||||
formats = {
|
formats = {
|
||||||
nimpretty = {
|
nimpretty = {
|
||||||
package = pkgs.nim;
|
command = "${pkgs.nim}/bin/nimpretty";
|
||||||
config = {
|
|
||||||
command = "${cfg.format.package}/bin/nimpretty";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -68,16 +65,10 @@ in {
|
||||||
format = {
|
format = {
|
||||||
enable = mkEnableOption "Nim formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "Nim formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Nim formatter to use";
|
description = "Nim formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Nim formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -108,8 +99,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.nim = [cfg.format.type];
|
setupOpts.formatters_by_ft.nim = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
setupOpts.formatters =
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "alejandra";
|
defaultFormat = ["alejandra"];
|
||||||
formats = {
|
formats = {
|
||||||
alejandra = {
|
alejandra = {
|
||||||
package = pkgs.alejandra;
|
command = getExe pkgs.alejandra;
|
||||||
};
|
};
|
||||||
|
|
||||||
nixfmt = {
|
nixfmt = {
|
||||||
package = pkgs.nixfmt-rfc-style;
|
command = getExe pkgs.nixfmt-rfc-style;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,15 +109,9 @@ in {
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Nix formatter to use";
|
description = "Nix formatter to use";
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
description = "Nix formatter package";
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
@ -161,10 +155,13 @@ in {
|
||||||
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.nix = [cfg.format.type];
|
setupOpts.formatters_by_ft.nix = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
@ -55,10 +55,10 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "ocamlformat";
|
defaultFormat = ["ocamlformat"];
|
||||||
formats = {
|
formats = {
|
||||||
ocamlformat = {
|
ocamlformat = {
|
||||||
package = pkgs.ocamlPackages.ocamlformat;
|
command = getExe pkgs.ocamlPackages.ocamlformat;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -83,15 +83,10 @@ in {
|
||||||
format = {
|
format = {
|
||||||
enable = mkEnableOption "OCaml formatting support (ocamlformat)" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "OCaml formatting support (ocamlformat)" // {default = config.vim.languages.enableFormat;};
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "OCaml formatter to use";
|
description = "OCaml formatter to use";
|
||||||
};
|
};
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "OCaml formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -113,10 +108,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.ocaml = [cfg.format.type];
|
setupOpts.formatters_by_ft.ocaml = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "black";
|
defaultFormat = ["black"];
|
||||||
formats = {
|
formats = {
|
||||||
black = {
|
black = {
|
||||||
command = getExe pkgs.black;
|
command = getExe pkgs.black;
|
||||||
|
@ -233,12 +233,6 @@ in {
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Python formatters to use";
|
description = "Python formatters to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Python formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO this implementation is very bare bones, I don't know enough python to implement everything
|
# TODO this implementation is very bare bones, I don't know enough python to implement everything
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.meta) getExe getExe';
|
inherit (lib.meta) getExe';
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
@ -28,11 +28,9 @@
|
||||||
defaultFormat = "qmlformat";
|
defaultFormat = "qmlformat";
|
||||||
formats = {
|
formats = {
|
||||||
qmlformat = {
|
qmlformat = {
|
||||||
package = pkgs.writeShellApplication {
|
command = "${qmlPackage}/bin/qmlformat";
|
||||||
name = "qmlformat";
|
args = ["-i" "$FILENAME"];
|
||||||
runtimeInputs = [qmlPackage];
|
stdin = false;
|
||||||
text = "qmlformat -";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -56,16 +54,10 @@ in {
|
||||||
enable = mkEnableOption "QML formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "QML formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "QML formatter to use";
|
description = "QML formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "QML formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,10 +80,13 @@ in {
|
||||||
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
(mkIf (cfg.format.enable && !cfg.lsp.enable) {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.qml = [cfg.format.type];
|
setupOpts.formatters_by_ft.qml = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) enum package;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
@ -19,35 +19,31 @@
|
||||||
packages = [pkgs.rPackages.languageserver];
|
packages = [pkgs.rPackages.languageserver];
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "format_r";
|
defaultFormat = ["format_r"];
|
||||||
formats = {
|
formats = {
|
||||||
styler = {
|
styler = {
|
||||||
package = pkgs.rWrapper.override {
|
command = let
|
||||||
packages = [pkgs.rPackages.styler];
|
pkg = pkgs.rWrapper.override {packages = [pkgs.rPackages.styler];};
|
||||||
};
|
in "${pkg}/bin/R";
|
||||||
config = {
|
|
||||||
command = "${cfg.format.package}/bin/R";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
format_r = {
|
format_r = {
|
||||||
package = pkgs.rWrapper.override {
|
command = let
|
||||||
packages = [pkgs.rPackages.formatR];
|
pkg = pkgs.rWrapper.override {
|
||||||
};
|
packages = [pkgs.rPackages.formatR];
|
||||||
config = {
|
};
|
||||||
command = "${cfg.format.package}/bin/R";
|
in "${pkg}/bin/R";
|
||||||
stdin = true;
|
stdin = true;
|
||||||
args = [
|
args = [
|
||||||
"--slave"
|
"--slave"
|
||||||
"--no-restore"
|
"--no-restore"
|
||||||
"--no-save"
|
"--no-save"
|
||||||
"-s"
|
"-s"
|
||||||
"-e"
|
"-e"
|
||||||
''formatR::tidy_source(source="stdin")''
|
''formatR::tidy_source(source="stdin")''
|
||||||
];
|
];
|
||||||
# TODO: range_args seem to be possible
|
# TODO: range_args seem to be possible
|
||||||
# https://github.com/nvimtools/none-ls.nvim/blob/main/lua/null-ls/builtins/formatting/format_r.lua
|
# https://github.com/nvimtools/none-ls.nvim/blob/main/lua/null-ls/builtins/formatting/format_r.lua
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,16 +83,10 @@ in {
|
||||||
enable = mkEnableOption "R formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "R formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "R formatter to use";
|
description = "R formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "R formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,8 +99,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.r = [cfg.format.type];
|
setupOpts.formatters_by_ft.r = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
setupOpts.formatters =
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
||||||
inherit (lib.types) package enum;
|
inherit (lib.types) enum;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
cfg = config.vim.languages.ruby;
|
cfg = config.vim.languages.ruby;
|
||||||
|
@ -49,11 +49,10 @@
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
|
|
||||||
defaultFormat = "rubocop";
|
defaultFormat = ["rubocop"];
|
||||||
formats = {
|
formats = {
|
||||||
rubocop = {
|
rubocop = {
|
||||||
# TODO: is this right?
|
command = getExe pkgs.rubyPackages.rubocop;
|
||||||
package = pkgs.rubyPackages.rubocop;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,16 +86,10 @@ in {
|
||||||
enable = mkEnableOption "Ruby formatter support" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "Ruby formatter support" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Ruby formatter to use";
|
description = "Ruby formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Ruby formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
@ -130,10 +123,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.ruby = [cfg.format.type];
|
setupOpts.formatters_by_ft.ruby = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -12,16 +12,17 @@
|
||||||
inherit (lib.trivial) boolToString;
|
inherit (lib.trivial) boolToString;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.types) bool package str listOf either enum;
|
inherit (lib.types) bool package str listOf either enum;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.nvim.lua) expToLua;
|
||||||
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
||||||
|
|
||||||
cfg = config.vim.languages.rust;
|
cfg = config.vim.languages.rust;
|
||||||
|
|
||||||
defaultFormat = "rustfmt";
|
defaultFormat = ["rustfmt"];
|
||||||
formats = {
|
formats = {
|
||||||
rustfmt = {
|
rustfmt = {
|
||||||
package = pkgs.rustfmt;
|
command = getExe pkgs.rustfmt;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -79,15 +80,9 @@ in {
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Rust formatter to use";
|
description = "Rust formatter to use";
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
description = "Rust formatter package";
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
dap = {
|
dap = {
|
||||||
|
@ -130,10 +125,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.rust = [cfg.format.type];
|
setupOpts.formatters_by_ft.rust = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -33,14 +33,11 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "sqlfluff";
|
defaultFormat = ["sqlfluff"];
|
||||||
formats = {
|
formats = {
|
||||||
sqlfluff = {
|
sqlfluff = {
|
||||||
package = sqlfluffDefault;
|
command = getExe sqlfluffDefault;
|
||||||
config = {
|
append_args = ["--dialect=${cfg.dialect}"];
|
||||||
command = getExe cfg.format.package;
|
|
||||||
append_args = ["--dialect=${cfg.dialect}"];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,16 +85,10 @@ in {
|
||||||
enable = mkEnableOption "SQL formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "SQL formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "SQL formatter to use";
|
description = "SQL formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "SQL formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
@ -133,8 +124,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.sql = [cfg.format.type];
|
setupOpts.formatters_by_ft.sql = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
setupOpts.formatters =
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -176,18 +176,18 @@
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# TODO: specify packages
|
# TODO: specify packages
|
||||||
defaultFormat = "prettier";
|
defaultFormat = ["prettier"];
|
||||||
formats = {
|
formats = {
|
||||||
prettier = {
|
prettier = {
|
||||||
package = pkgs.prettier;
|
command = getExe pkgs.prettier;
|
||||||
};
|
};
|
||||||
|
|
||||||
prettierd = {
|
prettierd = {
|
||||||
package = pkgs.prettierd;
|
command = getExe pkgs.prettierd;
|
||||||
};
|
};
|
||||||
|
|
||||||
biome = {
|
biome = {
|
||||||
package = pkgs.biome;
|
command = getExe pkgs.biome;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -239,15 +239,9 @@ in {
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
description = "Typescript/Javascript formatter to use";
|
description = "Typescript/Javascript formatter to use";
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
description = "Typescript/Javascript formatter package";
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
@ -309,12 +303,15 @@ in {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts = {
|
setupOpts = {
|
||||||
formatters_by_ft.typescript = [cfg.format.type];
|
formatters_by_ft.typescript = cfg.format.type;
|
||||||
# .tsx files
|
# .tsx files
|
||||||
formatters_by_ft.typescriptreact = [cfg.format.type];
|
formatters_by_ft.typescriptreact = cfg.format.type;
|
||||||
formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
|
@ -91,14 +91,14 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultFormat = "typstfmt";
|
defaultFormat = ["typstfmt"];
|
||||||
formats = {
|
formats = {
|
||||||
typstfmt = {
|
typstfmt = {
|
||||||
package = pkgs.typstfmt;
|
command = getExe pkgs.typstfmt;
|
||||||
};
|
};
|
||||||
# https://github.com/Enter-tainer/typstyle
|
# https://github.com/Enter-tainer/typstyle
|
||||||
typstyle = {
|
typstyle = {
|
||||||
package = pkgs.typstyle;
|
command = getExe pkgs.typstyle;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -124,16 +124,10 @@ in {
|
||||||
enable = mkEnableOption "Typst document formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "Typst document formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = singleOrListOf (enum (attrNames formats));
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Typst formatter to use";
|
description = "Typst formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Typst formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extensions = {
|
extensions = {
|
||||||
|
@ -189,10 +183,13 @@ in {
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
vim.formatter.conform-nvim = {
|
vim.formatter.conform-nvim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
setupOpts.formatters_by_ft.typst = [cfg.format.type];
|
setupOpts.formatters_by_ft.typst = cfg.format.type;
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
setupOpts.formatters =
|
||||||
command = getExe cfg.format.package;
|
mapListToAttrs (name: {
|
||||||
};
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue