diff options
Diffstat (limited to '.config/nvim/ftplugin/haskell.lua')
| -rw-r--r-- | .config/nvim/ftplugin/haskell.lua | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/.config/nvim/ftplugin/haskell.lua b/.config/nvim/ftplugin/haskell.lua new file mode 100644 index 0000000..6d06780 --- /dev/null +++ b/.config/nvim/ftplugin/haskell.lua @@ -0,0 +1,42 @@ +vim.g.haskell_enable_quantification = 1 -- to enable highlighting of `forall` +vim.g.haskell_enable_recursivedo = 1 -- to enable highlighting of `mdo` and `rec` +vim.g.haskell_enable_arrowsyntax = 1 -- to enable highlighting of `proc` +vim.g.haskell_enable_pattern_synonyms = 1 -- to enable highlighting of `pattern` +vim.g.haskell_enable_typeroles = 1 -- to enable highlighting of type roles +vim.g.haskell_enable_static_pointers = 1 -- to enable highlighting of `static` +vim.g.haskell_backpack = 1 -- to enable highlighting of backpack keywords + +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', '<space>ca', vim.lsp.codelens.run, opts) + vim.keymap.set('n', '<space>hs', ht.hoogle.hoogle_signature, opts) + vim.keymap.set('n', '<space>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 } + +-- enable hovering +vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + +-- Toggle a GHCi repl for the current package +vim.keymap.set('n', '<leader>rr', ht.repl.toggle, opts) +-- Toggle a GHCi repl for the current buffer +vim.keymap.set('n', '<leader>rf', function() + ht.repl.toggle(vim.api.nvim_buf_get_name(0)) +end, def_opts) +vim.keymap.set('n', '<leader>rq', ht.repl.quit, opts) + +-- Detect nvim-dap launch configurations +-- (requires nvim-dap and haskell-debug-adapter) +ht.dap.discover_configurations(bufnr) |
