All Articles

Rescuing Your Frozen Vim

frozen-vim

It is an unusual case, but sometimes the Vim editor may freeze and become unresponsive. In such cases, it is helpful to enable verbose logging to diagnose the issue. The first step is to start Vim with verbose logging enabled. We could use the -V option followed by a number that indicates the verbosity level and a filename to store the log. By reading the help documentation for the -V option, we find the following information:

:help verbose
-V[N]{filename}
                Like -V and set 'verbosefile' to {filename}.  The result is
                that messages are not displayed but written to the file
                {filename}.  {filename} must not start with a digit.
                Example:
                        vim -V20vimlog foobar

Then we can start Vim with the following command:

vim -V20vimlog [filename]

For my case, the last lines in vimlog were:

line 1:   return !has('nvim') || deoplete#custom#_get_option('yarp')
deoplete#util#has_yarp returning #1

continuing in deoplete#util#rpcnotify

line 8:     if g:deoplete#_yarp.job_is_dead
line 9:       return ''
line 10:     endif
line 11:     call g:deoplete#_yarp.notify(a:method, a:context)
calling yarp#

This output indicates that the issue is related to the deoplete plugin and its interaction with yarp. To resolve this, I enlarged the delay of the deoplete plugin so it would not frequently interact with yarp, to help the Vim editor to be more responsive.

--- a/.vim/plugin/config.deoplete.vim
+++ b/.vim/plugin/config.deoplete.vim
@@ -1 +1,5 @@
 let g:deoplete#enable_at_startup = 1
+call deoplete#custom#option({
+\   'auto_complete_delay': 200,
+\   'smart_case': v:true,
+\})