Vim slow with ruby syntax highlighting

后端 未结 7 528
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-12 16:59

I\'ve been using vim over ssh to work for a week or two now and all has been going great. Today I decided to add in some syntax highlighting, autocomplete, and some other ge

7条回答
  •  时光说笑
    2020-12-12 17:39

    see UPDATE at the bottom.

    this may be helpful as a workaround -

    i am using vim version

    VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:40:46)

    Included patches: 1-52

    it is the stock version from Linux Mint 17.1 Rebecca.

    the php.vim syntax file is not version'd that i can see, but it sez last edit'd 28 aug 13.

    it isn't a ruby project, but when editing a large php class file (

        $ php -w test.inc | wc
        2    2410   19220
    

    ) i note significant delays near the top of the class, but not above or below the class, and, notably, not toward the bottom of the class. as i attempt to insert new text near the bottom of the class, delay is minimal and seems to be proportional to the line number inside the class. "minimal" means almost instantly, "significant" means 1 to 1.5 seconds per character.

    the file is approx 1800 lines with approx 500 lines of legit php and 1300 lines of comments and doc. the class begins at approx line 30 and ends at approx line 1700. it is conceded it's a bit large, but well documented :-\

    if i insert

        class dummy { }
    

    in front of the original "class originalName {", there is no delay anywhere in the file. this unsightly kluge permits vim/gvim to regain its responsiveness and could be considered a workaround. note no linefeed between the two, just

        class dummy { } class originalName {
    

    it can even be comment'd out:

        /*class dummy {}*/class originalName {
    

    additional info:

    1. during this test, the plugins directory was moved.

    2. with "set syntax=off", the problem completely disappears. this is NOT a fix.

    3. setting the regular expression engine with

      set regexpengine=1   (or any other number)
      

      does not appreciably change the results.

    based on these results, i would suspect the regular expression engine as well. my point is that diddling a bit with the syntax in ruby files may lead to a workaround.

    UPDATE: i have found that the issue is "caused" by setting php_folding to 1 (enabled). the vimrc i THOUGHT i was using was not, but at least some of the mystery is solved due to that mistake. a simple vimrc like this will induce the problem (for me, as least):

        :syntax enable
        :let php_folding = 1
    

    this means my issue is totally unrelated to the ruby issue, but there may be a similar thing going on with the ruby.vim file. maybe not.

    apologies for the deflection.

提交回复
热议问题