Giter VIP home page Giter VIP 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 codex, hscope, ghc-mod, hasktags, 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
,htShow type of expression under cursor
,hTInsert type of expression into previous line
,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

Tags

,tgGenerate tags with codex
,ttOpen/close the tag bar
C-]Jump to definition of symbol (codex + hasktags)Note: You must generate the tags for your project (with ,tg) prior to using the jump command.
C-\Show uses of symbol (hscope)

Conversions

,h.Transform visual selection to pointfree style
,h>Transform visual selection to pointed style

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

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

install.sh --repo CLONE-PATH

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 afwlehmann avatar begriffs avatar benarmston avatar bjornbm avatar fmrl avatar gregwebs avatar guersam avatar harendra-kumar avatar hemanth avatar ideruga avatar igniting avatar joom avatar jship avatar kludgy avatar ksmith97 avatar markschultz avatar mitochon avatar natrbro avatar paniag avatar pavbiz avatar real-or-random avatar santios avatar sarabander avatar schell avatar sdiehl avatar simplex91 avatar sx91 avatar tehnix avatar twopoint718 avatar

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.