This repository has been archived by the owner. It is now read-only.
DEPRECATED! Interactive Haskell development using GHCi in Neovim
Clone or download
Pull request Compare This branch is 13 commits ahead, 38 commits behind parsonsmatt:master.

README.md

DEPRECATED

THIS FORK HAS BEEN INTEGRATED BACK INTO ITS UPSTREAM AND IS NO LONGER MAINTAINED!

If you are using this plugin since before the deprecation, it's recommended you switch over to https://github.com/parsonsmatt/intero-neovim. It now has support for using any GHCi as a backend, the primary feature of this plugin when it was forked. Thanks for your usage and support!




neovim-ghci

Interactive Haskell development using GHCi in Neovim


This is a fork of intero-neovim that uses regular GHCi, instead of intero. It has fewer features than its Intero counterpart, but does not rely on Stack and Intero.

Some key features:

  • On-the-fly Typechecking

    This plugin reports errors and warnings as you work on your file using the Neomake plugin. Errors appear asynchronously, and don't block the UI.

  • Built-in REPL

    Work with your Haskell code directly in GHCi using Neovim :terminal buffers. Load your file and play around with top-level functions directly.

Demo

asciicast

Installing

This plugin is compatible with pathogen, vim-plug, etc. For example:

Plug 'owickstrom/neovim-ghci'

This plugin requires Cabal, 1.24.0 or higher. Optionally, install Neomake for error reporting.

Quickstart

  • To open the REPL:
    • :GhciOpen
  • To load into the REPL:
    • :GhciLoadCurrentFile
  • To reload whatever's in the REPL:
    • :GhciReload
  • To evaluate an expression from outside the REPL:
    • :GhciEvaluate <expression>, or
    • :GhciEvaluate, and then enter the expression in the prompt.

Usage

Complete usage and configuration information can be found in here:

:help ghci

Example Configuration

These are some suggested settings. This plugin sets up no keybindings by default.

augroup ghciMaps
  au!
  " Maps for ghci. Restrict to Haskell buffers so the bindings don't collide.

  " Background process and window management
  au FileType haskell nnoremap <silent> <leader>gs :GhciStart<CR>
  au FileType haskell nnoremap <silent> <leader>gk :GhciKill<CR>

  " Restarting GHCi might be required if you add new dependencies
  au FileType haskell nnoremap <silent> <leader>gr :GhciRestart<CR>

  " Open GHCi split horizontally
  au FileType haskell nnoremap <silent> <leader>go :GhciOpen<CR>
  " Open GHCi split vertically
  au FileType haskell nnoremap <silent> <leader>gov :GhciOpen<CR><C-W>H
  au FileType haskell nnoremap <silent> <leader>gh :GhciHide<CR>

  " RELOADING (PICK ONE):

  " Automatically reload on save
  au BufWritePost *.hs GhciReload
  " Manually save and reload
  au FileType haskell nnoremap <silent> <leader>wr :w \| :GhciReload<CR>

  " Load individual modules
  au FileType haskell nnoremap <silent> <leader>gl :GhciLoadCurrentModule<CR>
  au FileType haskell nnoremap <silent> <leader>gf :GhciLoadCurrentFile<CR>
augroup END

" GHCi starts automatically. Set this if you'd like to prevent that.
let g:ghci_start_immediately = 0

" Customize how to run GHCi
let g:ghci_command = 'cabal new-repl'
let g:ghci_command_line_options = '-fobject-code'

Using the Stack REPL

If you'd like to use stack repl, instead of plain ghci or cabal repl, you can use something like the following configuration:

let g:ghci_command = 'stack repl'
let g:ghci_command_line_options = '--ghci-options="-fobject-code"'

Using a project specific .nvim.rc, you can also customize the Stack targets for the GHCi session of particular projects:

let g:ghci_command = 'stack repl my-project:test:my-test-suite'

Caveats

  • Running :Neomake! directly will not work. You need to run :GhciReload instead.

  • Some commands may have unexpected side-effects if you have an autocommand that automatically switches to insert mode when entering a terminal buffer.

Contributing

This project welcomes new contributions! Submit pull requests and open issues on GitHub: https://github.com/owickstrom/neovim-ghci

License

BSD3 License, the same license as ghcmod-vim and intero-neovim.