From 5f09376d46db9baf43991bb393f56ffea48c3757 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Date: Sat, 9 Dec 2017 13:05:53 -0500 Subject: [PATCH 1/4] Use https://github.com/google/vimdoc for helpfile generation Manually crafting vim helpfiles is cumbersome and hard to maintain, This can lead to outdated helpfiles and inconsistent formatting. `vimdoc`, as with all software, is not perfect. Its automation comes at the price of buying into the rigidity of the formatting it provides and it many cases it's not clear how to acomplish something except through trial and error. The documentation is lacking in that respect. In my musings I've found these some things `vimdoc` does not handle (not exhaustive): - Automatic generation of mapping documentation - Validation of settings, commands, ... when using their corresponding directives (`@setting()`, `@command()`, ...) - Interspersing documentation in generated sections. For example, arbitrary blocks of documentation in between commands. I still think that despite its shortcomings, vimdoc can potentially save precious time to developers of the plugin, thus lowering the barrier to contributions. --- after/ftplugin/haskell/intero.vim | 4 - autoload/intero/process.vim | 9 +- autoload/intero/targets.vim | 5 - doc/intero.txt | 391 +++++++++++++----------------- plugin/intero.vim | 324 ++++++++++++++++++++++--- 5 files changed, 467 insertions(+), 266 deletions(-) diff --git a/after/ftplugin/haskell/intero.vim b/after/ftplugin/haskell/intero.vim index 2378be8..8736027 100644 --- a/after/ftplugin/haskell/intero.vim +++ b/after/ftplugin/haskell/intero.vim @@ -3,10 +3,6 @@ if exists('b:did_ftplugin_intero') && b:did_ftplugin_intero endif let b:did_ftplugin_intero = 1 -if !exists('g:intero_start_immediately') - let g:intero_start_immediately = 1 -endif - if g:intero_start_immediately call intero#process#start() endif diff --git a/autoload/intero/process.vim b/autoload/intero/process.vim index ed7540b..4e6a716 100644 --- a/autoload/intero/process.vim +++ b/autoload/intero/process.vim @@ -222,10 +222,7 @@ function! s:start_buffer(height) abort " ID of the buffer. exe 'below ' . a:height . ' split' - let l:invocation = 'ghci --with-ghc intero' - if exists('g:intero_ghci_options') - let l:invocation .= ' --ghci-options="' . g:intero_ghci_options . '"' - endif + let l:invocation = 'ghci --with-ghc intero' . g:intero_ghci_options enew silent call termopen('stack ' @@ -248,10 +245,6 @@ function! s:start_buffer(height) abort endfunction function! s:on_stdout(jobid, lines, event) abort - if !exists('g:intero_prompt_regex') - let g:intero_prompt_regex = '[^-]> ' - endif - for l:line_seg in a:lines let s:current_line = s:current_line . l:line_seg diff --git a/autoload/intero/targets.vim b/autoload/intero/targets.vim index 99939de..da6ab97 100644 --- a/autoload/intero/targets.vim +++ b/autoload/intero/targets.vim @@ -7,11 +7,6 @@ scriptencoding utf-8 " component of a Haskell package. """"""""""" -if (!exists('g:intero_load_targets')) - " A list of load targets. - let g:intero_load_targets = [] -endif - if (!exists('g:intero_stack_targets')) " A cached list of the stack targets. let g:intero_stack_targets = [] diff --git a/doc/intero.txt b/doc/intero.txt index 1044421..d88fc32 100644 --- a/doc/intero.txt +++ b/doc/intero.txt @@ -1,5 +1,5 @@ -*intero.txt* Complete interactive program development for Haskell -*intero* *intero-neovim* +*intero.txt* + _ _ _ ~ (_)_ __ | |_ ___ _ __ ___ _ __ ___ _____ _(_)_ __ ___ ~ @@ -8,28 +8,24 @@ |_|_| |_|\__\___|_| \___/ |_| |_|\___|\___/ \_/ |_|_| |_| |_|~ ~ -============================================================================= -CONTENTS *intero-contents* + Complete interactive program development for Haskell + - 1. FEATURES .............................. |intero-features| - 2. OVERVIEW .............................. |intero-overview| - 3. USAGE ................................. |intero-usage| - 3.1 The intero Package ................. |intero-package| - 3.2 Intero Background Process .......... |intero-backend| - 3.3 The GHCi REPL Buffer ............... |intero-repl| - 3.4 Loading Code ....................... |intero-load| - 3.5 Inspecting Types ................... |intero-types| - 3.6 Switching Targets .................. |intero-targets| - 4. CONFIGURATION ......................... |intero-config| - 5. CAVEATS ............................... |intero-caveats| - 6. LICENSE ............................... |intero-license| - 7. CREDITS ............................... |intero-credits| - -============================================================================= -FEATURES *intero-features* - -For screenshots and images, see the homepage on GitHub: -https://github.com/parsonsmatt/intero-neovim +Matt Parsons *intero* + +============================================================================== +CONTENTS *intero-contents* + 1. Introduction...............................................|intero-intro| + 2. Usage......................................................|intero-usage| + 3. Configuration.............................................|intero-config| + 4. Commands................................................|intero-commands| + 5. Mappings................................................|intero-mappings| + 6. Caveats..................................................|intero-caveats| + 7. License..................................................|intero-license| + 8. Credits..................................................|intero-credits| + +============================================================================== +INTRODUCTION *intero-intro* Designed for Stack~ @@ -69,37 +65,19 @@ Easy Target Switching~ Intero makes working with multiple stack targets simple. Jump between your app and test suite seamlessly. -============================================================================= -OVERVIEW *intero-overview* - -To open the REPL: |:InteroOpen| -To load into the REPL: |:InteroLoadCurrentFile| -To reload whatever's in the REPL: |:InteroReload| -To get the type of the current identifier: |InteroGenericType| - (requires binding a key to this) -To jump to a definition: first |:InteroLoadCurrentFile| - then |:InteroGoToDef|. -To switch targets: |:InteroSetTargets| - :InteroClearTargets - :InteroUseAllTargets - -============================================================================= +============================================================================== USAGE *intero-usage* -The goal of Intero is to Just Work™. Most of the hard work is done behind the -scenes. - - -The intero Package~ *intero-package* + `intero-neovim` works by using Stack to build the `intero` package into your local project. The installation is completely automated by the plugin; you never have to install the `intero` package yourself. -Every time you open a Haskell file in a new Stack project, we'll run -`stack build intero` for this LTS release and GHC version. Stack then caches -the installation, so it's faster the next time you re-use the same LTS release -and GHC version in a project. +Every time you open a Haskell file in a new Stack project, we'll run `stack +build intero` for this LTS release and GHC version. Stack then caches the +installation, so it's faster the next time you re-use the same LTS release and +GHC version in a project. Note that due to Stack's global-project, one-off files which aren't managed by Stack will always re-use the same global `intero` build. This makes working @@ -108,9 +86,8 @@ with one-off files as painless as whole projects. Some people might want to control when (and whether) `intero` is built after opening a Haskell file. See |g:intero_start_immediately|. - -Intero Background Process~ *intero-backend* + `intero-neovim` maintains a GHCi process running in the background. This works using Neovim's asynchronous job control API (|job-control|). @@ -118,122 +95,20 @@ By default, the backend is started automatically when you open a Haskell buffer. Some people might want to control when (and whether) the background process is started. See |g:intero_start_immediately|. - - *:InteroStart* - *:InteroKill* - *:InteroRestart* -:InteroStart Commands for starting and stopping the background -:InteroKill process. You shouldn't need |:InteroStart| unless you -:InteroRestart have unset |g:intero_start_immediately|. In this case, - |:InteroStart| will do all initialization checks, like - building the `intero` package and starting the backend. - - These commands only manipulate the background process. - To manipulate the GHCi REPL, see |intero-repl|. - - -The GHCi REPL Buffer~ *intero-repl* + Normally, the intero backend (GHCi) runs in the background. However, you can bring it to the foreground into a |:terminal| buffer. There, you can directly interact with the REPL. - *:InteroOpen* - *:InteroHide* -:InteroOpen |:InteroOpen| makes sure that the background process is -:InteroHide started (|intero-backend|), then shows the REPL in a split. - - |:InteroHide| hides the open REPL buffer. It remains running - in the background. To kill the background process, see - |:InteroKill|. - - By default, the REPL opens in a horizontal split. To instead - use a vertical split use |CTRL-W_H| or |CTRL-W_L|. To move - it to it's own tab: |CTRL-W_T|. - - *:InteroEval* -:InteroEval [cmd] Runs a command in the background process, and displays the - result. Useful when you don't want to have to open up the - full REPL. - - Calling |:InteroEval| will 0 arguments will prompt you to - enter a command. - - *:InteroSend* -:InteroSend [cmd] Just like |:InteroEval|, but only shows the output in the - Intero buffer (doesn't also echo it). This is nice when you - have multi-line output that you want to keep around for a - while. - - -Loading Code~ *intero-load* + It's convenient to be able to load your file's or module's top-level bindings into the GHCi REPL so that you can play around. Additionally, some commands won't work until you've loaded the current file or module. - *:InteroReload* -:InteroReload Issues a `:reload` to GHCi. This rebuilds your code, and - you'll be able to see type checking and compilation errors. - If you have Neomake installed, the errors will show up in - the sign column and loclist. - - For local Stack projects, your Main module is loaded - immediately. For the global Stack project, you need to run - |:InteroLoadCurrentFile| first. - - *:InteroLoadCurrentFile* -:InteroLoadCurrentFile - Gets the current file and loads it into GHCi (using - `:load`). Should work for both local and global Stack - projects. - - *:InteroLoadCurrentModule* -:InteroLoadCurrentModule - `intero-neovim` tries to parse the module you're working on - right now, then loads it into GHCi (using `:load`). This - usually fails for the Stack global project. Use - |:InteroLoadCurrentFile| instead. - - -Inspecting Types~ - *intero-types* -Intero is able to tell you the type of any identifier in your code, as well as -that of any visual selection. - - *InteroGenericType* - *InteroType* - *:InteroGenericType* - *:InteroType* -InteroGenericType -InteroType -:InteroGenericType -:InteroType - Shows you the type of the identifier under your cursor. - The "Generic" variant shows you the fully-generic type - (including type variables, etc.). The non-Generic variant - tries to instantiate type variables whenever possible. - - Using the mappings (not the commands) is preferred, - as they'll also work with visual selections. You can bind - bind these mappings to a key of your choice: -> - map t InteroGenericType -< - NOTE: |:map| (not |:noremap|) is required here (it tells - Vim to "re-map" t through InteroGenericType - into the code internal to `intero-neovim`.) - - *:InteroTypeInsert* -:InteroTypeInsert - Looks up the type of the current identifier, and inserts it - above the current line as an annotation. You may have to - make sure to load the current module or file you're working - with (see |intero-load|). - - -Switching Targets~ *intero-targets* + Intero requires a target to work. When it first starts, it makes its best guess for which to load. You can switch between targets on the fly (|:InteroSetTargets|), or you can configure which target to use globally @@ -241,111 +116,185 @@ guess for which to load. You can switch between targets on the fly Intero will cache your stack targets for you. If you've changed into a different stack project than you were in initially, you may want to call -(:InteroClearTargetCache) to reload the target list from stack. +|:InteroClearTargetCache| to reload the target list from stack. + +============================================================================== +CONFIGURATION *intero-config* + + *g:intero_stack_yaml* +Default: Inferred from context + +If you need to use a specific stack.yaml file, you can set this variable. +Alternatively, set `STACK_YAML` in your environment. + + *g:intero_prompt_regex* +Default: `'[^-]>'` + +If you use a custom GHCi prompt, you may need to modify the prompt regex so +that it matches your custom prompt. + + *g:intero_start_immediately* +Default: `1` - *:InteroSetTargets* -:InteroSetTargets {target} .. - Restarts Intero and starts using the specified targets (can - be more than one). If the target doesn't exist in the output - of stack ide targets, then it is interpreted as a regex and - all matches are enabled. Overwrites whatever was previously - in |g:intero_load_targets|. +Intero initializes and starts immediately by default (this includes installing +the `intero` package and spawning the background process). To prevent this +from happening manually, set this to `0`. - Calling |:InteroSetTargets| without any arguments will - prompt you to select the targets you want to load from a - list. +Note: You will then have to trigger this manually by running |:InteroStart| or +|:InteroOpen| before Intero will do anything. - *:InteroUseAllTargets* -:InteroUseAllTargets - This loads all targets specified by `stack ide targets`. + *g:intero_use_neomake* +Default: `1` - *:InteroClearTargetCache* -:InteroClearTargetCache - This clears the cache Intero keeps of the stack targets, - allowing the program to reload them from stack. Useful if - you've changed your intero project in the same neovim - session. +Intero attempts to use Neomake (|neomake.txt|) if it is installed. To opt out +of using Neomake (including silencing warnings about Neomake), set to `0`. -Documentation Pending~ + *g:intero_load_targets* +Default: [] -- InteroUses -- InteroInfo +Intero automatically loads these targets after it starts. When empty, it uses +whatever Stack would normally load as the default target. Also see +|:InteroSetTargets| to change the stack targets on the fly. These must be +valid + *g:intero_ghci_options* +Default: '' -============================================================================= -CONFIGURATION *intero-config* +Options that configure the behaviour of GHCi. For example, `-fobject-code`. -*g:intero_stack_yaml* +============================================================================== +COMMANDS *intero-commands* - Default: (value inferred from context) +:InteroStart[!] *:InteroStart* + Start the Intero process in the background. You shouldn't need it unless you + have unset |g:intero_start_immediately|. In this case, |:InteroStart| will + do all initialization checks, like building the `intero` package and + starting the backend. - If you need to use a specific stack.yaml file, you can set this variable. - Alternatively, set `STACK_YAML` in your environment. +:InteroKill[!] *:InteroKill* + Kill the Intero process. -*g:intero_prompt_regex* +:InteroRestart[!] *:InteroRestart* + Kill and restart the Intero process. - Default: `'[^-]>'` +:InteroOpen[!] *:InteroOpen* + Make sure that the background process is started (|intero-backend|), then + show the REPL in a split. - If you use a custom GHCi prompt, you may need to modify the prompt regex so - that it matches your custom prompt. +:InteroHide[!] *:InteroHide* + Hide the open REPL buffer. It remains running in the background. To kill the + background process, see |:InteroKill|. -*g:intero_start_immediately* +:InteroEval[!] [cmd] *:InteroEval* + Run [cmd] in the background process, and displays the result. Useful when + you don't want to have to open up the full REPL. - Default: `1` + Calling it with no arguments will prompt you to enter a command. - Intero initializes and starts immediately by default (this includes - installing the `intero` package and spawning the background process). - To prevent this from happening manually, set this to `0`. +:InteroSend[!] [cmd] *:InteroSend* + Just like |:InteroEval|, but only show the output of [cmd] in the Intero + buffer (don't echo it). This is nice when you have multi-line output that + you want to keep around for a while. - Note: You will then have to trigger this manually by running |:InteroStart| - or |:InteroOpen| before Intero will do anything. +:InteroReload[!] *:InteroReload* + Issues a `:reload` to GHCi. This rebuilds your code, and you'll be able to + see type checking and compilation errors. If you have Neomake installed, the + errors will show up in the sign column and loclist. -*g:intero_use_neomake* + For local Stack projects, your Main module is loaded immediately. For the + global Stack project, you need to run |:InteroLoadCurrentFile| first. - Default: `1` +:InteroLoadCurrentModule[!] *:InteroLoadCurrentModule* + Gets the current file and loads it into GHCi (using `:load`). Should work + for both local and global Stack projects. - Intero attempts to use Neomake (|neomake.txt|) if it is installed. - To opt out of using Neomake (including silencing warnings about Neomake), - set this to `0`. +:InteroLoadCurrentFile[!] *:InteroLoadCurrentFile* + `intero-neovim` tries to parse the module you're working on right now, then + loads it into GHCi (using `:load`). This usually fails for the Stack global + project. Use |:InteroLoadCurrentFile| instead. -*g:intero_load_targets* +:InteroType[!] *:InteroType* + Show type of identifier under cursor. Tries to instantiate type variables + whenever possible. Prefer using |InteroType|. - Default: [] +:InteroGenericType[!] *:InteroGenericType* + Show type of identifier under cursor. Shows fully-generic type (including + type variables, etc.). Prefer using |InteroGenericType| - Intero automatically loads these targets after it starts. When empty, it - uses whatever Stack would normally load as the default target. Also see - |:InteroSetTargets| to change the stack targets on the fly. These must be - valid +:InteroTypeInsert[!] *:InteroTypeInsert* + Look up the type of the current identifier, and insert it above the current + line as an annotation. You may have to make sure to load the current module + or file you're working with (see |intero-load|). -g:intero_ghci_options +:InteroSetTargets[!] [targets] *:InteroSetTargets* + Restart Intero and use the specified [targets]. + + If a target doesn't exist in the output of stack ide targets, then it is + interpreted as a regex and all matches are enabled. Overwrites whatever was + previously in |g:intero_load_targets|. Calling it without any arguments will + prompt you to select the targets you want to load from a list. + +:InteroUseAllTargets[!] *:InteroUseAllTargets* + Set Intero to use all targets given by `stack ide targets` + +:InteroClearTargetCache[!] *:InteroClearTargetCache* + Clear the cache Intero keeps of the stack targets, allowing the program to + reload them from stack. Useful if you've changed your intero project in the + same neovim session. + +:InteroInfo[!] *:InteroInfo* + Get info for the identifier at the current point + +:InteroGoToDef[!] *:InteroGoToDef* + Go to definition of item under cursor + +:InteroUses[!] *:InteroUses* + Highlight uses of the identifier under cursor + +============================================================================== +MAPPINGS *intero-mappings* + + +Using the mappings is preferred over using the commands, as they'll also work +with visual selections. You can bind bind these mappings to a key of +your choice: +> + map t InteroGenericType +< +NOTE: |:map| (not |:noremap|) is required here (it tells Vim to "re-map" +t through InteroGenericType into the code internal to +`intero-neovim`.) - Default: '' +InteroType *InteroType* +InteroGenericType *InteroGenericType* - Options that configure the behaviour of GHCi. For example, -fobject-code. + Same as |:InteroType| and |:InteroGenericType|, except these mappings allow +for visual selections as well -============================================================================= +============================================================================== CAVEATS *intero-caveats* -- Running `:Neomake!` directly will not work. You need to run |:InteroReload| - instead. + * Running `:Neomake!` directly will not work. You need to run + |:InteroReload| instead. -- Some commands may have unexpected side-effects if you have an autocommand - that automatically switches to insert mode when entering a terminal buffer. + * Some commands may have unexpected side-effects if you have an autocommand + that automatically switches to insert mode when entering a terminal + buffer. -- Completion is not handled by this plugin. You might want to checkout out - `neco-ghc` if you want completion. (https://github.com/eagletmt/neco-ghc) + * Completion is not handled by this plugin. You might want to checkout out + `neco-ghc` if you want completion. (https://github.com/eagletmt/neco-ghc) -============================================================================= +============================================================================== LICENSE *intero-license* BSD3 License (the same license as `ghcmod-vim`). -============================================================================= +============================================================================== CREDITS *intero-credits* -The original Intero for Emacs plugin was created by @chrisdone. -Much of the copy and descriptions in this help file are from the Commercial -Haskell homepage for Intero: https://commercialhaskell.github.io/intero/ +The original Intero for Emacs plugin was created by @chrisdone. Much of the +copy and descriptions in this help file are from the Commercial Haskell +homepage for Intero: https://commercialhaskell.github.io/intero/ `intero-neovim` was written by @parsonsmatt, with significant contributions from @rdnetto. @@ -354,4 +303,4 @@ from @rdnetto. issues on GitHub: https://github.com/parsonsmatt/intero-neovim -vim:tw=78:et:ts=2:ft=help:norl: +vim:tw=78:ts=8:ft=help:norl: diff --git a/plugin/intero.vim b/plugin/intero.vim index f0bc45a..f4eb246 100644 --- a/plugin/intero.vim +++ b/plugin/intero.vim @@ -1,52 +1,320 @@ +scriptencoding utf-8 +"" +" @section Introduction, intro +" @order intro usage config commands mappings caveats license credits +" Designed for Stack~ +" +" Intero requires Stack. If your project works with Stack, it almost definitely +" works with Intero. +" +" Automatic Setup~ +" +" `intero-neovim` takes care of installing Intero into your Stack environment. +" The installation is local (not global!). This means that Intero is always +" current for each of your projects. The goal of Intero is to Just Work™. +" +" On-the-fly Typechecking~ +" +" Intero 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. +" +" Type Information~ +" +" You can ask for type information of the identifier under your cursor as well +" as of a selection. Intero makes an effort to remember type information even +" when the module no longer typechecks. +" +" Jump to Definition~ +" +" After a module has been loaded by Intero, you can jump to the defintion of any +" identifiers within your package. If the identifier comes from a different +" package, Intero will tell you which package the identifier comes from. +" +" Easy Target Switching~ +" +" Intero makes working with multiple stack targets simple. Jump between your app +" and test suite seamlessly. + +"" +" @section Usage +" *intero-package* +" +" `intero-neovim` works by using Stack to build the `intero` package into your +" local project. The installation is completely automated by the plugin; you +" never have to install the `intero` package yourself. +" +" Every time you open a Haskell file in a new Stack project, we'll run `stack +" build intero` for this LTS release and GHC version. Stack then caches the +" installation, so it's faster the next time you re-use the same LTS release and +" GHC version in a project. +" +" Note that due to Stack's global-project, one-off files which aren't managed by +" Stack will always re-use the same global `intero` build. This makes working +" with one-off files as painless as whole projects. +" +" Some people might want to control when (and whether) `intero` is built after +" opening a Haskell file. See |g:intero_start_immediately|. +" +" *intero-backend* +" +" `intero-neovim` maintains a GHCi process running in the background. This works +" using Neovim's asynchronous job control API (|job-control|). +" +" By default, the backend is started automatically when you open a Haskell +" buffer. Some people might want to control when (and whether) the background +" process is started. See |g:intero_start_immediately|. +" +" *intero-repl* +" +" Normally, the intero backend (GHCi) runs in the background. However, you can +" bring it to the foreground into a |:terminal| buffer. There, you can directly +" interact with the REPL. +" +" *intero-load* +" +" It's convenient to be able to load your file's or module's top-level bindings +" into the GHCi REPL so that you can play around. Additionally, some commands +" won't work until you've loaded the current file or module. +" +" *intero-targets* +" +" Intero requires a target to work. When it first starts, it makes its best +" guess for which to load. You can switch between targets on the fly +" (|:InteroSetTargets|), or you can configure which target to use globally +" (|g:intero_load_targets|). +" +" Intero will cache your stack targets for you. If you've changed into a +" different stack project than you were in initially, you may want to call +" |:InteroClearTargetCache| to reload the target list from stack. + +"" +" @section Caveats +" * Running `:Neomake!` directly will not work. You need to run |:InteroReload| +" instead. +" +" * Some commands may have unexpected side-effects if you have an autocommand +" that automatically switches to insert mode when entering a terminal buffer. +" +" * Completion is not handled by this plugin. You might want to checkout out +" `neco-ghc` if you want completion. (https://github.com/eagletmt/neco-ghc) + +"" +" @section License +" BSD3 License (the same license as `ghcmod-vim`). + +"" +" @section Credits +" The original Intero for Emacs plugin was created by @chrisdone. Much of the +" copy and descriptions in this help file are from the Commercial Haskell +" homepage for Intero: https://commercialhaskell.github.io/intero/ +" +" `intero-neovim` was written by @parsonsmatt, with significant contributions +" from @rdnetto. +" +" `intero-neovim` welcomes new contributions! Submit pull requests and open +" issues on GitHub: https://github.com/parsonsmatt/intero-neovim + if exists('g:did_plugin_intero') && g:did_plugin_intero finish endif let g:did_plugin_intero = 1 -if !exists('g:intero_use_neomake') - let g:intero_use_neomake = 1 +" Settings {{{1 + +"" +" Default: Inferred from context +" +" If you need to use a specific stack.yaml file, you can set this variable. +" Alternatively, set `STACK_YAML` in your environment. +let g:intero_stack_yaml = "" + +"" +" Default: `'[^-]>'` +" +" If you use a custom GHCi prompt, you may need to modify the prompt regex so +" that it matches your custom prompt. +let g:intero_prompt_regex = get(g:, 'intero_prompt_regex', '[^-]> ') + +"" +" Default: `1` +" +" Intero initializes and starts immediately by default (this includes installing +" the `intero` package and spawning the background process). To prevent this +" from happening manually, set this to `0`. +" +" Note: You will then have to trigger this manually by running |:InteroStart| or +" |:InteroOpen| before Intero will do anything. +let g:intero_start_immediately = get(g:, 'intero_start_immediately', 1) + +"" +" Default: `1` +" +" Intero attempts to use Neomake (|neomake.txt|) if it is installed. To opt out +" of using Neomake (including silencing warnings about Neomake), set to `0`. +let g:intero_use_neomake = get(g:, 'intero_use_neomake', 1) + +"" +" Default: [] +" +" Intero automatically loads these targets after it starts. When empty, it uses +" whatever Stack would normally load as the default target. Also see +" |:InteroSetTargets| to change the stack targets on the fly. These must be +" valid +let g:intero_load_targets = get(g:, 'intero_load_targets', []) + +"" +" Default: '' +" +" Options that configure the behaviour of GHCi. For example, `-fobject-code`. +let g:intero_ghci_options = get(g:, 'intero_ghci_options', '') +if g:intero_ghci_options != '' + let g:intero_ghci_options = ' --ghci-options="' . g:intero_ghci_options . '"' endif -" Starts the Intero process in the background. +" Intero Background Process Commands {{{1 + +"" +" Start the Intero process in the background. You shouldn't need it unless you +" have unset |g:intero_start_immediately|. In this case, |:InteroStart| will do +" all initialization checks, like building the `intero` package and starting the +" backend. command! -nargs=0 -bang InteroStart call intero#process#start() -" Kills the Intero process. + +"" +" Kill the Intero process. command! -nargs=0 -bang InteroKill call intero#process#kill() -" Opens the Intero buffer. + +"" +" Kill and restart the Intero process. +command! -nargs=0 -bang InteroRestart call intero#process#restart() + +"" +" Make sure that the background process is started (|intero-backend|), then +" show the REPL in a split. command! -nargs=0 -bang InteroOpen call intero#process#open() -" Hides the Intero buffer. + +" GHCi REPL Buffer Commands {{{1 + +"" +" Hide the open REPL buffer. It remains running in the background. To kill the +" background process, see |:InteroKill|. command! -nargs=0 -bang InteroHide call intero#process#hide() -" Loads the current module in Intero. -command! -nargs=0 -bang InteroLoadCurrentModule call intero#repl#load_current_module() -" Loads the current file in Intero. -command! -nargs=0 -bang InteroLoadCurrentFile call intero#repl#load_current_file() -" Prompts user for a string to eval + +"" +" Run [cmd] in the background process, and displays the result. Useful when you +" don't want to have to open up the full REPL. +" +" Calling it with no arguments will prompt you to enter a command. command! -nargs=? -bang InteroEval call intero#repl#eval() -" Sends a string to the Intero buffer (doesn't prompt to "press any key") + +"" +" Just like |:InteroEval|, but only show the output of [cmd] in the Intero +" buffer (don't echo it). This is nice when you have multi-line output that you +" want to keep around for a while. command! -nargs=? -bang InteroSend call intero#repl#send() -" Gets the specific type at the current point + +" Code Loading Commands {{{1 + +"" +" Issues a `:reload` to GHCi. This rebuilds your code, and you'll be able to see +" type checking and compilation errors. If you have Neomake installed, the +" errors will show up in the sign column and loclist. +" +" For local Stack projects, your Main module is loaded immediately. For the +" global Stack project, you need to run |:InteroLoadCurrentFile| first. +command! -nargs=0 -bang InteroReload call intero#repl#reload() + +"" +" Gets the current file and loads it into GHCi (using `:load`). Should work for +" both local and global Stack projects. +command! -nargs=0 -bang InteroLoadCurrentModule call intero#repl#load_current_module() + +"" +" `intero-neovim` tries to parse the module you're working on right now, then +" loads it into GHCi (using `:load`). This usually fails for the Stack global +" project. Use |:InteroLoadCurrentFile| instead. +command! -nargs=0 -bang InteroLoadCurrentFile call intero#repl#load_current_file() + +" Inspecting Types Commands {{{1 + +"" +" Show type of identifier under cursor. Tries to instantiate type variables +" whenever possible. Prefer using |InteroType|. command! -nargs=0 -bang InteroType call intero#repl#type(0) -" Gets the type at the current point + +"" +" Show type of identifier under cursor. Shows fully-generic type (including type +" variables, etc.). Prefer using |InteroGenericType| command! -nargs=0 -bang InteroGenericType call intero#repl#type(1) -" Gets info for the identifier at the current point + +"" +" Look up the type of the current identifier, and insert it above the current +" line as an annotation. You may have to make sure to load the current module or +" file you're working with (see |intero-load|). +command! -nargs=0 -bang InteroTypeInsert call intero#repl#insert_type() + +" Switching Targets Commands {{{1 + +"" +" Restart Intero and use the specified [targets]. +" +" If a target doesn't exist in the output of stack ide targets, then it is +" interpreted as a regex and all matches are enabled. Overwrites whatever was +" previously in |g:intero_load_targets|. +" Calling it without any arguments will prompt you to select the targets you +" want to load from a list. +command! -nargs=* -bang InteroSetTargets call intero#process#restart_with_targets() + +"" +" Set Intero to use all targets given by `stack ide targets` +command! -nargs=0 -bang InteroUseAllTargets call intero#targets#enable_all_targets() + +"" +" Clear the cache Intero keeps of the stack targets, allowing the program to +" reload them from stack. Useful if you've changed your intero project in the +" same neovim session. +command! -nargs=0 -bang InteroClearTargetCache call intero#targets#clear_target_cache() + +" Miscellaneous Commands {{{1 + +"" +" Get info for the identifier at the current point command! -nargs=0 -bang InteroInfo call intero#repl#info() + +"" " Go to definition of item under cursor command! -nargs=0 -bang InteroGoToDef call intero#loc#go_to_def() -" Insert type of thing below cursor -command! -nargs=0 -bang InteroTypeInsert call intero#repl#insert_type() -" Reload -command! -nargs=0 -bang InteroReload call intero#repl#reload() + +"" " Highlight uses of the identifier under cursor command! -nargs=0 -bang InteroUses call intero#repl#uses() | set hlsearch -" Kill and restart the Intero process -command! -nargs=0 -bang InteroRestart call intero#process#restart() -" Set the load targets for Intero. -command! -nargs=* -bang InteroSetTargets call intero#process#restart_with_targets() -" Set Intero to use all targets given by stack ide targets -command! -nargs=0 -bang InteroUseAllTargets call intero#targets#enable_all_targets() -" Clear the cached targets (useful if you've moved into a new stack project) -command! -nargs=0 -bang InteroClearTargetCache call intero#targets#clear_target_cache() -" Same as the :InteroType commands, but as maps (so they work with selections) +" Mappings {{{1 + +"" +" @section Mappings, mappings +" +" Using the mappings is preferred over using the commands, as they'll also work +" with visual selections. You can bind bind these mappings to a key of +" your choice: +" > +" map t InteroGenericType +" < +" NOTE: |:map| (not |:noremap|) is required here (it tells Vim to "re-map" +" t through InteroGenericType into the code internal to +" `intero-neovim`.) +" +" InteroType *InteroType* +" InteroGenericType *InteroGenericType* +" +" Same as |:InteroType| and |:InteroGenericType|, except these mappings allow +" for visual selections as well + noremap InteroType intero#repl#pos_for_type(0) noremap InteroGenericType intero#repl#pos_for_type(1) From 261d47a477b572ad2726aaaacc40427fa6f68206 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Date: Sat, 9 Dec 2017 14:03:04 -0500 Subject: [PATCH 2/4] Fix check for g:intero_stack_yaml --- autoload/intero/process.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/intero/process.vim b/autoload/intero/process.vim index 4e6a716..e3f1397 100644 --- a/autoload/intero/process.vim +++ b/autoload/intero/process.vim @@ -62,7 +62,7 @@ function! intero#process#initialize() abort endif " Find stack.yaml - if (!exists('g:intero_stack_yaml')) + if g:intero_stack_yaml == '' " If there's a STACK_YAML environment variable, try to interpret " that. let l:should_cd_to_current_file = empty($STACK_YAML) From 247e9da58b8563c983a57ca280bddb64f1c9d252 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Date: Sat, 9 Dec 2017 14:06:40 -0500 Subject: [PATCH 3/4] Conform to vint suggestions --- autoload/intero/process.vim | 2 +- plugin/intero.vim | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/intero/process.vim b/autoload/intero/process.vim index e3f1397..cef6dc0 100644 --- a/autoload/intero/process.vim +++ b/autoload/intero/process.vim @@ -62,7 +62,7 @@ function! intero#process#initialize() abort endif " Find stack.yaml - if g:intero_stack_yaml == '' + if g:intero_stack_yaml ==# '' " If there's a STACK_YAML environment variable, try to interpret " that. let l:should_cd_to_current_file = empty($STACK_YAML) diff --git a/plugin/intero.vim b/plugin/intero.vim index f4eb246..fc59c1f 100644 --- a/plugin/intero.vim +++ b/plugin/intero.vim @@ -131,7 +131,7 @@ let g:did_plugin_intero = 1 " " If you need to use a specific stack.yaml file, you can set this variable. " Alternatively, set `STACK_YAML` in your environment. -let g:intero_stack_yaml = "" +let g:intero_stack_yaml = '' "" " Default: `'[^-]>'` @@ -172,7 +172,7 @@ let g:intero_load_targets = get(g:, 'intero_load_targets', []) " " Options that configure the behaviour of GHCi. For example, `-fobject-code`. let g:intero_ghci_options = get(g:, 'intero_ghci_options', '') -if g:intero_ghci_options != '' +if g:intero_ghci_options !=# '' let g:intero_ghci_options = ' --ghci-options="' . g:intero_ghci_options . '"' endif From 51ca442f6b53224c8ca7a984084927cf47b5aa61 Mon Sep 17 00:00:00 2001 From: Alejandro Hernandez Date: Sat, 9 Dec 2017 19:45:00 -0500 Subject: [PATCH 4/4] Add addon-info.json --- addon-info.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 addon-info.json diff --git a/addon-info.json b/addon-info.json new file mode 100644 index 0000000..2616c10 --- /dev/null +++ b/addon-info.json @@ -0,0 +1,6 @@ +{ + "description": "\n\n\n _ _ _ ~\n (_)_ __ | |_ ___ _ __ ___ _ __ ___ _____ _(_)_ __ ___ ~\n | | '_ \\| __/ _ \\ '__/ _ \\ _____| '_ \\ / _ \\/ _ \\ \\ / / | '_ ` _ \\ ~\n | | | | | || __/ | | (_) |_____| | | | __/ (_) \\ V /| | | | | | |~\n |_|_| |_|\\__\\___|_| \\___/ |_| |_|\\___|\\___/ \\_/ |_|_| |_| |_|~\n ~\n\n Complete interactive program development for Haskell\n\n", + "author": "Matt Parsons ", + "name": "intero", + "repository": {"type": "git", "url": "https://github.com/parsonsmatt/intero-neovim"} +}