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.
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.
- 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.
Complete usage and configuration information can be found in here:
:help ghci
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>
" 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'
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'
-
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.
This project welcomes new contributions! Submit pull requests and open issues on GitHub: https://github.com/owickstrom/neovim-ghci
BSD3 License, the same license as ghcmod-vim and intero-neovim.