From a5c7553632b043380491abd3251de72e8ac15d04 Mon Sep 17 00:00:00 2001 From: Maciej Jur Date: Mon, 10 Jul 2023 15:18:34 +0200 Subject: [PATCH] Add haskell tools --- nvim/ftplugin/haskell.lua | 32 ++++++++++++++++++++++++++++++++ nvim/lazy-lock.json | 1 + nvim/lua/configs/treesitter.lua | 2 ++ nvim/lua/plugins.lua | 20 ++++++++++++++------ 4 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 nvim/ftplugin/haskell.lua diff --git a/nvim/ftplugin/haskell.lua b/nvim/ftplugin/haskell.lua new file mode 100644 index 0000000..444ffa6 --- /dev/null +++ b/nvim/ftplugin/haskell.lua @@ -0,0 +1,32 @@ +local ht = require('haskell-tools') +local def_opts = { noremap = true, silent = true, } +ht.start_or_attach { + hls = { + on_attach = function(client, bufnr) + local opts = vim.tbl_extend('keep', def_opts, { buffer = bufnr, }) + -- haskell-language-server relies heavily on codeLenses, + -- so auto-refresh (see advanced configuration) is enabled by default + vim.keymap.set('n', 'ca', 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) + end, + }, +} + +-- Suggested keymaps that do not depend on haskell-language-server: +local bufnr = vim.api.nvim_get_current_buf() +-- set buffer = bufnr in ftplugin/haskell.lua +local opts = { noremap = true, silent = true, buffer = bufnr } + +-- Toggle a GHCi repl for the current package +vim.keymap.set('n', 'rr', ht.repl.toggle, opts) +-- Toggle a GHCi repl for the current buffer +vim.keymap.set('n', 'rf', function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) +end, def_opts) +vim.keymap.set('n', 'rq', ht.repl.quit, opts) + +-- Detect nvim-dap launch configurations +-- (requires nvim-dap and haskell-debug-adapter) +-- ht.dap.discover_configurations(bufnr) + diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 51979b1..9f39e48 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -1,4 +1,5 @@ { + "haskell-tools.nvim": { "branch": "1.x.x", "commit": "2c8cb26417cb4ce6f4271efb72578576464a5424" }, "kanagawa.nvim": { "branch": "master", "commit": "1749cea392acb7d1548a946fcee1e6f1304cd3cb" }, "lazy.nvim": { "branch": "main", "commit": "da8b00581a52f5f87ad2aba9f52171fda7491f18" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, diff --git a/nvim/lua/configs/treesitter.lua b/nvim/lua/configs/treesitter.lua index 52fffc8..e6b170d 100644 --- a/nvim/lua/configs/treesitter.lua +++ b/nvim/lua/configs/treesitter.lua @@ -16,6 +16,8 @@ return function() "markdown", -- nix "nix", + -- haskell + "haskell", -- latex "latex", "bibtex", -- misc diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 2e9288a..181fd47 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -3,6 +3,14 @@ return { "nvim-telescope/telescope.nvim", dependencies = { "nvim-lua/plenary.nvim" }, }, + { + "nvim-treesitter/nvim-treesitter", + config = require "configs/treesitter", + build = ":TSUpdate", + init = function() + vim.treesitter.language.register("markdown", "mdx") + end + }, { "neovim/nvim-lspconfig", config = require "configs/lspconfig", @@ -12,12 +20,12 @@ return { config = require "configs/rust-tools", }, { - "nvim-treesitter/nvim-treesitter", - config = require "configs/treesitter", - build = ":TSUpdate", - init = function() - vim.treesitter.language.register("markdown", "mdx") - end + "mrcjkb/haskell-tools.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim", + }, + branch = "1.x.x", }, { "andweeb/presence.nvim",