mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-12-08 13:13:55 +00:00
languages/formatters: allow multiple formatters (#1103)
* language/python: allow multiple formatters * package: add prettier-plugin-astro * language/astro: fix prettier, remove prettierd * package: add prettier-plugin-svelte * language/svelte: fix prettier, remove prettierd * languages: allow listOf format.type * deprecations: add warnings for removed format options * ruby: remove unused variable * nix: fix outdated references to format.package * docs: update release note * treewide: warn deprecation in singleOrListOf * conform: add definitions for setupOpts.formatters
This commit is contained in:
parent
a87439ed3c
commit
d5da1a14c3
47 changed files with 641 additions and 488 deletions
|
|
@ -10,7 +10,7 @@
|
|||
inherit (lib.meta) getExe;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib.types) bool enum package;
|
||||
inherit (lib.nvim.types) mkGrammarOption singleOrListOf;
|
||||
inherit (lib.nvim.types) mkGrammarOption deprecatedSingleOrListOf;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
||||
|
|
@ -59,19 +59,16 @@
|
|||
};
|
||||
};
|
||||
|
||||
defaultFormat = "gofmt";
|
||||
defaultFormat = ["gofmt"];
|
||||
formats = {
|
||||
gofmt = {
|
||||
package = pkgs.go;
|
||||
config.command = "${cfg.format.package}/bin/gofmt";
|
||||
command = "${pkgs.go}/bin/gofmt";
|
||||
};
|
||||
gofumpt = {
|
||||
package = pkgs.gofumpt;
|
||||
config.command = getExe cfg.format.package;
|
||||
command = getExe pkgs.gofumpt;
|
||||
};
|
||||
golines = {
|
||||
package = pkgs.golines;
|
||||
config.command = "${cfg.format.package}/bin/golines";
|
||||
command = "${pkgs.golines}/bin/golines";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -95,7 +92,7 @@ in {
|
|||
enable = mkEnableOption "Go LSP support" // {default = config.vim.lsp.enable;};
|
||||
|
||||
servers = mkOption {
|
||||
type = singleOrListOf (enum (attrNames servers));
|
||||
type = deprecatedSingleOrListOf "vim.language.go.lsp.servers" (enum (attrNames servers));
|
||||
default = defaultServers;
|
||||
description = "Go LSP server to use";
|
||||
};
|
||||
|
|
@ -113,15 +110,9 @@ in {
|
|||
|
||||
type = mkOption {
|
||||
description = "Go formatter to use";
|
||||
type = enum (attrNames formats);
|
||||
type = deprecatedSingleOrListOf "vim.language.go.format.type" (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Go formatter package";
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
|
|
@ -163,8 +154,15 @@ in {
|
|||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.go = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = formats.${cfg.format.type}.config;
|
||||
setupOpts = {
|
||||
formatters_by_ft.go = cfg.format.type;
|
||||
formatters =
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = formats.${name};
|
||||
})
|
||||
cfg.format.type;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue