2

After noticing some lag that only happens when I use neovim to open Ruby files, I have debugged it and find the result quite interesting (from ms 255 to ms 1294):

times in msec
 clock   self+sourced   self:  sourced script
 clock   elapsed:              other lines

000.011  000.011: --- NVIM STARTING ---
000.779  000.768: locale set
001.476  000.697: inits 1
001.495  000.019: window checked
002.105  000.610: parsing arguments
002.110  000.005: expanding arguments
002.217  000.107: inits 2
002.547  000.330: init highlight
003.332  000.246  000.246: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim
003.471  000.510  000.264: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/synload.vim
032.373  028.808  028.808: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/filetype.vim
032.458  029.613  000.295: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syntax.vim
035.139  002.590  002.590: sourcing /Users/huyvo/.config/nvim/autoload/plug.vim
040.513  002.977  002.977: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftoff.vim
066.653  024.721  024.721: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/filetype.vim
066.877  000.053  000.053: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftplugin.vim
067.060  000.042  000.042: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/indent.vim
067.277  000.052  000.052: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/filetype.vim
067.456  000.047  000.047: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftplugin.vim
067.682  000.030  000.030: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/indent.vim
068.327  000.178  000.178: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim
069.049  000.160  000.160: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim
069.383  000.156  000.156: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/syncolor.vim
076.225  007.741  007.425: sourcing /Users/huyvo/.config/nvim/plugged/nord-vim/colors/nord.vim
076.373  073.635  005.590: sourcing /Users/huyvo/.config/nvim/init.vim
076.379  000.198: sourcing vimrc file(s)
077.077  000.201  000.201: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/utility.vim
077.502  000.133  000.133: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/highlight.vim
078.311  001.671  001.337: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/plugin/gitgutter.vim
078.910  000.475  000.475: sourcing /Users/huyvo/.config/nvim/plugged/vim-surround/plugin/surround.vim
079.628  000.576  000.576: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/plugin/lightline.vim
080.824  001.015  001.015: sourcing /Users/huyvo/.fzf/plugin/fzf.vim
081.703  000.757  000.757: sourcing /Users/huyvo/.config/nvim/plugged/fzf.vim/plugin/fzf.vim
081.930  000.105  000.105: sourcing /Users/huyvo/.config/nvim/plugged/vim-startify/plugin/startify.vim
082.597  000.143  000.143: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/autoload/nerdtree.vim
083.686  000.470  000.470: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/path.vim
083.884  000.111  000.111: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/menu_controller.vim
084.039  000.077  000.077: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/menu_item.vim
084.217  000.100  000.100: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/key_map.vim
084.498  000.203  000.203: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/bookmark.vim
084.792  000.213  000.213: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/tree_file_node.vim
085.240  000.365  000.365: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/tree_dir_node.vim
085.512  000.191  000.191: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/opener.vim
085.811  000.218  000.218: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/creator.vim
085.937  000.047  000.047: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/flag_set.vim
086.144  000.130  000.130: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/nerdtree.vim
086.586  000.365  000.365: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/ui.vim
086.696  000.026  000.026: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/event.vim
086.813  000.040  000.040: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/lib/nerdtree/notifier.vim
087.268  000.366  000.366: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/autoload/nerdtree/ui_glue.vim
103.030  000.101  000.101: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/nerdtree_plugin/exec_menuitem.vim
103.591  000.511  000.511: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/nerdtree_plugin/fs_menu.vim
104.421  000.693  000.693: sourcing /Users/huyvo/.config/nvim/plugged/vim-nerdtree-tabs/nerdtree_plugin/vim-nerdtree-tabs.vim
104.617  022.568  018.197: sourcing /Users/huyvo/.config/nvim/plugged/nerdtree/plugin/NERD_tree.vim
109.363  004.623  004.623: sourcing /Users/huyvo/.config/nvim/plugged/nerdcommenter/plugin/NERD_commenter.vim
116.162  006.246  006.246: sourcing /Users/huyvo/.config/nvim/plugged/vim-fugitive/plugin/fugitive.vim
117.079  000.304  000.304: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale.vim
118.349  000.205  000.205: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/toggle.vim
118.826  002.472  001.964: sourcing /Users/huyvo/.config/nvim/plugged/ale/plugin/ale.vim
119.636  000.095  000.095: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/pythonx.vim
199.542  080.219  080.124: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/python.vim
239.339  000.269  000.269: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/remote/host.vim
239.441  039.710  039.441: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/python3.vim
239.785  120.779  000.850: sourcing /Users/huyvo/.config/nvim/plugged/YouCompleteMe/plugin/youcompleteme.vim
240.366  000.036  000.036: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/gui_shim.vim
240.723  000.317  000.317: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/gzip.vim
240.791  000.027  000.027: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/health.vim
240.899  000.071  000.071: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/man.vim
241.515  000.576  000.576: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/matchit.vim
241.803  000.190  000.190: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/matchparen.vim
242.308  000.457  000.457: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/netrwPlugin.vim
242.982  000.192  000.192: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/remote/define.vim
243.066  000.503  000.311: sourcing /Users/huyvo/.local/share/nvim/rplugin.vim
243.074  000.713  000.210: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/rplugin.vim
243.140  000.019  000.019: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/rrhelper.vim
243.292  000.108  000.108: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/shada.vim
243.373  000.032  000.032: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/spellfile.vim
243.563  000.146  000.146: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/tarPlugin.vim
243.700  000.092  000.092: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/tohtml.vim
243.771  000.026  000.026: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/tutor.vim
244.002  000.182  000.182: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/plugin/zipPlugin.vim
244.013  003.354: loading plugins
244.111  000.098: loading packages
244.326  000.049  000.049: sourcing /Users/huyvo/.config/nvim/plugged/ale/after/plugin/ale.vim
244.343  000.183: loading after plugins
244.351  000.008: inits 3
245.530  001.179: reading ShaDa
247.687  002.156: clearing screen
254.170  002.672  002.672: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/syntax/ruby.vim
255.154  000.225  000.225: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider/ruby.vim
1294.907  1040.213  1039.989: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/ftplugin/ruby.vim
1296.065  000.501  000.501: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/indent/ruby.vim
1296.577  000.386  000.386: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/autoload/lightline.vim
1297.137  000.048  000.048: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/autoload/lightline/tab.vim
1297.633  000.193  000.193: sourcing /Users/huyvo/.config/nvim/plugged/lightline.vim/autoload/lightline/colorscheme.vim
1298.123  000.854  000.661: sourcing /Users/huyvo/.config/nvim/plugged/nord-vim/autoload/lightline/colorscheme/nord.vim
1301.287  000.062  000.062: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/events.vim
1301.666  000.200  000.200: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/util.vim
1302.204  000.291  000.291: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/linter.vim
1302.882  000.366  000.366: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/brakeman.vim
1303.305  000.368  000.368: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/rails_best_practices.vim
1303.730  000.371  000.371: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/reek.vim
1304.144  000.360  000.360: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/rubocop.vim
1304.549  000.354  000.354: sourcing /Users/huyvo/.config/nvim/plugged/ale/ale_linters/ruby/ruby.vim
1307.615  000.051  000.051: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/pattern_options.vim
1309.866  000.999  000.999: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/engine.vim
1310.342  000.118  000.118: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/handlers/rubocop.vim
1310.679  000.072  000.072: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/history.vim
1311.167  000.058  000.058: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/command.vim
1326.470  000.765  000.765: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/job.vim
1349.343  052.544: opening buffers
1350.024  000.365  000.365: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter.vim
1351.377  000.145  000.145: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/async.vim
1351.682  000.151  000.151: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/debug.vim
1377.794  021.768  021.768: sourcing /Users/huyvo/.config/nvim/plugged/vim-gitgutter/autoload/gitgutter/diff.vim
1400.106  028.334: BufEnter autocommands
1400.123  000.017: editing files in windows
1401.999  001.034  001.034: sourcing /Users/huyvo/.config/nvim/plugged/YouCompleteMe/autoload/youcompleteme.vim
1525.528  000.147  000.147: sourcing /usr/local/Cellar/neovim/0.2.2_1/share/nvim/runtime/autoload/provider.vim
1605.589  204.286: VimEnter autocommands
1605.597  000.008: before starting main loop
1606.038  000.176  000.176: sourcing /Users/huyvo/.config/nvim/plugged/ale/autoload/ale/cursor.vim
1623.767  017.995: first screen update
1623.771  000.004: --- NVIM STARTED ---

Sourcing ruby.vim takes very long time to finish, I don't think that the root cause is because of my settings and plugins, but because neovim somehow just doesn't know where my ruby path is.

Adding let g:ruby_path="/usr/bin/ruby" to the configuration file does solve the lagging problem, but it raises another question: what's wrong with neovim and ruby path? And if neovim doesn't know where Ruby path is at the beginning, why does it take so long to find the path?

I used to look for the init.vim of other Ruby developers. None of them explicitly set ruby path in their config. If they don't have the lagging problem then why me?

My configuration can be found at https://github.com/huyvohcmc/dotfiles/blob/master/init.vim

Update: Here is my result when I run checkhealth fyi:

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $XTERM_VERSION=''
  - INFO: $VTE_VERSION=''
  - INFO: $SSH_TTY=''

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

## Python 2 provider (optional)
  - INFO: Using: g:python_host_prog = "/usr/local/bin/python"
  - INFO: Executable: /usr/local/bin/python
  - INFO: Python2 version: 2.7.14
  - INFO: python-neovim version: 0.2.4
  - OK: Latest python-neovim is installed: 0.2.4

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/usr/local/bin/python3"
  - INFO: Executable: /usr/local/bin/python3
  - INFO: Python3 version: 3.6.4
  - INFO: python3-neovim version: 0.2.4
  - OK: Latest python3-neovim is installed: 0.2.4

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin17]
  - INFO: Host: /Users/huyvo/.rbenv/shims/neovim-ruby-host
  - OK: Latest "neovim" gem is installed: 0.7.1

## Node provider (optional)
  - INFO: Node: v8.9.4
  - INFO: Host: /Users/huyvo/.nvm/versions/node/v8.9.4/bin/neovim-node-host
  - OK: Latest "neovim" npm is installed: 3.5.2

closed as off-topic by Martin Tournoij Mar 19 '18 at 7:48

  • This question does not appear to be about Vi and Vim family of editors, within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • what's the result of :CheckHealth command? that's first thing to do when you have trouble with Neovim plugins – number5 Mar 17 '18 at 4:28
  • @number5 checkhealth show no warnings or errors, I'll update it to the question. – Huy Vo Mar 17 '18 at 4:47
  • 2
    my gut feel is this has something to do with your rbenv setup - INFO: Ruby: ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin17] - INFO: Host: /Users/huyvo/.rbenv/shims/neovim-ruby-host . Maybe try to use Ruby 2.4 as your host to see if it make any difference, if not I suggest you create a github issue on neovim project – number5 Mar 17 '18 at 12:21
  • @number5 It's definitely rbenv that cause the lagging - switch to rvm solved the problem. – Huy Vo Mar 17 '18 at 17:13
  • I'm voting to close this question as off-topic because it's not a question about Vim, but rather a question about Ruby/rbenv. – Martin Tournoij Mar 19 '18 at 7:48