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