Delay when exiting insert mode in large files
I installed vim-pandoc and from the first use there is a ~1 second delay when I hit Esc to exit insert mode. Here is my .vimrc, I dont see anything that could be a problem. I made sure that vim-pencil is off.
" vim-plug
" Specify a directory for plugins
" - For Neovim: ~/.local/share/nvim/plugged
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
Plug 'tpope/vim-sensible'
Plug 'tpope/vim-sleuth'
" Cycle through themes with F4
"Plug 'vim-scripts/CycleColor'
Plug 'scrooloose/nerdcommenter'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'vim-pandoc/vim-pandoc'
Plug 'vim-pandoc/vim-pandoc-syntax'
Plug 'godlygeek/tabular'
"Plug 'plasticboy/vim-markdown'
Plug 'altercation/vim-colors-solarized'
Plug 'reedes/vim-pencil'
Plug 'zhou13/vim-easyescape'
Plug 'freitass/todo.txt-vim'
Plug 'chrisbra/Colorizer'
Plug 'tpope/vim-surround'
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Initialize plugin system
call plug#end()
set spell spelllang=en_us
set relativenumber
set wildmode=longest:full,full
"Easy Escape
"
let g:easyescape_chars = { "j": 1, "k": 1 }
let g:easyescape_timeout = 100
cnoremap jk <ESC>
cnoremap kj <ESC>
"--------------------------------------
" VimPencil
"
noremap <silent> <F7> :<C-u>PFormatToggle<cr>
inoremap <silent> <F7> <C-o>:PFormatToggle<cr>
"let g:pencil#joinspaces = 1
"----------------------------------------
" Make Directories when they don't exist
" https://stackoverflow.com/a/4294176/4297100
"
function s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
augroup BWCCreateDir
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
augroup END
"-------------------------------------------
"" Theme
syntax enable
let g:solarized_contrast="high"
let g:solarized_visibility="low"
set background=light
colorscheme solarized
let g:airline_theme='solarized'
The only thing that comes to mind that might be causing this is the folding code, since we change the fold method in insert, and it can be expensive in some cases. Other thing that can cause this kind of behaviour is the autoformatting stuff, but you don't have it enabled. You could try blacklisting the folding module from vim-pandoc.
I tried that now and the problem remains. I swill have folds however, did I do it right? I added let g:pandoc#modules#disabled=[vim-pandoc-folding-module] to my .vimrc and restarted. I noticed that short files work fine, It's just a really long file (4700 lines).
I also have this problem (file of 3200 lines). Turning off folding fixes the problem - there's no delay at all. However, when you're editing large files is of course when you need folding the most.
I turned off folding with: let g:pandoc#modules#disabled=["folding"].
Would it be possible to keep folding but still not have the delay? I used vim-markdown before and then there was no delay even though folding was used. Why is the fold method changed?
The problem is that the default path for the folding code is very complex. vim-markdown's folding code is way simpler than ours in comparison. You can try to use
let b:pandoc_folding_basic = 1
so that it uses a simpler path to decide what to fold. You might lose relative folding then (if you were using that), but it should work in most cases.
I tried setting it but then it gets just as slow as when I have ordinary path.
I have the same problem. Using the basic folding like you suggested reduce the delay, but the only way to remove it is by disabling folding completely. With folding disabled also the file opening becomes faster.