question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GVim starts slowly with enable_for_buffer()

See original GitHub issue

If you’re having trouble with NCM2, Please provide the following information along with your detailed issue description:

OS

Windows 10 Pro 1803

neovim :version output

GVim 8.1 with patch 1-116

Minimal vimrc for reproducing the issue

set nocompatible
set fileformat=unix
set fileformats=unix,dos
set encoding=utf-8

call plug#begin('E:\ProgramFiles\Vim\vimfiles\plugged')
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
call plug#end()

autocmd BufEnter * call ncm2#enable_for_buffer()

neovim :messages output when the error occurs

N/A.

Log files if you think the issue is a bug

gvim --startuptime log.txt

with and without the autocmd BufEnter * call ncm2#enable_for_buffer().

Additional description

In short, is there a solution to make this autocmd work without slowing down the startup?

Basically, with autocmd BufEnter * call ncm2#enable_for_buffer() in my full vimrc, it could take as much as about 2.6s to start GVim while it takes only about 500ms to start without this autocmd. However, it is necessary to put this autocmd in my vimrc since I usually load a session before working.

Startup timing log files of minimal vimrc are attached below. Thanks in advanced.

log.txt log_wo.txt

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
YaLTeRcommented, Aug 3, 2018

I believe I’m hitting the same issue, with neovim-gtk, except it straight up hits a timeout and shows an error message with

autocmd BufEnter * call ncm2#enable_for_buffer()

so it’s rather critical. Launching nvim in terminal works fine.

autocmd InsertEnter * call ncm2#enable_for_buffer()

seems to work too but it’s a workaround.

Edit: turns out the InsertEnter workaround doesn’t work very well: it makes the LSP completions not show up until the language client is manually restarted (probably due to it initializing before ncm2). I switched to the timer workaround.

1reaction
roxmacommented, Jul 28, 2018

Hmm…

If you don’t want ncm2 to start as vim starts.

Try something like


    function s:ncm2_start(...)
        if v:vim_did_enter
            call ncm2#enable_for_buffer()
        endif
        autocmd BufEnter * call ncm2#enable_for_buffer()
    endfunc
    call timer_start(500, function('s:ncm2_start'))

or

autocmd InsertEnter * call ncm2#enable_for_buffer()
Read more comments on GitHub >

github_iconTop Results From Across the Web

Speed up opening buffer (might be irrelevant) #53 - GitHub
The slow opening of the buffer is not caused by the plugin manager but is caused by the the VimEnter autocmd from some...
Read more >
Vim slows down with multiple buffers etc
Try disabling vim-bufferline plugin. I see some performance issues on it's Github tracker. – grodzik. Dec 16, 2016 at 8:19.
Read more >
How to speed up vim's buffer open? - Stack Overflow
How i can speed up buffer open for the first time? I find myself often use ctrl-p and load is very slow. Also...
Read more >
Vim slow at rendering the buffer with LaTeX syntax highlighting
Try opening the file with: vim -u NONE filename.tex to disable your .vimrc and other scripts from loading for the session. If this...
Read more >
Profiling Vim to Find Out Which Plugin Makes Vim Slow
Find out which plugin makes Vim slow to start​​ You can profile the startup process of Vim by adding the --startuptime option during...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found