From 2a21c8570e76ed4b85e5d50fd6b564cee2304890 Mon Sep 17 00:00:00 2001 From: siggsy Date: Sun, 19 Oct 2025 14:51:54 +0200 Subject: [PATCH] languages/haskell: share common lsp configuration Some of the LSP configuration is common for both `haskell-tools` and `hls`. Make them consistent with attrset updates. --- modules/plugins/languages/haskell.nix | 82 ++++++++++++++------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/modules/plugins/languages/haskell.nix b/modules/plugins/languages/haskell.nix index d694c6f4..13d91b5f 100644 --- a/modules/plugins/languages/haskell.nix +++ b/modules/plugins/languages/haskell.nix @@ -19,46 +19,52 @@ cfg = config.vim.languages.haskell; defaultServers = ["hls"]; + serverCommon = { + 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 + ''; + }; servers = { - hls = { - enable = true; - cmd = [ "haskell-language-server-wrapper" "--lsp" ]; - 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 - ''; - }; + hls = + serverCommon + // { + enable = true; + cmd = ["haskell-language-server-wrapper" "--lsp"]; + }; - haskell-tools = { - enable = true; - on_attach = - mkLuaInline - /* - lua - */ - '' - function(client, bufnr) - local ht = require("haskell-tools") - local opts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set('n', 'cl', vim.lsp.codelens.run, opts) - vim.keymap.set('n', 'hs', ht.hoogle.hoogle_signature, opts) - vim.keymap.set('n', 'ea', ht.lsp.buf_eval_all, opts) - vim.keymap.set('n', 'rr', ht.repl.toggle, opts) - vim.keymap.set('n', 'rf', function() - ht.repl.toggle(vim.api.nvim_buf_get_name(0)) - end, opts) - vim.keymap.set('n', 'rq', ht.repl.quit, opts) - end - ''; - }; + haskell-tools = + serverCommon + // { + enable = false; + on_attach = + mkLuaInline + /* + lua + */ + '' + function(client, bufnr) + local ht = require("haskell-tools") + local opts = { noremap = true, silent = true, buffer = bufnr } + vim.keymap.set('n', 'cl', vim.lsp.codelens.run, opts) + vim.keymap.set('n', 'hs', ht.hoogle.hoogle_signature, opts) + vim.keymap.set('n', 'ea', ht.lsp.buf_eval_all, opts) + vim.keymap.set('n', 'rr', ht.repl.toggle, opts) + vim.keymap.set('n', 'rf', function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) + end, opts) + vim.keymap.set('n', 'rq', ht.repl.quit, opts) + end + ''; + }; }; in { options.vim.languages.haskell = {