mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-08 22:45:30 +00:00
language/astro: fix prettier, remove prettierd
This commit is contained in:
parent
db30023c78
commit
6b334ad28f
1 changed files with 21 additions and 29 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
self,
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
|
|
@ -8,7 +9,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 coercedTo;
|
||||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics singleOrListOf;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
|
@ -40,23 +41,21 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: specify packages
|
defaultFormat = ["prettier"];
|
||||||
defaultFormat = "prettier";
|
formats = let
|
||||||
formats = {
|
parser = "${self.packages.${pkgs.stdenv.system}.prettier-plugin-astro}/index.js";
|
||||||
|
in {
|
||||||
prettier = {
|
prettier = {
|
||||||
package = pkgs.prettier;
|
command = getExe pkgs.nodePackages.prettier;
|
||||||
};
|
options.ft_parsers.astro = "astro";
|
||||||
|
prepend_args = ["--plugin=${parser}"];
|
||||||
prettierd = {
|
|
||||||
package = pkgs.prettierd;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
biome = {
|
biome = {
|
||||||
package = pkgs.biome;
|
command = getExe pkgs.biome;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: specify packages
|
|
||||||
defaultDiagnosticsProvider = ["eslint_d"];
|
defaultDiagnosticsProvider = ["eslint_d"];
|
||||||
diagnosticsProviders = {
|
diagnosticsProviders = {
|
||||||
eslint_d = let
|
eslint_d = let
|
||||||
|
|
@ -76,6 +75,15 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
formatType =
|
||||||
|
singleOrListOf
|
||||||
|
"vim.languages.astro.format.type"
|
||||||
|
(coercedTo (enum ["prettierd"]) (_:
|
||||||
|
lib.warn
|
||||||
|
"vim.languages.astro.format.type: prettierd is deprecated, use prettier instead"
|
||||||
|
"prettier")
|
||||||
|
(enum (attrNames formats)));
|
||||||
in {
|
in {
|
||||||
options.vim.languages.astro = {
|
options.vim.languages.astro = {
|
||||||
enable = mkEnableOption "Astro language support";
|
enable = mkEnableOption "Astro language support";
|
||||||
|
|
@ -89,7 +97,7 @@ in {
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Astro LSP support" // {default = config.vim.lsp.enable;};
|
enable = mkEnableOption "Astro LSP support" // {default = config.vim.lsp.enable;};
|
||||||
servers = mkOption {
|
servers = mkOption {
|
||||||
type = singleOrListOf (enum (attrNames servers));
|
type = singleOrListOf "vim.languages.astro.lsp.servers" (enum (attrNames servers));
|
||||||
default = defaultServers;
|
default = defaultServers;
|
||||||
description = "Astro LSP server to use";
|
description = "Astro LSP server to use";
|
||||||
};
|
};
|
||||||
|
|
@ -99,16 +107,10 @@ in {
|
||||||
enable = mkEnableOption "Astro formatting" // {default = config.vim.languages.enableFormat;};
|
enable = mkEnableOption "Astro formatting" // {default = config.vim.languages.enableFormat;};
|
||||||
|
|
||||||
type = mkOption {
|
type = mkOption {
|
||||||
type = enum (attrNames formats);
|
type = formatType;
|
||||||
default = defaultFormat;
|
default = defaultFormat;
|
||||||
description = "Astro formatter to use";
|
description = "Astro formatter to use";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
type = package;
|
|
||||||
default = formats.${cfg.format.type}.package;
|
|
||||||
description = "Astro formatter package";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extraDiagnostics = {
|
extraDiagnostics = {
|
||||||
|
|
@ -137,16 +139,6 @@ in {
|
||||||
cfg.lsp.servers;
|
cfg.lsp.servers;
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.format.enable {
|
|
||||||
vim.formatter.conform-nvim = {
|
|
||||||
enable = true;
|
|
||||||
setupOpts.formatters_by_ft.astro = [cfg.format.type];
|
|
||||||
setupOpts.formatters.${cfg.format.type} = {
|
|
||||||
command = getExe cfg.format.package;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(mkIf cfg.extraDiagnostics.enable {
|
(mkIf cfg.extraDiagnostics.enable {
|
||||||
vim.diagnostics.nvim-lint = {
|
vim.diagnostics.nvim-lint = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue