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
|
|
@ -8,8 +8,8 @@
|
|||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
||||
inherit (lib.types) package enum;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf;
|
||||
inherit (lib.types) enum;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
||||
cfg = config.vim.languages.ruby;
|
||||
|
|
@ -49,11 +49,10 @@
|
|||
|
||||
# testing
|
||||
|
||||
defaultFormat = "rubocop";
|
||||
defaultFormat = ["rubocop"];
|
||||
formats = {
|
||||
rubocop = {
|
||||
# TODO: is this right?
|
||||
package = pkgs.rubyPackages.rubocop;
|
||||
command = getExe pkgs.rubyPackages.rubocop;
|
||||
};
|
||||
};
|
||||
|
||||
|
|
@ -61,7 +60,6 @@
|
|||
diagnosticsProviders = {
|
||||
rubocop = {
|
||||
package = pkgs.rubyPackages.rubocop;
|
||||
config.command = getExe cfg.format.package;
|
||||
};
|
||||
};
|
||||
in {
|
||||
|
|
@ -77,7 +75,7 @@ in {
|
|||
enable = mkEnableOption "Ruby LSP support" // {default = config.vim.lsp.enable;};
|
||||
|
||||
servers = mkOption {
|
||||
type = singleOrListOf (enum (attrNames servers));
|
||||
type = deprecatedSingleOrListOf "vim.language.ruby.lsp.servers" (enum (attrNames servers));
|
||||
default = defaultServers;
|
||||
description = "Ruby LSP server to use";
|
||||
};
|
||||
|
|
@ -87,16 +85,10 @@ in {
|
|||
enable = mkEnableOption "Ruby formatter support" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
type = enum (attrNames formats);
|
||||
type = deprecatedSingleOrListOf "vim.language.ruby.format.type" (enum (attrNames formats));
|
||||
default = defaultFormat;
|
||||
description = "Ruby formatter to use";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
description = "Ruby formatter package";
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
|
|
@ -130,9 +122,14 @@ in {
|
|||
(mkIf cfg.format.enable {
|
||||
vim.formatter.conform-nvim = {
|
||||
enable = true;
|
||||
setupOpts.formatters_by_ft.ruby = [cfg.format.type];
|
||||
setupOpts.formatters.${cfg.format.type} = {
|
||||
command = getExe cfg.format.package;
|
||||
setupOpts = {
|
||||
formatters_by_ft.ruby = 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