mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-06-13 00:08:56 +00:00
languages/haskell.nix: add cabal formatter options
Unwrap cabal-fmt from the haskell-language-server binary, and add an option to configure the executable between cabal-fmt and cabal-gild.
This commit is contained in:
parent
2890e99c72
commit
e7f3af5445
2 changed files with 50 additions and 15 deletions
|
|
@ -4,11 +4,16 @@
|
|||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.meta) getExe';
|
||||
inherit (lib.meta) getExe 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" [];
|
||||
|
|
@ -23,18 +28,16 @@ in {
|
|||
paths = [pkgs.haskellPackages.haskell-language-server];
|
||||
meta.mainProgram = "haskell-language-server-wrapper";
|
||||
buildInputs = [pkgs.makeBinaryWrapper];
|
||||
postBuild = ''
|
||||
wrapProgram $out/bin/haskell-language-server-wrapper \
|
||||
--prefix PATH : ${pkgs.haskellPackages.cabal-fmt}/bin
|
||||
'';
|
||||
}) "haskell-language-server-wrapper")
|
||||
"--lsp"
|
||||
];
|
||||
root_markers = ["hie.yaml" "stack.yaml" "cabal.project" "*.cabal" "package.yaml"];
|
||||
settings = {
|
||||
settings = mkIf cabalFmtCfg.enable {
|
||||
haskell = {
|
||||
# cabal-fmt is an external tool; it is wrapped into the LSP binary's PATH above
|
||||
cabalFormattingProvider = "cabal-fmt";
|
||||
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};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue