I’ve been a happy Vim user for a little while now. With the exception of Objective-C for iOS development (too much of a pain without Xcode’s completion), I’ve been writing all of my code in Vim.
However, I have not been making use of Vim’s auto-completion features, due to a serious performance issue when used with Ruby files. Completion was painfully slow. It was annoying when triggering completion manually, but it was a complete show-stopper when used with an automatic completion plugin like NeoComplCache.
Finally, I got a clue from this StackOverflow response:
Had a very similar problem since upgrading to Vim 7.3 (from 7.2): I was using the (excellent) ACP plugin and in longer source files (C-files, 1700 LOC), the popup took ages to jump through the suggestions when I was editing near the bottom of the file.
Using the PerformanceValidator (from Softwareverify), I found out that some fold methods were called again and again and lead to very high processor load and slow completion.
My workaround was to set the foldmethod (fdm) to manual. And this solved it…
Now, I was having issues with fairly short Ruby files, as opposed to the large C files that this responder was editing. However, it clued me in to the fact that foldmethod was getting called a lot during auto-completion, and led me to experiment.
Finally, I found the issue:
foldmethod=syntax is dog-ass slow when editing Ruby syntax files.
As soon as I switch to any other foldmethod, Ruby auto-completion becomes instant. I’ve been using foldmethod=indent, which creates folds based on code indent levels. This seems to work as well for me as syntax-aware folding did.
Hopefully that tip helps out anyone else who found Vim auto-completion strangely non-performant while working with Ruby files.