language/haskell: let conform handle cabal formatting

This commit is contained in:
Ching Pei Yang 2026-05-20 16:34:15 +02:00
commit 802206bff4
No known key found for this signature in database
GPG key ID: B3841364253DC4C8
2 changed files with 27 additions and 43 deletions

View file

@ -4,16 +4,11 @@
pkgs,
...
}: let
inherit (lib.meta) getExe getExe';
inherit (lib.meta) getExe';
inherit (lib.modules) mkIf;
inherit (lib.nvim.types) mkLspPresetEnableOption;
cfg = config.vim.lsp.presets.haskell-language-server;
cabalFmtCfg = config.vim.languages.haskell.cabalFormat;
cabalFormats = {
cabal-fmt = pkgs.haskellPackages.cabal-fmt;
cabal-gild = pkgs.haskellPackages.cabal-gild;
};
in {
options.vim.lsp.presets.haskell-language-server = {
enable = mkLspPresetEnableOption "haskell-language-server" "Haskell" [];
@ -32,14 +27,6 @@ in {
"--lsp"
];
root_markers = ["hie.yaml" "stack.yaml" "cabal.project" "*.cabal" "package.yaml"];
settings = mkIf cabalFmtCfg.enable {
haskell = {
cabalFormattingProvider = cabalFmtCfg.type;
# This option is undocumented in the haskell-language-server docs, but it does exist in the plugin API
# https://github.com/haskell/haskell-language-server/blob/f158128ec034bec1667c440262641086bbb4d359/plugins/hls-cabal-fmt-plugin/src/Ide/Plugin/CabalFmt.hs#L51
plugin.${cabalFmtCfg.type}.config.path = getExe cabalFormats.${cabalFmtCfg.type};
};
};
};
};
}