Compare commits

..

2 commits

Author SHA1 Message Date
Artur Manuel
9d8146e792
Merge f311be9a2d into a0a57757a0 2024-12-16 18:46:42 +00:00
Artur Manuel
f311be9a2d plugins/languages: add haskell support 2024-12-16 18:46:27 +00:00

View file

@ -4,28 +4,27 @@
pkgs, pkgs,
... ...
}: let }: let
cfg = config.vim.languages.haskell;
inherit (builtins) isList; inherit (builtins) isList;
inherit (lib) options modules nvim strings types meta; inherit (lib) options modules nvim strings types;
inherit (types) either package listOf str; inherit (types) either package listOf str;
inherit (options) mkEnableOption mkOption; inherit (options) mkEnableOption mkOption;
inherit (strings) optionalString; inherit (strings) optionalString;
inherit (meta) getExe;
inherit (modules) mkIf mkMerge; inherit (modules) mkIf mkMerge;
inherit (nvim) mkGrammarOption; inherit (nvim.types) mkGrammarOption;
inherit (nvim.dag) entryAnywhere; inherit (nvim.dag) entryAnywhere;
inherit (nvim.lua) expToLua; inherit (nvim.lua) expToLua;
inherit (pkgs) haskellPackages; inherit (pkgs) haskellPackages;
cfg = config.vim.languages.haskell;
in { in {
options.vim.languages.haskell = { options.vim.languages.haskell = {
enable = mkEnableOption "Haskell support"; enable = mkEnableOption "Haskell support";
treesitter = { treesitter = {
enable = mkEnableOption "Treesitter support for Haskell"; enable = mkEnableOption "Treesitter support for Haskell" // {default = config.vim.languages.enableTreesitter;};
package = mkGrammarOption pkgs "haskell"; package = mkGrammarOption pkgs "haskell";
}; };
lsp = { lsp = {
enable = mkEnableOption "LSP support for Haskell"; enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.languages.enableLSP;};
package = mkOption { package = mkOption {
description = "Haskell LSP package or command to run the Haskell LSP"; description = "Haskell LSP package or command to run the Haskell LSP";
default = haskellPackages.haskell-language-server; default = haskellPackages.haskell-language-server;
@ -34,7 +33,7 @@ in {
}; };
dap = { dap = {
enable = mkEnableOption "DAP support for Haskell"; enable = mkEnableOption "DAP support for Haskell" // {default = config.vim.languages.enableDAP;};
package = mkOption { package = mkOption {
description = "Haskell DAP package or command to run the Haskell DAP"; description = "Haskell DAP package or command to run the Haskell DAP";
default = haskellPackages.haskell-debug-adapter; default = haskellPackages.haskell-debug-adapter;
@ -44,8 +43,10 @@ in {
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {
vim.treesitter.enable = true; vim.treesitter = {
vim.treesitter.grammars = [cfg.treesitter.package]; enable = true;
grammars = [cfg.treesitter.package];
};
}) })
(mkIf (cfg.dap.enable || cfg.lsp.enable) { (mkIf (cfg.dap.enable || cfg.lsp.enable) {
vim = { vim = {
@ -65,7 +66,7 @@ in {
cmd = ${ cmd = ${
if isList cfg.lsp.package if isList cfg.lsp.package
then expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{"${getExe cfg.lsp.package}"}'' else ''{"${cfg.lsp.package}/bin/haskell-language-server-wrapper"}''
}, },
on_attach = function(client, bufnr, ht) on_attach = function(client, bufnr, ht)
default_on_attach(client, bufnr, ht) default_on_attach(client, bufnr, ht)
@ -86,7 +87,7 @@ in {
cmd = ${ cmd = ${
if isList cfg.dap.package if isList cfg.dap.package
then expToLua cfg.dap.package then expToLua cfg.dap.package
else ''${getExe cfg.dap.package}'' else ''${cfg.dap.package}/bin/haskell-debug-adapter''
}, },
}, },
''} ''}