dotfiles/nvim/lua/config/plugins/haskell-tools.lua

33 lines
979 B
Lua
Raw Normal View History

2024-01-23 22:23:58 +01:00
local H = require 'config.helpers'
local n = H.keymap 'n'
2023-08-20 14:27:47 +02:00
2023-07-23 01:34:24 +02:00
2023-12-24 22:54:03 +01:00
---@param buffer number
---@param ht HaskellTools
local function on_attach(_, buffer, ht)
n '<leader>hc' (vim.lsp.codelens.run) {'Run codelens', buffer}
n '<leader>hs' (ht.hoogle.hoogle_signature) {'Hoogle: search', buffer}
n '<leader>he' (ht.lsp.buf_eval_all) {'Haskell: eval all', buffer}
2023-07-23 01:34:24 +02:00
local function repl_file()
local name = vim.api.nvim_buf_get_name(0)
ht.repl.toggle(name)
end
2023-07-23 01:34:24 +02:00
2023-12-24 22:54:03 +01:00
n '<leader>rf' (repl_file) 'Repl: Toggle GHCi for the current buffer'
n '<leader>rr' (ht.repl.toggle) {'Repl: Toggle GHCi for the current package', buffer}
n '<leader>rq' (ht.repl.quit) {'Repl: Quit', buffer}
2023-07-23 01:34:24 +02:00
-- Detect nvim-dap launch configurations
-- (requires nvim-dap and haskell-debug-adapter)
-- ht.dap.discover_configurations(bufnr)
end
2023-08-20 14:27:47 +02:00
2024-01-23 22:23:58 +01:00
return function()
vim.g.haskell_tools = {
---@type HaskellLspClientOpts`
hls = { on_attach = on_attach }
}
end