Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Editing markdown file very unresponsive #5

Open
bytesource opened this Issue · 24 comments

6 participants

@bytesource

Hi Suan,

After installation of vim-instant-markdown using Vundle and following the instructions in the README I found the following problem:

On opening a markdown file in Vim, the same file opens in a browser window.
Unfortunately, editing the file is very unresponsive. I can only type about one character per second, otherwise characters get lost. Also, the browser window does not update and a manual reload of the page leads to a could not connect to localhost:8090.

I am sure the problem must be on my side, otherwise someone would have reported it before me. However, I just have no clue of what might have gone wrong.

Stefan

@suan
Owner

Could you try following the instructions here? #1 (comment) ?

Someone else there is having similar issues.

@suan
Owner

Sorry for the delay, and let's bring the discussion back here. When you say there's unresponsiveness, do you mean vim itself becomes laggy or that the browser window is slow to reflect the changes?

Would you happen to have a slow machine/VM? Unfortunately my implementation can be CPU-hungry, and there have been times when I've crashed instant-markdown-d by backscaping a lot of words rapidly while there were other things using my CPU at the same time.

Perhaps another possibility is that you have very old redcarpet, pygments.rb or node.js versions installed, which are slow?

I've been thinking of making the backend limit the number of concurrent processes it spawns off (to something like 3) - that might help with slower machines.

@bytesource

I meant that Vim itself becomes laggy, not the browser.

I installed redcarpet 2.1.1 through RVM.

To be honest, I don't know much about node.js. I installed the lastest npm, so I guess this also installed the latest version of node.js. If this assumption is not correct, I would be glad if you could tell me how to figure out the currently installed version of node.js.

Stefan

@suan
Owner

So if I understand correctly, even though vim becomes leggy, the browser does update? If thats the issue I'm not sure if I can help. Maybe try disabling other vim plugins?

You should be able to check your node version by doing node --version I think.

@bytesource

Vim becomes unresponsive and the browser does not update.

Thanks for telling me how to check the node version. I just checked an mine is v0.4.9.

@suan
Owner

Hmm, that's really weird. I've noticed @irrationalfab which had a somewhat related problem created a workaround here: https://github.com/irrationalfab/vim-instant-markdown/blob/master/plugin/instant-markdown.vim

Perhaps download that version of the plugin file and see if that improves things for you?

@bytesource

I installed the fork from @irrationalfab.

Now the browser window updates after every change, but Vim is as unresponsive as before, unfortunately.

@fabiopelosin

I noticed unresponsiveness if you have code blocks (especially github flavored ones). Could this be your issue?

@bytesource

I mainly use markdown for my projects' README files and these all contain code blocks such as

def xyz
  #...
end

If you noticed unresponsiveness with code blocks then this could certainly be the issue.

Stefan

@bytesource

I just tried both irrationalfab/vim-instant-markdown' and suan/vim-instant-markdown on an empty markdown file. Unfortunately both versions of the plugin still make Vim unresponsive, that is if I type more than about one character per second, some characters just get 'swallowed'.

@suan
Owner

@bytesource What OS and vim version are you using? Not sure what would be causing such a severe lag like that (I'm sure the lag @irrationalfab is seeing can't be that bad, otherwise he'd be complaining too ;-) ). Have you tried disabling all other vim plugins and customizations?

The only thing I can recommend right now is to update your node.js version, though I'm not sure that it would help.

P/S: I've merged Fabio's changes into my main repo, so you should be able to just use that from now on.

@bytesource

After removing all of my plugins, and then only installing suan/vim-instant-markdown, instant-markdown now works flawlessly! It really is a great plugin.

I still need to find out which of the plugins caused the error, though. As I had a lot of plugins installed this might take some time. Or maybe you can spot a possible candidate in the following list.

List of previously installed plugins:

CSApprox
Command-T
IndexedSearch
VimClojure
bufexplorer.zip
grep.vim
nerdtree
repeat.vim
securemodelines
session.vim--Odding
snipmate-snippets
snipmate.vim
supertab
syntastic
tabular
tagbar
textile.vim
vim-abolish
vim-fugitive
vim-markdown
vim-rails
vim-ruby
vim-ruby-sinatra
vim-slime
vim-surround
zencoding-vim

Stefan

@suan
Owner

Glad it works! Hmmm, looking though that list I can only cross out fugitive.vim right now, since I use that too without problems.

One thing that might help is to do a grep for CursorMoved or CursorHold across all your plugins. I think there's a good chance that the problem plugin is one that uses those autocmds.

@bytesource

This is the output:

$ egrep -r -w 'CursorMoved|CursorHold' ~/.vim/bundle/
/home/sovonex/.vim/bundle/IndexedSearch/plugin/IndexedSearch.vim:    au CursorHold * 
/home/sovonex/.vim/bundle/IndexedSearch/plugin/IndexedSearch.vim:        " when too_slow, we'll want to switch the work over to CursorHold
/home/sovonex/.vim/bundle/IndexedSearch/plugin/IndexedSearch.vim:    let too_slow = 0 " if too_slow, we'll want to switch the work over to CursorHold
/home/sovonex/.vim/bundle/IndexedSearch/plugin/IndexedSearch.vim:            let too_slow=1 "  if too_slow, we'll want to switch the work over to CursorHold
/home/sovonex/.vim/bundle/IndexedSearch/plugin/IndexedSearch.vim:" - implement CursorHold bg counting to which too_slow will resort
/home/sovonex/.vim/bundle/tagbar/autoload/tagbar.vim:        doautocmd CursorHold
/home/sovonex/.vim/bundle/tagbar/autoload/tagbar.vim:        autocmd CursorHold __Tagbar__ call s:ShowPrototype()
/home/sovonex/.vim/bundle/tagbar/autoload/tagbar.vim:        autocmd BufEnter,CursorHold,FileType * call
/home/sovonex/.vim/bundle/tagbar/doc/tagbar.txt:will only happen on the |CursorHold| event and when switching buffers (or
/home/sovonex/.vim/bundle/session.vim--Odding/autoload/xolox/misc/msg.vim:        autocmd! CursorHold,CursorHoldI * call s:clear_message()
/home/sovonex/.vim/bundle/vim-instant-markdown/plugin/instant-markdown.vim:autocmd CursorMoved,CursorMovedI,CursorHold,CursorHoldI *.{md,mkd,mkdn,mark*} silent call UpdateMarkdown()
/home/sovonex/.vim/bundle/supertab/plugin/supertab.vim:    exec 'autocmd CursorHold * ' .
@bytesource

I successively removed tagbar, IndexedSearch, supertab, and session, but the problem remains.

@suan
Owner

Hmmm, are any of the remaining plugins the type where something happens everytime you make a change in the buffer or move the cursor?

@bytesource

Not that I know of

@suan
Owner

Looks like you'll have to find out the hard way then :(

I went ahead and crossed out the plugins we've already tested in your original comment

@bytesource

I removed my plugins one at a time, but this when I had removed all plugins except for instant-markdown the unresponsiveness was still there. Now I am not quite sure why that is.

@bytesource bytesource closed this
@bytesource bytesource reopened this
@fabiopelosin

I'm sure the lag @irrationalfab is seeing can't be that bad, otherwise he'd be complaining too ;-)

The lag was noticeable with code blocks of a couple of lines... However I thought that it was due to redcarpet not being fast enough. So I didn't report the issue.

After removing all of my plugins, and then only installing suan/vim-instant-markdown, instant-markdown now works flawlessly! It really is a great plugin.

I agree it is really a great plug-in! And I'm glad to see that the performance issues are not an underlying limitation.

I removed my plugins one at a time, but this when I had removed all plugins except for instant-markdown the unresponsiveness was still there.

This bug is going to be very thought to track back. Unfortunately I can't help because mi knowledge of vim internals is null :-)

@avit

I'm having the same problem here. Wondering if there's a way to disable the autocmd so I can call UpdateMarkdown() manually.

@suan
Owner

@avit Yes I think that would be a good feature both as a workaround for people with lag issues, and as a workflow that's preferred by some others. I'll try to implement that, but no promises on when that would be. Pulle requests would be great! :)

@vsushkov

Maybe curl request should be sent not every time but only when 10 (or so) keyboard events have been done?

@chreekat

Y'all may want to consider my g:instant_markdown_slow option over at #18!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.