一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

haskell-vim-now:实践指南

时间:2026-09-10 18:34:01 编辑:袖梨 来源:一聚教程网

在项目中评估haskell-vim-now,可以先看清用途边界:一行 Haskell Vim 安装。把它放到日常自动化流程中,最容易暴露的是输入边界、依赖和失败处理如果不清楚就很难稳定复用,不能只看演示是否顺利。更实际的做法是用一项范围明确的真实任务完成最小试跑,同时核对配置时间、输出质量、异常信息和维护痕迹,不要直接在关键项目上。对愿意先做小范围验证并复查原始文档的团队来说,这个仓库值得继续验证;只求即装即用的人则要先看维护成本。

Haskell Vim IDE

不到十分钟,你的 Vim 就会变成一个漂亮的 哈斯克尔天堂。 (别担心,它会备份您的原始数据 配置为 ~/.config/haskell-vim-now/backup/.vimrc.yearmonthdate_time。)它还构建所有必要的支持二进制文件 包括ghcidehlinthoogle等。

不再费力地通过插件试图让它们一起工作。 十分钟内你将拥有一个功能齐全、看起来很棒的 Vim 并让你

  • 检查类型
  • 评估哈斯克尔
  • 棉绒和检查
  • 操纵标签
  • 霍格尔查找
  • 无点重构
  • 选项卡完成
  • 统一码符号
  • 突出显示DSLs
  • 使用 git

安装

只需下载并运行安装程序:

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
,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

胡格尔

,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 重复

如果你在 MacVim 旁边打开 tmux 终端,那么你可以发送 Vim 对其进行选择。这对于评估 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

评论

gcComment / Uncomment selection

对齐

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

分割并查找文件

,<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

缓冲器

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

杂项

,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

(如果您希望恢复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)。这些映射使 Escc-[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 重写安装程序和其他重大改进。

热门栏目