GithubHelp home page GithubHelp logo

haskell-vim-now's Introduction

Build Status

Haskell Vim IDE


In less than ten minutes your Vim will transform into a beautiful Haskell paradise. (Don't worry, it backs up your original configuration to ~/.config/haskell-vim-now/backup/.vimrc.yearmonthdate_time.) It also builds all necessary support binaries including ghcide, hlint, hoogle and more.

No more wading through plugins trying to make them all work together. In ten minutes you will have a fully functional Vim that looks great and lets you

  • inspect types
  • evaluate Haskell
  • lint and check
  • manipulate tags
  • hoogle lookup
  • pointfree refactor
  • tab complete
  • unicode symbols
  • highlight DSLs
  • work with git

Installation

Just download and run the installer:

curl -L https://git.io/haskell-vim-now > /tmp/haskell-vim-now.sh
bash /tmp/haskell-vim-now.sh

WARNING: this command, once successful, will make backups and remove your existing VIM configurations (.vim, plugins etc). You can later customize HVN configurations.

Keybindings and commands

The commands are organized into logical groups to help you remember them.

Types, autocomplete, refactoring, and linting

<Tab>Autocomplete with words in file
<C-space>Autocomplete with symbols in your Cabal sandbox
,hrApply one refactoring hint at cursor position
,hRApply all refactoring suggestions in the file
,hlRun Haskell linter on file
,hcRun Haskell compile check on file
,<cr>Clear type selection

Hoogle

,hhRun Hoogle on the word under the cursor
,hHRun Hoogle and prompt for input
,hiRun Hoogle for detailed information on word under cursor
,hIRun Hoogle for detailed information and prompt for input
,hzClose the Hoogle search window

GHCI repl

If you open a tmux terminal alongside MacVim then you can send Vim selections to it. This works well for evaluating things in GHCI.

,rsSend selected text to tmux
,rvChange tmux session, window, and pane attachment

Git

,g?Last-committed files (Monday morning key)
,gsGit status (fugitive)
,ggGit grep
,glGit log (extradition)
,gdGit diff
,gbGit blame

Commenting

gcComment / Uncomment selection

Aligning

,a=Align on equal signs
,a,Align on commas
,a|Align on vertical bar
,apAlign on character of your choice

Splits and find file

,<space>Fuzzy file find (CtrlP)
,fToggle file browser, find file
,FToggle file browser
,sjOpen split below
,skOpen split above
,shOpen split leftward
,slOpen split rightward

Buffers

,bpPrevious buffer
,bnNext buffer
,b<space>Buffer fuzzy finder
,bdDelete buffer, keep window open (bbye)
,boClose all buffers except the current one

Misc

,maEnable mouse mode (default)
,moDisable mouse mode
,igToggle indentation guides
,uInteractive undo tree
,ssEnable spell checking
,eOpen file prompt with current path
,<cr>Clear search highlights
,rRedraw screen
C-hMove cursor to leftward pane
C-kMove cursor to upward pane
C-jMove cursor to downward pane
C-lMove cursor to rightward pane (redraw is `,r` instead)
gqFormat selection using `hindent` for haskell buffers (`par` for others)
,yYank to OS clipboard
,dDelete to OS clipboard
,pPaste from OS clipboard

(If you prefer to restore the default screen redraw action of C-l then add unmap <c-l> to your vimrc.local)

Customizing

After installing this configuration, your .vimrc and .vim will be under version control. Don't alter these files. Instead, add your own settings to ~/.config/haskell-vim-now/vimrc.local.pre, ~/.config/haskell-vim-now/vimrc.local.

Adding Vim Plugins

Haskell-Vim-Now uses vim-plug to install plugins. It uses the following vim configuration structure to determine what to install:

call plug#begin('~/.vim/plugged')

" The plugins are named in github short form, for example:
Plug 'junegunn/vim-easy-align'

" All plug statements must be between plug#begin and plug#end
call plug#end()

However the .vimrc file in Haskell-Vim-Now is under version control so you shouldn't edit it directly. To add a plugin what you should do is add Plug statements to ~/.config/haskell-vim-now/plugins.vim. When ready reload .vimrc and run :PlugInstall to install plugins.

Neovim support

The .vimrc configuration is fully compatible with Neovim, and adds a few Neovim specific mappings for the terminal mode (terminal emulation is activated with :terminal). The mappings make Esc and c-[hjkl] function as one would expect them to from normal mode.

The Neovim configuration is found at .config/nvim, and is symlinked just like regular vim, which means you should only add your own settings to ~/.config/haskell-vim-now/vimrc.local.pre, ~/.config/haskell-vim-now/vimrc.local and ~/.config/haskell-vim-now/plugins.vim.

You can quickly backup and replace your Neovim setup by running the scripts/neovim.sh script.

Docker image

If you are into developing with Docker, you can use the image.

docker pull haskell:7.8
docker build -t haskell-vim .
docker run --rm -i -t haskell-vim /bin/bash

If instead you want to extract the vim setup from the image that is easy enough

docker build -t haskell-vim .
mkdir ~/.haskell-vim-now
cd ~/.haskell-vim-now
docker run --rm haskell-vim tar -cz -C /root/.haskell-vim-now . > haskell-vim-now.tgz
tar -xzf haskell-vim-now.tgz

However, some things (for example the hoogle database) use absolute paths and don't work correctly.

Advanced install methods

Basic install

In case you want to skip the haskell specific components and want to install just the common vim config you can use:

bash <(curl -sL https://git.io/haskell-vim-now) --basic

Installing from a fork or clone

If you have a modified fork you can use the --repo option to tell the install script the location of your repository:

bash <(curl -sL INSTALL-SCRIPT-URL) --repo FORK-URL

For example:

bash <(curl -sL https://raw.githubusercontent.com/begriffs/haskell-vim-now/master/install.sh) --repo https://github.com/begriffs/haskell-vim-now.git

Additionally the --branch argument can override the default of master used when cloning the repo.

If you have a local git clone you can use install.sh directly to install from your clone:

install.sh --repo CLONE-PATH

Installing in Nix build environment

Use --nix parameter, in case you want to execute stack installation in nix-shell

bash <(curl -sL https://git.io/haskell-vim-now) --nix

Troubleshooting

See this wiki page for tips on fixing installation problems.

Thank you!

Big thanks to contributors. I'd especially like to thank @SX91 for rewriting the installer and for other major improvements.

haskell-vim-now's People

Contributors

adambaker avatar begriffs avatar bidhan-a avatar bjornbm avatar fmrl avatar gregwebs avatar guersam avatar harendra-kumar avatar hemanth avatar huiwang avatar ideruga avatar igniting avatar isomorphisms avatar jship avatar kludgy avatar ksmith97 avatar markschultz avatar mitochon avatar natrbro avatar p-alik avatar pavbiz avatar real-or-random avatar santios avatar schell avatar sdiehl avatar simplex91 avatar sx91 avatar tebello-thejane avatar tehnix avatar tomberek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

haskell-vim-now's Issues

Not able to see types

I am not able to see the types of expression under cursor or lines (using ,ht).
Error on using ,ht is ghcmod#command#type: Cannot guess type
and similarly on using ,hT is ghcmod#command#type_insert: Cannot guess type
It is not that above is not working on some particular instance, it has not worked ever since I installed vim-haskell-now.
I tried running ghc-mod check /path_to_file, but there was no error.

Also ,hc doesn't work. Maybe I guess some problem with syntastic.

Nested allignments

I love HVN's align feature. It certainly makes my life a little easier! That being said, I frequently align lines internally, too. E.G. the = below:

fib n | n  0        = 0
      | n  1        = 1
      | otherwise    = fib (n - 1) + fib (n - 2)

It doesn't look like there is a way to do that with HVN as of yet. Is this something that's doable?

Thanks!

P.S. GitHub is aligning things weird, so the space numbers above don't actually match up. The above does capture what I'm going for visually, though.

Current keybindings rob the ability to redraw the screen

^L is usually used to restore the screen when things get mucked up.

noremap <c-l> <c-w>l 

makes it so that that is moving around between windows instead.

Given the number of extensions, the screen winds up showing garbage a fair bit with no easy way to clean it off.

Support Haskell Platform

The current version requires GHC 7.8, which means that the current Haskell Platform version (GHC 7.6.3) isn't supported. Since the platform is a standard distribution environment that new Haskell developers are encouraged to use, it would be great to support that environment! :)

Weird `git commit -a` interaction.

I've switched to this configuration to try it out. So far so good, except there is one deal killing problem that I'm having though.

When I go to edit a git commit message, e.g. git commit -a, and save it

I always get:

Macintosh-4:semigroups ekmett$ git commit -a
error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

even after saving, with this editor config. =/

install from Dockerfile failed

...
Removing intermediate container 39297f92e426
Step 2 : ADD https://raw.githubusercontent.com/begriffs/haskell-vim-now/master/install.sh /install.sh
Downloading 3.662 kB

 ---> bada1a59f97b
Removing intermediate container 0abf39bb541d
Step 3 : RUN /install.sh && rm -r /root/.cabal
 ---> Running in 1a9cfa921c10
/bin/sh: 1: /install.sh: Permission denied
INFO[0427] The command [/bin/sh -c /install.sh && rm -r /root/.cabal] returned a non-zero code: 126 

I'm running Mac OS X Yosemite 10.10.4 (14E46) with
Boot2Docker-cli version: v1.6.2 / Git commit: cb2c3bc
Docker version 1.6.2, build 7c8fca2

Replace 'jk' with something better

In Dutch, 'jk' are letters that used quite often in normal messages, in fact, my surname ends with those letters. Thus maybe 'jk' to exit from insert mode could be replaced with something better, 'jjk' for example.

Haskell-vim-now and stack don't seem to play together nicely yet

Hi!

First of all, I really like haskell-vim-now, it's super easy to install and makes my vim environment beautiful.

I used it successfully for quite a while, but recently I started using stack instead of cabal-install (which is also an awesome improvement), and unfortunately I feel like now many things don't work very well anymore. One thing happening in my AWS EC2 environment is that every time I save I get this syntastic error:

ghc-mod: Could not find $libexecdir/cabal-helper-wrapper                        
If you are a developer set the environment variable                             
`cabal_helper_libexecdir' to override $libexecdir[1]. The following will        
work in the cabal-helper source tree:                                           
    $ export cabal_helper_libexecdir=$PWD/dist/build/cabal-helper-wrapper       
[1]: /tmp/build-IARM/.cabal-sandbox/libexec                                     
If you don't know what I'm talking about something went wrong with your         
installation. Please report this problem here:                                  
    https://github.com/DanielG/cabal-helper/issues

In another environment ",hc" doesn't seem to work well anymore. This could have something to do with the fact that I have both a local ghc installation and a global one (one in my home dir, the other across users), or that I have my packages installed locally.

(As an aside, auto-indenting doesn't seem to work very well in .lhs files but I'm fairly sure that's a plugin-specific thing, not a haskell-vim-now issue.)

In case all these issues are already fixed, what's the easiest way for me to update haskell-vim-now? (I can git pull, maybe that's all I need to do?)

Oh by the way, I did find this command in a post by Michael Snoyman (https://groups.google.com/forum/#!topic/haskell-stack/8HJ6DHAinU0):

cabal configure --package-db=clear --package-db=global --package-db=$(stack path --snapshot-pkg-db) --package-db=$(stack path --local-pkg-db)

this solved at least part of my problems, maybe it will be useful for other people as well.

Cheers and thanks!
Sam

Overeager unicode symbol replacement

I'm noticing that more and more symbols are being replaced by cute characters. Now even Text and Bool are being replaced by T and B. Feels a little too cute to me and I'm considering disabling some of this.

GhcModCheck error

function ghcmod#command#make..ghcmod#make..<SNR>203_system..<SNR>203_plineopen3, line 1
Vim(lcd):E344: Can't find directory "/usr/local/Cellar/ghc/7.8.4/lib/ghc-7.8.4/settings:
 openFile: does not exist (No such file or directory)" in cdpath 
Error detected while processing function ghcmod#command#make:
line    7:
E714: List required 
ghc-mod check: No errors found 

I get this error when I run :GhcModCheck on a Haskell file. In general, ghc-mod does not perform syntax-checking on my files.

Part of the issue is that I have this directory: "/usr/local/Cellar/ghc/7.10.2/lib/ghc-7.10.2"
but not this directory: "/usr/local/Cellar/ghc/7.8.4/lib/ghc-7.8.4/"

Auto-fold imports

Some vim configs autofold functions, but it would be nice to do it to the Haskell imports since they can be annoying.

Failed to install ghc-mod-4.1.6 under

On

  • OS X 10.10.3
  • GHC 7.10.1
  • cabal-install version 1.22.2.0

Installation fails with

Language/Haskell/GhcMod/Gap.hs:241:18:
    Not in scope: data constructor ‘ExposePackageId’
    Perhaps you meant ‘ExposePackage’ (imported from DynFlags)
cabal: Error: some packages failed to install:
ghc-mod-4.1.6 failed during the building phase. The exception was:
ExitFailure 1
--- Saving ghc-mod, binaries
--- Cleaning up
/Users/user/.haskell-vim-now
--- hasktags is already installed, skipping build
--- codex is already installed, skipping build
...

Any solutions?

error when building docker image

---> Running in 00f407df5098
/bin/sh: 1: /install.sh: Permission denied
The command '/bin/sh -c /install.sh && rm -r /root/.cabal' returned a non-zero code: 126

I get the above error when trying to build docker image as explained
docker build -t haskell-vim .

any ideas ?

Having some problems getting things to work

Im using Mac OSX 10.9.5
Vim 7.4.

The commands I'm having problem with are the following:
,hl ,hc I don't think any checking actually happens. Im used to having syntastic checking my files at each save but with Vim-now the only thing that happens is that the left side gets a bit indented in the vim window but no errors.

Also when I'm using ,ht or ,hT I'm getting error saying that type can not be identified or determined. Can you please in the readme give some sample use cases of the examples if I might be using them wrong?

Also is there a easy way to see see the type of the function under the cursor. The only way I understand now is by using hoogle but I would like to know the type of my own functions.

'Show expression type under cursor' works, but ,hT inserts a blank line above

When editing a Haskell file, ,ht reports the correct expression type under the cursor. But when I try to insert the type using ,hT, a blank line is inserted instead of the expression type.

Interestingly, ,hT works correctly for the main function--correctly inserting main :: IO (). But ,hT inserts a blank line for all other functions in a file.

I tried ,hT within a sandbox as well, but had the same issue. Perhaps I'm missing something simple. Any pointers would be appreciated!

Using latest haskell-vim-now on Yosemite, GHC 7.8.3, ghc-mod 5.2.1.2 compiled by GHC 7.8.3, vim 7.4/MacVim 73.

P.S. Thanks for your efforts in creating/maintaining this awesome Haskell paradise! 👍

",hc" doesn't seem to do anything, ",ht" fails with "cannot guess type"

Just ran the install script fresh and I seem to be having trouble with several commands. With code that doesn't compile, ",hc" outputs nothing. Also, for other functions defined (in the same file), ",ht" always reports that it "cannot guess type." happy is installed at .cabal/bin which is on my path.

Work with cabal-sandbox?

So I'm wondering how to add a sandbox path to the ghc-mod command (and thus have it picked up by the vim commands).

I know that with any ghc command I can run:

ghc -package-db .cabal-sandbox/x86_64-osx-ghc-7.6.3-packages.conf.d

(at least for me) this includes the sandboxed libraries. I can run this:

ghc-mod --ghcOpt='-package-db .cabal-sandbox/x86_64-osx-ghc-7.6.3-packages.conf.d'

and then ghc-mod consults the sandbox-installed packages. I just don't know how to integrate this into the vim commands. Let me know if there's something that I can do.

Fix Haskell autocomplete

As configured the .vimrc should suggest Haskell completions when the user presses the tab key. The config installs ghc-mod, neco-ghc and neocomplcache and sets the vim omnicompletion function to necoghc#omnifunc. Should be working but it's not.

@DrBoolean or @adambaker could either of you take a look and see if you can spot the problem?

Installable on Win8?

I assume not, I tried installing the missing tools anyway and got stuck trying to install curl-config on Windows.
Any recommendations for Windows users?

view type output (,ht) is difficult to decipher ...

,ht does not seem to work ... If I am in the middle of the function readMay for instance, I have got a type that seems totally unrelated. Move the cursor, gives me another type.

Actually I don't seem to be able to make sense of the output at all ...

I am running ghc-7.8.2.

More issues installing from docker

Still having problems (follow up to #69)

Step 2 : ADD https://raw.githubusercontent.com/begriffs/haskell-vim-now/master/install.sh /install.sh
Downloading 3.309 kB

 ---> 5fa7f448c073
Removing intermediate container 0c9f057c93a7
Step 3 : RUN /bin/bash /install.sh && rm -r /root/.cabal
 ---> Running in b1b3d6a5b5b5
--- Installer requires Stack. Installation instructions:
--- https://github.com/commercialhaskell/stack#how-to-install

I have stack installed in my machine.

{9:47}~/Downloads/haskell-vim-now:master ✓ ➭ which stack
/Users/mitochon/Applications/ghc-7.10.2.app/Contents/bin/stack
{9:47}~/Downloads/haskell-vim-now:master ✓ ➭ command -v stack >/dev/null && echo $?
0

Does stack need to be part of the Dockerfile?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.