mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-08 22:45:30 +00:00
languages/haskell: separate hls and haskell-tools
haskell-tools.nvim supports configuring lsp through vim.lsp.haskell-tools table. Add it as a separate option of possible language servers
This commit is contained in:
parent
3e48f13c3c
commit
1bc364b5ae
1 changed files with 28 additions and 23 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (builtins) isList attrNames;
|
inherit (builtins) isList attrNames elem;
|
||||||
inherit (lib.types) either package enum listOf str;
|
inherit (lib.types) either package enum listOf str;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
inherit (lib.nvim.dag) entryAfter;
|
inherit (lib.nvim.dag) entryAfter;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
inherit (lib.meta) getExe';
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (pkgs) haskellPackages;
|
inherit (pkgs) haskellPackages;
|
||||||
|
|
||||||
|
|
@ -21,9 +21,23 @@
|
||||||
defaultServers = ["hls"];
|
defaultServers = ["hls"];
|
||||||
servers = {
|
servers = {
|
||||||
hls = {
|
hls = {
|
||||||
enable = false;
|
enable = true;
|
||||||
cmd = [(getExe' pkgs.haskellPackages.haskell-language-server "haskell-language-server-wrapper") "--lsp"];
|
|
||||||
filetypes = ["haskell" "lhaskell"];
|
filetypes = ["haskell" "lhaskell"];
|
||||||
|
root_dir =
|
||||||
|
mkLuaInline
|
||||||
|
/*
|
||||||
|
lua
|
||||||
|
*/
|
||||||
|
''
|
||||||
|
function(bufnr, on_dir)
|
||||||
|
local fname = vim.api.nvim_buf_get_name(bufnr)
|
||||||
|
on_dir(util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project', '*.cabal', 'package.yaml')(fname))
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
haskell-tools = {
|
||||||
|
enable = true;
|
||||||
on_attach =
|
on_attach =
|
||||||
mkLuaInline
|
mkLuaInline
|
||||||
/*
|
/*
|
||||||
|
|
@ -43,23 +57,6 @@
|
||||||
vim.keymap.set('n', '<localleader>rq', ht.repl.quit, opts)
|
vim.keymap.set('n', '<localleader>rq', ht.repl.quit, opts)
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
root_dir =
|
|
||||||
mkLuaInline
|
|
||||||
/*
|
|
||||||
lua
|
|
||||||
*/
|
|
||||||
''
|
|
||||||
function(bufnr, on_dir)
|
|
||||||
local fname = vim.api.nvim_buf_get_name(bufnr)
|
|
||||||
on_dir(util.root_pattern('hie.yaml', 'stack.yaml', 'cabal.project', '*.cabal', 'package.yaml')(fname))
|
|
||||||
end
|
|
||||||
'';
|
|
||||||
settings = {
|
|
||||||
haskell = {
|
|
||||||
formattingProvider = "ormolu";
|
|
||||||
cabalFormattingProvider = "cabalfmt";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
|
@ -98,7 +95,16 @@ in {
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf (cfg.dap.enable || cfg.lsp.enable) {
|
(mkIf cfg.lsp.enable {
|
||||||
|
vim.lsp.servers =
|
||||||
|
mapListToAttrs (n: {
|
||||||
|
name = n;
|
||||||
|
value = servers.${n};
|
||||||
|
})
|
||||||
|
cfg.lsp.servers;
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf (cfg.dap.enable || (cfg.lsp.enable && elem "haskell-tools" cfg.lsp.servers)) {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["haskell-tools-nvim"];
|
startPlugins = ["haskell-tools-nvim"];
|
||||||
luaConfigRC.haskell-tools-nvim =
|
luaConfigRC.haskell-tools-nvim =
|
||||||
|
|
@ -113,7 +119,6 @@ in {
|
||||||
enable = true,
|
enable = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
hls = ${toLuaObject servers.hls},
|
|
||||||
''}
|
''}
|
||||||
${optionalString cfg.dap.enable ''
|
${optionalString cfg.dap.enable ''
|
||||||
dap = {
|
dap = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue