diff --git a/lazy-lock.json b/lazy-lock.json index 657a268..97e8596 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -9,6 +9,7 @@ "fd": { "branch": "master", "commit": "4d957d3a630c53fc610b4c835a1ff992f98fa49d" }, "feline.nvim": { "branch": "main", "commit": "9f1313f61a75ec5ebe805fedd46bdc130c420963" }, "gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" }, + "haskell-tools.nvim": { "branch": "master", "commit": "cbfee33efb3d7252453e454d61c6b939539ea35f" }, "idris2-nvim": { "branch": "main", "commit": "8bff02984a33264437e70fd9fff4359679d910da" }, "lazy.nvim": { "branch": "main", "commit": "56ead98e05bb37a4ec28930a54d836d033cf00f2" }, "mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" }, diff --git a/lua/plugins/languages/haskell.lua b/lua/plugins/languages/haskell.lua new file mode 100644 index 0000000..3bf7730 --- /dev/null +++ b/lua/plugins/languages/haskell.lua @@ -0,0 +1,46 @@ +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('lcl', vim.lsp.codelens.run, nil) + + map('lhs', ht.hoogle.hoogle_signature, "Hoogle search for the type signature of the definition under the cursor") + + map('lea', ht.lsp.buf_eval_all, "Evaluate all code snippets") + + map('lrr', ht.repl.toggle, "Toggle a GHCi repl for the current package") + + -- Toggle a GHCi repl for the current buffer + map('lrb', function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) + end, nil) + + map('lrq', ht.repl.quit, "Quit the current GHCi repl") + + vim.notify("Just done seting up hls") + end + end + }) + end, +}