0

I notice an annoying stutter when opening directories. Just a split second, but it's kind of a problem if I'm navigating the directory tree and it hesitates each time I open a different directory.

I thought it might be double-loading something so to debug, I put the following in ~/.vim/ftplugin/netrw.vim:

if !exists('s:count')
  let s:count = 0
endif
let s:count += 1

func! Count()
  echo s:count
endf

and mapped <leader>j to call Count().

If I open a file in vim, and run :edit %:h, a netrw buffer opens with the file's containing directory as expected. The s:count is 2, so my ftplugin was indeed double-loaded. Hitting Enter on a listing to edit that file increments s:count by 1 more.

It's consistent: every time navigate into a directory-buffer, s:count increments by 2, every time I navigate down the file-tree, s:count increments by 1. This also means that if move down the tree into a subdirectory, it increments by 3.

Is this a good indicator that something is loading more times than necessary, and if so how might I fix it?

  • what vim version are you testing with? – Christian Brabandt Jul 14 '17 at 15:32
  • @ChristianBrabandt I'm testing on Vim 8.0.0705 and Neovim 0.2.0_1. I noticed it a while back, but it seems Vim no longer stutters (but still seems to be double-loading the ftplugin file), though Neovim continues to stutter. I looked through recent Vim releases to see if a fix was mentioned but didn't see anything. – ivan Jul 14 '17 at 17:41
  • there was a patch to fix double loading of filetypes just recently. Neovim probably doesn't have it yet – Christian Brabandt Jul 14 '17 at 19:55
  • @ChristianBrabandt Interesting, do you know which patch it was? I'm looking through the recent vim releases as well as :help netrw-history but can't find any mention of it. According to my (maybe flawed?) debugging technique above, Vim is still double loading, but it no longer causes any noticeable hesitation. – ivan Jul 14 '17 at 23:32
  • 1
    Was thinking of patches 649 and 650, but seems they specifically fixed only the help filetype. You might want to ask Charles (maintainer of netrw) or on vim-dev for further advise – Christian Brabandt Jul 15 '17 at 6:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.