dotfiles-nvim/lua/plugins/languages/haskell.lua

47 lines
1.5 KiB
Lua
Raw Permalink Normal View History

return {
'mrcjkb/haskell-tools.nvim',
version = '^4',
lazy = false, -- This plugin is already lazy
cond = vim.fn.executable("haskell-language-server") ~= 0,
init = function()
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local client = vim.lsp.get_client_by_id(ev.data.client_id)
if client ~= nil and client.name == "haskell-tools.nvim" then
local ht = require('haskell-tools')
local bufnr = ev.buf
local map = function(keys, action, desc)
local opts = { noremap = false, silent = true, buffer = bufnr }
if desc ~= nil then
opts.desc = desc
end
vim.keymap.set("n", keys, action, opts)
end
-- haskell-language-server relies heavily on codeLenses,
-- so auto-refresh (see advanced configuration) is enabled by default
map('<space>lcl', vim.lsp.codelens.run, nil)
map('<space>lhs', ht.hoogle.hoogle_signature, "Hoogle search for the type signature of the definition under the cursor")
map('<space>lea', ht.lsp.buf_eval_all, "Evaluate all code snippets")
map('<leader>lrr', ht.repl.toggle, "Toggle a GHCi repl for the current package")
-- Toggle a GHCi repl for the current buffer
map('<leader>lrb', function()
ht.repl.toggle(vim.api.nvim_buf_get_name(0))
end, nil)
map('<leader>lrq', ht.repl.quit, "Quit the current GHCi repl")
vim.notify("Just done seting up hls")
end
end
})
end,
}