neovim-flake/modules/plugins/languages/haskell.nix

50 lines
1.3 KiB
Nix
Raw Normal View History

2024-09-27 17:44:23 +02:00
{
config,
pkgs,
lib,
...
}: let
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) package;
inherit (lib.nvim.types) mkGrammarOption;
cfg = config.vim.languages.haskell;
in {
options.vim.languages.haskell = {
enable = mkEnableOption "Haskell support";
treesitter = {
enable = mkEnableOption "Haskell treesitter" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "haskell";
};
lsp = {
enable = mkEnableOption "Haskell LSP support (haskell-language-server)" // {default = config.vim.languages.enableLSP;};
package = mkOption {
2024-10-20 12:48:37 +02:00
description = "haskell-language-server package";
2024-09-27 17:44:23 +02:00
type = package;
2024-10-20 12:48:37 +02:00
default = pkgs.haskell-language-server;
2024-09-27 17:44:23 +02:00
};
};
};
config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable {
vim.treesitter.enable = true;
vim.treesitter.grammars = [cfg.treesitter.package];
})
(mkIf cfg.lsp.enable {
vim.lsp.lspconfig.enable = true;
2024-10-20 12:48:37 +02:00
vim.lsp.lspconfig.sources.hls = ''
lspconfig.hls.setup {
2024-09-27 17:44:23 +02:00
capabilities = capabilities,
2024-10-20 12:48:37 +02:00
on_attach = default_on_attach,
cmd = {"${cfg.lsp.package}/bin/haskell-language-server"},
2024-09-27 17:44:23 +02:00
}
'';
})
]);
}