From 415ed89340f91bda3807bd6b3e0c5e90b8506646 Mon Sep 17 00:00:00 2001 From: Soliprem Date: Fri, 27 Sep 2024 17:44:23 +0200 Subject: [PATCH] haskell: haskell support --- modules/plugins/languages/haskell.nix | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 modules/plugins/languages/haskell.nix diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix new file mode 100644 index 0000000..b2df406 --- /dev/null +++ b/modules/plugins/languages/haskell.nix @@ -0,0 +1,49 @@ +{ + 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 { + description = "haskell_ls package"; + type = package; + default = pkgs.haskellPackages.haskell-language-server; + }; + }; + }; + 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; + vim.lsp.lspconfig.sources.haskell-ls = '' + lspconfig.haskell_ls.setup { + capabilities = capabilities, + on_attach=default_on_attach, + cmd = "${cfg.lsp.package}/bin/haskell-language-server-wrapper", + } + ''; + }) + ]); +}