Vim 使用 ruby 语法高亮显示很慢 [英] Vim slow with ruby syntax highlighting
问题描述
我已经在 ssh 上使用 vim 工作了一两个星期,一切都很顺利.今天我决定添加一些语法高亮、自动完成和其他一些通用插件.设置 vundle 并开始工作.
I've been using vim over ssh to work for a week or two now and all has been going great. Today I decided to add in some syntax highlighting, autocomplete, and some other general plugins. Set up vundle and went to work.
我当前的 .vimrc 可以在 https://github 上找到.com/scotopell/dotfiles/blob/master/.vimrc
我已将我的 vimrc 和 vim 文件克隆到我的本地 ubuntu 桌面,vim 完全按预期运行,我可以找到的任何文件都没有变慢.相同的插件和相同的 vimrc 并且在 ruby 文件上没有缓慢.
I have cloned my vimrc and vim files onto my local ubuntu desktop and vim runs exactly as expected, no slowness on any files that I can find. Same plugins and same vimrc and no slowness on ruby files.
更新
我可以用下面的 .vimrc 重现这个问题
I can reproduce this issue with the following .vimrc
syntax on
和一个空的 ~/.vim
文件夹.
and an empty ~/.vim
folder.
然而,这个 vps 上的 vim 对于 ruby/haml 文件非常慢.更多红宝石文件.当我打开任何 ruby 文件时,启动大约需要 2 秒(用 --startuptime 计时).使用可比长度的haml 文件,大约需要0.5 秒.这种缓慢不仅仅是在启动时,移动和编辑文件都非常缓慢.
However, vim on this vps is very slow with ruby/haml files. Much moreso ruby files. When I open any ruby file, startup takes about 2 seconds (timed with --startuptime). With a comparable length haml file, its about .5 seconds. This slowness isn't just on startup either, moving around and editing the file are both painfully slow.
Haml/erb(它们基本相同)
Haml/erb(they are basically the same)
268.818 000.005: before starting main loop
848.871 580.053: first screen update
红宝石
199.613 000.004: before starting main loop
2937.859 2738.246: first screen update
在同一个 ruby 文件上没有语法高亮
Without syntax highlighting on the same ruby file as above
149.047 000.004: before starting main loop
152.912 003.865: first screen update
我试过使用 mosh(http://mosh.mit.edu) 并且它没有没有帮助.不再相关
I have tried using mosh(http://mosh.mit.edu) and it doesn't help. not really relevant anymore
正如你在我的 .vimrc 文件中看到的,我已经尝试了几种不同的解决方案来解决这个问题.我试过在禁用所有插件的情况下运行(我将它们从 ~/vim/bundle/PLUGINNAME
移动到 ~/vim/bundle/disabled/PLUGINNAME
,这是正确的吗?),设置 ruby 路径,将 foldlevel 设置为手动,禁用我的颜色方案,没有任何帮助.见edit3
As you can see in my .vimrc file, I have tried a few different solutions to this problem.
I have tried running with all plugins disabled (I moved them all from ~/vim/bundle/PLUGINNAME
to ~/vim/bundle/disabled/PLUGINNAME
, is this correct?), set ruby path, set foldlevel to manual, disabled my colorscheme, nothing helps. see edit3
如果有帮助,我可以发布任何文件的完整启动时间日志.
我测试了一些其他语言(php、c、python、vimL),但没有遇到任何减速.
I can post the full startupttime log for any file if that will help.
I have tested a few other languages(php, c, python, vimL) and none experience any slowdown.
只是为了澄清一下,我正在使用 ssh user@server 运行 ssh 会话,然后一旦进入服务器,我正在执行 vim file.rb.
Just to clarify, I am running an ssh session with ssh user@server then once inside the server I am doing vim file.rb.
我只是尝试直接访问服务器,但在没有 ssh 的情况下缓慢仍然存在,我已更新以反映这不是 ssh 的问题.
I just tried accessing the server directly and the slowness persists without ssh, I have updated to reflect that this isn't a problem with ssh.
我可以用一个 .vimrc 文件重现这个问题,该文件包含单行 syntax on
和一个空的 ~/.vim 文件夹
I can reproduce the issue with a .vimrc file that contains the single line syntax on
with an empty ~/.vim folder
EDIT4 我卸载了我编译的 vim 版本以及我可能通过 apt 安装的任何版本,手动从我的系统中删除了所有 vim 内容,然后我可以使用 vim -u 运行 vimNONE/path/to/file.rb
然后执行 :syn on 问题就会出现.有问题的文件是一个 rails 控制器,但正如我所说,我可以在某种程度上用大多数文件重新创建它,但 rails 控制器看起来是最糟糕的.
EDIT4 I uninstalled my compiled version of vim and any versions that I may have installed through apt, manually removed all vim stuff from my system, and I can run vim with vim -u NONE /path/to/file.rb
then do :syn on and the issue will be there. The file in question is a rails controller, but like I've said, I can recreate it to some degree with most any file, but rails controllers see to be the worst.
推荐答案
这个问题的解决方案原来是 vim 使用的正则表达式引擎.关于 freenode 上 #vim 的猜测是 ruby 语法文件在新的正则表达式引擎上使用了较慢的东西.
The solution to this problem turned out to be the regex engine that vim uses. The speculation on #vim on freenode is that the ruby syntax files use something that is slower on the new regex engine.
任何早于并包括 Vim 7.3.969 的版本都有旧的正则表达式引擎.将 set re=1
添加到您的 vimrc
以在任何更新的版本上强制使用旧的正则表达式引擎(不要忘记重新加载您当前正在编辑的文件 vimrc
代码>:e).
Any version older than and including Vim 7.3.969 has the old regex engine.
Add in set re=1
to your vimrc
to force the old regex engine on any version newer (and don't forget to reload the file you're currently editing with :e
).
感谢来自 #vim 的 Houl、Dolio 和 dmedvinsky 帮助解决这个问题.
Thanks to Houl, Dolio and dmedvinsky from #vim for help figuring it out.
我还没有机会尝试绝对最新的版本,昨晚有一个提交可能有助于解决这个问题.如果我有机会再次尝试最前沿的版本,我会更新这个.
I haven't had a chance to try the absolute latest version, there was a commit last night that may help with this issue. I will update this if I get the chance to try the bleeding edge version again.
这篇关于Vim 使用 ruby 语法高亮显示很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!