From c16100e949426f1df94ad24c9570ba17cf49cdaa Mon Sep 17 00:00:00 2001 From: James Brock Date: Fri, 16 Nov 2018 15:23:59 +0900 Subject: [PATCH 1/4] URLs from bitc/hdevtools to hdevtools/hdevtools --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ad733a8..9468cb9 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ hdevtools Vim Plugin ==================== Vim plugin for Haskell development powered by the lightning fast -[hdevtools]() background server. +[hdevtools]() background server. About ----- -[hdevtools]() is a command line program +[hdevtools]() is a command line program powered by the GHC API, that provides services for Haskell development. hdevtools works by running a persistent process in the background, so that your Haskell modules remain in memory, instead of having to reload everything each @@ -23,7 +23,7 @@ Installation ------------ 1. You must install the `hdevtools` command line program, It can be found - here: , or from Hackage: + here: , or from Hackage: $ cabal install hdevtools From 66a4fc462f3ee3bc754807a628b2d920391247ab Mon Sep 17 00:00:00 2001 From: James Brock Date: Sun, 18 Nov 2018 23:36:47 +0900 Subject: [PATCH 2/4] README Recommend -fdefer-type-errors --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 9468cb9..3ec3a8a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,12 @@ appropriate (such as your project's `Session.vim`): Make sure that each GHC option has its own `-g` prefix (don't group multiple options like this: `"-g-isrc\ -Wall"`) +I recommend setting the flag to +[defer GHC type errors to runtime](), +so that Haskell expressions can be typechecked even if type errors +elsewhere in the project would otherwise prevent GHC from compiling. + + let g:hdevtools_options = '-g-fdefer-type-errors' Credits ------- From 85462d9721109db88ce35ed57c14dbfb903854ba Mon Sep 17 00:00:00 2001 From: James Brock Date: Mon, 19 Nov 2018 00:35:03 +0900 Subject: [PATCH 3/4] README Instructions for HdevtoolsInfo --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3ec3a8a..bdd4dad 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,8 @@ Installation like: au FileType haskell nnoremap :HdevtoolsType - au FileType haskell nnoremap :HdevtoolsClear + au FileType haskell nnoremap :HdevtoolsInfo + au FileType haskell nnoremap :HdevtoolsClear Features @@ -61,6 +62,9 @@ The type for the expression under the cursor will be printed, and the expression will be highlighted. Repeated presses will expand the expression that is examined. +To get information from GHC about the identifier under cursor, +execute `HdevtoolsInfo` (or press the `` key as configured above). + You can execute `HdevtoolsClear` to get rid of the highlighting. Customization From 699761b7f9722b971b76c595fca153314e57c159 Mon Sep 17 00:00:00 2001 From: James Brock Date: Fri, 16 Nov 2018 23:05:30 +0900 Subject: [PATCH 4/4] Stack support If a `stack.yaml` file is found in the pwd, then hdevtools commands will be invoked by `stack exec --package hdevtools hdevtools` instead of `hdevtools`. `hdevtools` must be built with the same version of GHC as the project being inspected. With Stack support for vim-hdevtools, `hdevtools` will be built with the same version of GHC referred to by the `stack.yaml` resolver for the project, and `hdevtools` will be automatically installed locally the first time a vim-hdevtools command is run. Stack support must be enabled by `g:hdevtools_stack = 1`, otherwise vim-hdevtools will revert to the usual behavior of always looking for `hdevtools` in the `$PATH`. This will provide continuity for users who would be surprised by the new behavior if they weren't expecting it. In the future, perhaps Stack support could be enabled by default. --- README.md | 46 +++++++++++++++++++++++++++++----- autoload/hdevtools.vim | 7 ++---- ftplugin/haskell/hdevtools.vim | 11 +++++++- 3 files changed, 52 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index bdd4dad..623d828 100644 --- a/README.md +++ b/README.md @@ -19,21 +19,55 @@ editor. This is the Vim plugin that integrates Vim with hdevtools. -Installation +Requirements ------------ -1. You must install the `hdevtools` command line program, It can be found - here: , or from Hackage: +The *vim-hdevtools* plugin requires a way to run `hdevtools`. Here are the +ways to make `hdevtools` available to the plugin. + +### Global `hdevtools` + +Install the `hdevtools` command line program so that it is on your +executable `$PATH`. + +Get it from Github: + +Or from Hackage: + + $ cabal install hdevtools + +Or from Stackage: + + $ stack install hdevtools - $ cabal install hdevtools +Note that `hdevtools` must be built with the same version of GHC as the +project which you will be editing. + +### Local `hdevtools` with `stack` + +If your project is built with [stack]() and +if you run Vim from the directory that contains `stack.yaml`, then +the *vim-hdevtools* plugin can employ `stack` to automatically install +`hdevtools` built with the same version of GHC indicated by the resolver +in your `stack.yaml`. This will not conflict with any other installations +of `hdevtools` on your system. + +If you want the *vim-hdevtools* plugin to use `stack`, +you have to enable this feature in your `.vimrc` like so: + + let g:hdevtools_stack = 1 + + +Installation +------------ -2. Install this plugin. [pathogen.vim]() +1. Install this plugin. [pathogen.vim]() is the recommended way: cd ~/.vim/bundle git clone https://github.com/bitc/vim-hdevtools.git -3. Configure your keybindings in your `.vimrc` file. I recommend something +2. Configure your keybindings in your `.vimrc` file. I recommend something like: au FileType haskell nnoremap :HdevtoolsType diff --git a/autoload/hdevtools.vim b/autoload/hdevtools.vim index aca1e2f..b4bcb77 100644 --- a/autoload/hdevtools.vim +++ b/autoload/hdevtools.vim @@ -477,9 +477,7 @@ function! s:on_leave() endfunction function! hdevtools#build_command(command, args) - let l:cmd = 'hdevtools' - let l:cmd = l:cmd . ' ' . a:command . ' ' - + let l:cmd = g:hdevtools_exe . ' ' . a:command . ' ' let l:cmd = l:cmd . get(g:, 'hdevtools_options', '') . ' ' let l:cmd = l:cmd . a:args return l:cmd @@ -487,8 +485,7 @@ endfunction " Does not include g:hdevtools_options function! hdevtools#build_command_bare(command, args) - let l:cmd = 'hdevtools' - let l:cmd = l:cmd . ' ' . a:command . ' ' + let l:cmd = g:hdevtools_exe . ' ' . a:command . ' ' let l:cmd = l:cmd . a:args return l:cmd endfunction diff --git a/ftplugin/haskell/hdevtools.vim b/ftplugin/haskell/hdevtools.vim index 1b2f241..4ac3323 100644 --- a/ftplugin/haskell/hdevtools.vim +++ b/ftplugin/haskell/hdevtools.vim @@ -6,7 +6,16 @@ let b:did_ftplugin_hdevtools = 1 if !exists('s:has_hdevtools') let s:has_hdevtools = 0 - if !executable('hdevtools') + " For stack support, vim must be started in the directory containing stack.yaml + if exists('g:hdevtools_stack') && g:hdevtools_stack && filereadable("stack.yaml") + if !executable('stack') + call hdevtools#print_error('hdevtools: stack.yaml found, but stack is not executable!') + finish + endif + let g:hdevtools_exe = 'stack exec --silent --no-ghc-package-path --package hdevtools hdevtools --' + elseif executable('hdevtools') + let g:hdevtools_exe = 'hdevtools' + else call hdevtools#print_error('hdevtools: hdevtools is not executable!') finish endif