在项目中评估haskell-vim-now,可以先看清用途边界:一行 Haskell Vim 安装。把它放到日常自动化流程中,最容易暴露的是输入边界、依赖和失败处理如果不清楚就很难稳定复用,不能只看演示是否顺利。更实际的做法是用一项范围明确的真实任务完成最小试跑,同时核对配置时间、输出质量、异常信息和维护痕迹,不要直接在关键项目上。对愿意先做小范围验证并复查原始文档的团队来说,这个仓库值得继续验证;只求即装即用的人则要先看维护成本。
Haskell Vim IDE
不到十分钟,你的 Vim 就会变成一个漂亮的
哈斯克尔天堂。 (别担心,它会备份您的原始数据
配置为 ~/.config/haskell-vim-now/backup/.vimrc.yearmonthdate_time。)它还构建所有必要的支持二进制文件
包括ghcide、hlint、hoogle等。
不再费力地通过插件试图让它们一起工作。 十分钟内你将拥有一个功能齐全、看起来很棒的 Vim 并让你
安装
只需下载并运行安装程序:
curl -L https://git.io/haskell-vim-now > /tmp/haskell-vim-now.sh
bash /tmp/haskell-vim-now.sh
WARNING:此命令一旦成功,将_进行备份并删除_您现有的VIM配置(.vim、插件等)。您稍后可以自定义 定制 HVN 配置。
按键绑定和命令
这些命令被组织成逻辑组以帮助您记住 他们。
类型、自动完成、重构和 linting
| <Tab> | Autocomplete with words in file |
| <C-space> | Autocomplete with symbols in your Cabal sandbox |
| ,hr | Apply one refactoring hint at cursor position |
| ,hR | Apply all refactoring suggestions in the file |
| ,hl | Run Haskell linter on file |
| ,hc | Run Haskell compile check on file |
| ,<cr> | Clear type selection |
胡格尔
| ,hh | Run Hoogle on the word under the cursor |
| ,hH | Run Hoogle and prompt for input |
| ,hi | Run Hoogle for detailed information on word under cursor |
| ,hI | Run Hoogle for detailed information and prompt for input |
| ,hz | Close the Hoogle search window |
GHCI 重复
如果你在 MacVim 旁边打开 tmux 终端,那么你可以发送 Vim 对其进行选择。这对于评估 GHCI 中的内容非常有效。
| ,rs | Send selected text to tmux |
| ,rv | Change tmux session, window, and pane attachment |
git
| ,g? | Last-committed files (Monday morning key) |
| ,gs | Git status (fugitive) |
| ,gg | Git grep |
| ,gl | Git log (extradition) |
| ,gd | Git diff |
| ,gb | Git blame |
评论
| gc | Comment / Uncomment selection |
对齐
| ,a= | Align on equal signs |
| ,a, | Align on commas |
| ,a| | Align 垂直 bar |
| ,ap | Align on character of your choice |
分割并查找文件
| ,<space> | Fuzzy file find (CtrlP) |
| ,f | Toggle file browser, find file |
| ,F | Toggle file browser |
| ,sj | Open split below |
| ,sk | Open split above |
| ,sh | Open split leftward |
| ,sl | Open split rightward |
缓冲器
| ,bp | Previous buffer |
| ,bn | Next buffer |
| ,b<space> | Buffer fuzzy finder |
| ,bd | Delete buffer, keep window open (bbye) |
| ,bo | Close all buffers except the current one |
杂项
| ,ma | Enable mouse mode (default) |
| ,mo | Disable mouse mode |
| ,ig | Toggle indentation guides |
| ,u | Interactive undo tree |
| ,ss | Enable spell checking |
| ,e | Open file prompt with current path |
| ,<cr> | Clear search highlights |
| ,r | Redraw screen |
| C-h | Move cursor to leftward pane |
| C-k | Move cursor to upward pane |
| C-j | Move cursor to downward pane |
| C-l | Move cursor to rightward pane (redraw is ,r instead) |
| gq | Format selection using hindent for haskell buffers (par for others) |
| ,y | Yank to OS clipboard |
| ,d | Delete to OS clipboard |
| ,p | Paste from OS clipboard |
(如果您希望恢复C-l的默认屏幕重绘操作
然后将 unmap <c-l> 添加到您的 vimrc.local 中)
定制
安装此配置后,您的 .vimrc 和 .vim 将
处于版本控制之下。不要更改这些文件。相反,添加
你自己的设置为~/.config/haskell-vim-now/vimrc.local.pre,
~/.config/haskell-vim-now/vimrc.local.
添加 Vim 插件
Haskell-Vim-Now 使用 vim-plug 安装插件。它使用以下 vim 配置结构 确定要安装的内容:
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()
然而 Haskell-Vim-Now 中的 .vimrc 文件处于版本控制之下
所以你不应该直接编辑它。添加插件你应该做什么
要做的就是将 Plug 语句添加到 ~/.config/haskell-vim-now/plugins.vim 中。
准备好后重新加载 .vimrc 并运行 :PlugInstall 来安装插件。
Neovim 支持
.vimrc配置与Neovim完全兼容,并添加了一些
Neovim 终端模式的特定映射(终端仿真已激活
与 :terminal)。这些映射使 Esc 和 c-[hjkl] 发挥作用
期望他们从正常模式。
Neovim 配置位于 .config/nvim,并且符号链接就像
常规 vim,这意味着您应该只添加自己的设置
~/.config/haskell-vim-now/vimrc.local.pre, ~/.config/haskell-vim-now/vimrc.local
和 ~/.config/haskell-vim-now/plugins.vim。
您可以通过运行 scripts/neovim.sh 快速备份和替换 Neovim 设置
脚本。
Docker镜像
如果您想使用 Docker 进行开发,则可以使用该映像。
docker pull haskell:7.8
docker build -t haskell-vim .
docker run --rm -i -t haskell-vim /bin/bash
如果你想从图像中提取 vim 设置,那很简单
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
但是,有些东西(例如 hoogle 数据库)使用绝对路径并且无法正常工作。
高级安装方法
基本安装
如果您想跳过 haskell 特定组件并想要安装 只是你可以使用的常见 vim 配置:
bash <(curl -sL https://git.io/haskell-vim-now) --basic
在 Nix 构建环境中安装
使用 --nix 参数,如果你想在 nix-shell 中执行 堆栈安装
bash <(curl -sL https://git.io/haskell-vim-now) --nix
故障排除
请参阅此 维基 有关解决安装问题的提示页面。
谢谢你!
非常感谢 贡献者。我特别要感谢 @SX91 重写安装程序和其他重大改进。