ghcimportedfrom-vim


Ⅰ. 插件描述

Vim plugin for ghc-imported-from.

Ⅱ. 基本信息

创建日期:  2014-01-10
使用用户:  1
Github星:  6
插件作者:  Carlo Hamalainen

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'carlohamalainen/ghcimportedfrom-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'carlohamalainen/ghcimportedfrom-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'carlohamalainen/ghcimportedfrom-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/carlohamalainen/ghcimportedfrom-vim

Ⅳ. 文档说明

# ghcimportedfrom-vim

Vim plugin for ghc-imported-from.

Based heavily on ghcmod-vim.

Installation - Linux

Prerequisites are Pathogen, vimproc, and ghc-imported-from.

Pathogen

Install Pathogen:

mkdir -p ~/.vim/autoload ~/.vim/bundle;
curl -Sso ~/.vim/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim

Add these lines to ~/.vimrc:

execute pathogen#infect()
syntax on
filetype plugin indent on

vimproc

git clone https://github.com/Shougo/vimproc.vim.git ~/.vim/bundle/vimproc.vim
cd ~/.vim/bundle/vimproc.vim
make
cd

ghc-imported-from

Install into user's cabal directory:

git clone https://github.com/carlohamalainen/ghc-imported-from
cd ghc-imported-from
cabal install
cd -

Alternatively, see the script build_in_sandbox.sh for building
in a cabal sandbox (requires a fairly recent version of Cabal).

Make sure that the ghc-imported-from binary is on the path, for example:

$ which ghc-imported-from
/home/user/.cabal/bin/ghc-imported-from

ghcimportedfrom-vim

Install ghcimportedfrom-vim:

git clone https://github.com/carlohamalainen/ghcimportedfrom-vim ~/.vim/bundle/ghcimportedfrom-vim

Add these lines to ~/.vimrc:

au FileType haskell  nnoremap <buffer> <F4> :GhcImportedFromOpenHaddock<CR>
au FileType lhaskell nnoremap <buffer> <F4> :GhcImportedFromOpenHaddock<CR>

au FileType haskell  nnoremap <buffer> <F5> :GhcImportedFromEchoUrl<CR>
au FileType lhaskell nnoremap <buffer> <F5> :GhcImportedFromEchoUrl<CR>

Install - Windows

Tested on Windows 7 64bit.

Install the following components:

Then using a Git Bash shell:

cd $HOME
mkdir -p ~/vimfiles/autoload ~/vimfiles/bundle
curl -Sso ~/vimfiles/autoload/pathogen.vim https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim

vimproc:

git clone https://github.com/Shougo/vimproc.vim.git ~/vimfiles/bundle/vimproc.vim
cd ~/vimfiles/bundle/vimproc.vim
/c/MinGW/bin/mingw32-make.exe -f make_mingw32.mak
cd

ghc-imported-from

git clone https://github.com/carlohamalainen/ghc-imported-from
cd ghc-imported-from
cabal install
cd -

ghcimportedfrom-vim

git clone https://github.com/carlohamalainen/ghcimportedfrom-vim ~/vimfiles/bundle/ghcimportedfrom-vim

vimrc

Make sure that it looks like this:

$ cat $HOME/.vimrc

execute pathogen#infect()
syntax on
filetype plugin indent on

au FileType haskell  nnoremap <buffer> <F4> :GhcImportedFromOpenHaddock<CR>
au FileType lhaskell nnoremap <buffer> <F4> :GhcImportedFromOpenHaddock<CR>

au FileType haskell  nnoremap <buffer> <F5> :GhcImportedFromEchoUrl<CR>
au FileType lhaskell nnoremap <buffer> <F5> :GhcImportedFromEchoUrl<CR>

au FileType haskell  vnoremap <S-F4> :<C-u> :GhcImportedFromOpenHaddockVismode<CR>
au FileType lhaskell vnoremap <S-F4> :<C-u> :GhcImportedFromOpenHaddockVismode<CR>

au FileType haskell  vnoremap <S-F5> :<C-u> :GhcImportedFromEchoUrlVismode<CR>
au FileType lhaskell vnoremap <S-F5> :<C-u> :GhcImportedFromEchoUrlVismode<CR>

Using

In Vim, put the cursor over a symbol, and hit F4 to open the relevant
Haddock documentation page in the system's default browser, or F5 to
echo the Haddock URL in the Vim window.

If the cursor is over a "strange" symbol like

<$

then the standard regex may not identify the symbol properly. In this
case you can use vim's visual mode to highlight the text and then hit
Shift-F4 or Shift-F5 to open the doc or echo the url
for the highlighted term.

The screencast shows
some examples. Make sure that the video plays in 720p HD fullscreen.

Customising

To manually specify the browser, set g:ghcimportedfrom_browser in your ~/.vimrc:

let g:ghcimportedfrom_browser = '/usr/bin/google-chrome'

To pass extra options to GHC:

let g:ghcimportedfrom_ghc_options = ['-blap']

To pass extra options to ghc-pkg:

let g:ghcimportedfrom_ghcpkg_options = ['--global', '--package-db=/home/user/foo/.cabal-sandbox/x86_64-linux-ghc-7.6.3-packages.conf.d']

Beware that GHC and ghc-pkg accept options in a different form;
for example GHC takes -package-db while ghc-pkg takes
--package-db=. For more details: http://www.vex.net/~trebla/haskell/sicp.xhtml

添加新评论