mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-05-19 05:24:22 +00:00
languages/haskell: simplify attach function
This commit is contained in:
parent
dfaa9b4c5a
commit
8a0073182f
1 changed files with 24 additions and 31 deletions
|
|
@ -200,38 +200,31 @@ in {
|
|||
vim = {
|
||||
extraPackages = [haskellPackages.cabal-fmt];
|
||||
startPlugins = ["haskell-tools-nvim"];
|
||||
globals.haskell_tools = let
|
||||
htCfg = cfg.extensions.haskell-tools;
|
||||
keymapDefinitions = options.vim.languages.haskell.extensions.haskell-tools.mappings;
|
||||
mappings = addDescriptionsToMappings htCfg.mappings keymapDefinitions;
|
||||
mkBinding = binding: action:
|
||||
if binding.value != null
|
||||
then "vim.keymap.set('n', ${toLuaObject binding.value}, ${action}, {buffer=bufnr, noremap=true, silent=true, desc=${toLuaObject binding.description}})"
|
||||
else "";
|
||||
generatedOnAttach = mkLuaInline ''
|
||||
function(client, bufnr)
|
||||
local ht = require("haskell-tools")
|
||||
${mkBinding mappings.codeLensRun "vim.lsp.codelens.run"}
|
||||
${mkBinding mappings.hoogleSignature "ht.hoogle.hoogle_signature"}
|
||||
${mkBinding mappings.evalAll "ht.lsp.buf_eval_all"}
|
||||
${mkBinding mappings.replToggle "function() vim.cmd('Haskell repl toggle') end"}
|
||||
${mkBinding mappings.replToggleFile "function() vim.cmd('Haskell repl toggle ' .. vim.api.nvim_buf_get_name(0)) end"}
|
||||
${mkBinding mappings.replQuit "function() vim.cmd('Haskell repl quit') end"}
|
||||
end
|
||||
'';
|
||||
effectiveOnAttach =
|
||||
if htCfg.setupOpts.hls.on_attach != null
|
||||
then htCfg.setupOpts.hls.on_attach
|
||||
else generatedOnAttach;
|
||||
in
|
||||
htCfg.setupOpts
|
||||
// {
|
||||
hls =
|
||||
htCfg.setupOpts.hls
|
||||
// {
|
||||
on_attach = effectiveOnAttach;
|
||||
};
|
||||
globals.haskell_tools = cfg.extensions.haskell-tools.setupOpts;
|
||||
languages.haskell.extensions.haskell-tools.setupOpts = {
|
||||
hls = {
|
||||
on_attach = let
|
||||
htCfg = cfg.extensions.haskell-tools;
|
||||
keymapDefinitions = options.vim.languages.haskell.extensions.haskell-tools.mappings;
|
||||
mappings = addDescriptionsToMappings htCfg.mappings keymapDefinitions;
|
||||
mkBinding = binding: action:
|
||||
if binding.value != null
|
||||
then "vim.keymap.set('n', ${toLuaObject binding.value}, ${action}, {buffer=bufnr, noremap=true, silent=true, desc=${toLuaObject binding.description}})"
|
||||
else "";
|
||||
in
|
||||
mkLuaInline ''
|
||||
function(client, bufnr)
|
||||
local ht = require("haskell-tools")
|
||||
${mkBinding mappings.codeLensRun "vim.lsp.codelens.run"}
|
||||
${mkBinding mappings.hoogleSignature "ht.hoogle.hoogle_signature"}
|
||||
${mkBinding mappings.evalAll "ht.lsp.buf_eval_all"}
|
||||
${mkBinding mappings.replToggle "function() vim.cmd('Haskell repl toggle') end"}
|
||||
${mkBinding mappings.replToggleFile "function() vim.cmd('Haskell repl toggle ' .. vim.api.nvim_buf_get_name(0)) end"}
|
||||
${mkBinding mappings.replQuit "function() vim.cmd('Haskell repl quit') end"}
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue