我注意到Vim花了很长时间才打开Ruby和ERB(嵌入式Ruby)文件。我描述了我的启动时间和这些有趣的行(如果你想看到它,那么完整的个人资料就在底部):
32980.181 32011.917 32011.917: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/ftplugin/ruby.vim
32980.516 32035.414 022.871: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/ftplugin/eruby.vim
正如您所看到的,为Ruby和ERuby加载ftdetect需要很长时间(显然是“msec”时间)。将此与HTML的ftdetect和加载.vimrc所需的时间进行比较:
952.223 000.626 000.626: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/ftplugin/html.vim
738.536 612.248 534.785: sourcing $HOME/.vimrc
这是正常的,我能做些什么吗?必须等待〜33秒才能打开文件真是令人生气。
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.022 000.022: --- VIM STARTING ---
012.064 012.042: Allocated generic buffers
012.910 000.846: locale set
013.186 000.276: clipboard setup
013.203 000.017: window checked
033.918 020.715: inits 1
034.697 000.779: parsing arguments
034.716 000.019: expanding arguments
077.784 043.068: shell init
079.520 001.736: Termcap init
079.562 000.042: inits 2
080.186 000.624: init highlight
179.889 001.991 001.991: sourcing /Users/davidtuite/.vim/autoload/pathogen.vim
564.261 000.178 000.178: sourcing /Users/davidtuite/.vim/filetype.vim
632.475 000.389 000.389: sourcing /Users/davidtuite/.vim/bundle/jst/ftdetect/jst.vim
633.141 055.478 055.089: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/filetype.vim
660.587 000.236 000.236: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/ftplugin.vim
661.081 000.247 000.247: sourcing /Users/davidtuite/.vim/filetype.vim
661.408 000.041 000.041: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/filetype.vim
673.005 000.208 000.208: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/indent.vim
699.170 000.901 000.901: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/syncolor.vim
699.550 007.236 006.335: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/synload.vim
699.669 008.305 001.069: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/syntax.vim
700.763 000.561 000.561: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/syncolor.vim
715.774 000.497 000.497: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/syncolor.vim
716.658 000.452 000.452: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/syncolor.vim
722.467 010.218 009.269: sourcing /Users/davidtuite/.vim/bundle/solarized/colors/solarized.vim
738.536 612.248 534.785: sourcing $HOME/.vimrc
738.593 046.159: sourcing vimrc file(s)
784.522 000.859 000.859: sourcing /Users/davidtuite/.vim/bundle/ctrlp/autoload/ctrlp/mrufiles.vim
785.378 045.922 045.063: sourcing /Users/davidtuite/.vim/bundle/ctrlp/plugin/ctrlp.vim
816.261 000.454 000.454: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/getscriptPlugin.vim
818.593 000.792 000.792: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/gzip.vim
820.050 000.921 000.921: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/matchparen.vim
830.405 002.463 002.463: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/netrwPlugin.vim
843.038 000.145 000.145: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/rrhelper.vim
850.425 000.293 000.293: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/spellfile.vim
851.617 000.671 000.671: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/tarPlugin.vim
852.558 000.509 000.509: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/tohtml.vim
853.470 000.599 000.599: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/vimballPlugin.vim
854.255 000.463 000.463: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/plugin/zipPlugin.vim
854.362 062.537: loading plugins
854.375 000.013: inits 3
875.931 021.556: reading viminfo
875.995 000.064: setting raw mode
876.010 000.015: start termcap
876.062 000.052: clearing screen
952.223 000.626 000.626: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/ftplugin/html.vim
32980.181 32011.917 32011.917: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/ftplugin/ruby.vim
32980.516 32035.414 022.871: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/ftplugin/eruby.vim
33007.912 000.688 000.688: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/indent/ruby.vim
33024.997 001.804 001.804: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/indent/html.vim
33025.207 025.843 023.351: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/indent/eruby.vim
33067.541 000.929 000.929: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/javascript.vim
33085.205 004.486 004.486: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/vb.vim
33088.445 002.575 002.575: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/css.vim
33089.314 039.262 031.272: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/html.vim
33106.920 003.463 003.463: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/ruby.vim
33107.112 064.122 021.397: sourcing /usr/local/Cellar/vim/7.3.266/share/vim/vim73/syntax/eruby.vim
33107.888 107.447: opening buffers
33108.114 000.226: BufEnter autocommands
33108.117 000.003: editing files in windows
33108.319 000.202: VimEnter autocommands
33108.320 000.001: before starting main loop
33127.031 018.711: first screen update
33127.033 000.002: --- VIM STARTED ---
答案 0 :(得分:9)
延迟可归因于ftplugin / ruby.vim查询Ruby加载路径。就在几天前,我通过放弃查询Ruby Gems显着提高了速度。我的Mac目前报告它需要大约125毫秒,这是一个显着的改进。因此,您可以尝试更新到最新版本。
如果仍然不够,可以通过在vimrc中设置g:ruby_path来完全禁用加载路径查询。
尝试将其添加到.vimrc文件(在您的主文件夹中):
if !empty($MY_RUBY_HOME)
let g:ruby_path = join(split(glob($MY_RUBY_HOME.'/lib/ruby/*.*')."\n".glob($MY_RUBY_HOME.'/lib/rubysite_ruby/*'),"\n"),',')
endif
答案 1 :(得分:0)
如果您只想将vim红宝石路径设置为明确的内容,请将其添加到.vimrc
中的任意位置:
let g:ruby_path = "/Users/<username>/rbenv/shims/ruby"
如果您使用的是rbenv,则只需将<username>
替换为您的实际Mac用户名。
如果您的ruby路径是其他路径,请用引号将可执行文件的完整路径替换引号中的所有内容。