Losing syntax on save #15

Open
mauserrifle opened this Issue Sep 18, 2012 · 13 comments

Comments

Projects
None yet
8 participants
@mauserrifle

I'm using the full spf13-vim package, but I think this issue is related to PIV. When I edit most files of projects (old php code with functions only, or a big class file) I lose syntax highlighting after saving. I got a sample code to reproduce the problem:
http://pastebin.com/UCKxiPQd

  1. Open the file go to the end (G). Syntax should be broken already (look at the variable colors)
  2. Go back to the first line (gg) and scroll down to the end using }. Syntax is working!
  3. Save the file (:w). Syntax is broken again

The strange thing is: if i remove something like the first method (get_id) the problem is gone. When I delete the constants, the problem is gone. Not sure how to fix it myself. I assume the highlighter is breaking on some pattern but that is currently out of my league :(

Due to this bug vim is not usable for all my projects as it happens in almost all files. Hope this can be fixed!

@mauserrifle

This comment has been minimized.

Show comment Hide comment
@mauserrifle

mauserrifle Sep 18, 2012

Got a temporary fix:

:syn on

That brings back highlighting.

Tried to make a autocmd:

:autocmd BufWriteCmd *.php :syn on

But then the bottom status bar loses style :( Oh well I'm happy I can use :syn on for now.

Got a temporary fix:

:syn on

That brings back highlighting.

Tried to make a autocmd:

:autocmd BufWriteCmd *.php :syn on

But then the bottom status bar loses style :( Oh well I'm happy I can use :syn on for now.

@mauserrifle mauserrifle reopened this Sep 18, 2012

@mauserrifle

This comment has been minimized.

Show comment Hide comment
@mauserrifle

mauserrifle Sep 19, 2012

Hmm I have more problems than this. I got a legacy project with horrible code. 1439 lines within one file. With syn on vim takes like 20 seconds to save the file (yes I've timed it). Vim uses 100% CPU during this 20 seconds. Within other editors like Eclipse PDT there is no slowness.

The syntax highlighter seems to be going wild!

With :syn off the save is instant. I tested this with the default spf13-vim config on three machines.

What have I tried without success:

I can't believe i'm the only one having this issue. The three machines are all debian tho.

With PIV disabled the problem is solved, but no more sweet completion :(

Hmm I have more problems than this. I got a legacy project with horrible code. 1439 lines within one file. With syn on vim takes like 20 seconds to save the file (yes I've timed it). Vim uses 100% CPU during this 20 seconds. Within other editors like Eclipse PDT there is no slowness.

The syntax highlighter seems to be going wild!

With :syn off the save is instant. I tested this with the default spf13-vim config on three machines.

What have I tried without success:

I can't believe i'm the only one having this issue. The three machines are all debian tho.

With PIV disabled the problem is solved, but no more sweet completion :(

@spf13

This comment has been minimized.

Show comment Hide comment
@spf13

spf13 Sep 19, 2012

Owner

You've probably hit some edge case in the syntax file or another plugin. If possible if you could email me the PHP file you are using to generate this I could spend time trying to investigate / reproducing.

Best,
Steve

http://stevefrancia.com
http://spf13.com
http://twitter.com/spf13

On Wednesday, September 19, 2012 at 2:42 PM, mauserrifle wrote:

Hmm I have more problems than this. I got an legacy project with horrible code. 1439 lines within one file. With syn on vim takes like 20 seconds to save the file. Vim uses 100% CPU during this 20 seconds. Within other editors like Eclipse PDT there is no slowness.
The syntax highlighter seems to be going wild!
With :syn off the save is instant. I tested this with the default spf13-vim config on three machines.
What have I tried without success:
Disable folding
http://stackoverflow.com/questions/4775605/vim-syntax-highlight-improve-performance
Install vim package from debian sid and squeeze
Use gvim
Use vim in tty1
Compile and use the latest version of vim

I can't believe i'm the only one having this issue. The three machines are all debian tho.
With PIV disabled the problem is solved, but no more sweet completion :(


Reply to this email directly or view it on GitHub (#15 (comment)).

Owner

spf13 commented Sep 19, 2012

You've probably hit some edge case in the syntax file or another plugin. If possible if you could email me the PHP file you are using to generate this I could spend time trying to investigate / reproducing.

Best,
Steve

http://stevefrancia.com
http://spf13.com
http://twitter.com/spf13

On Wednesday, September 19, 2012 at 2:42 PM, mauserrifle wrote:

Hmm I have more problems than this. I got an legacy project with horrible code. 1439 lines within one file. With syn on vim takes like 20 seconds to save the file. Vim uses 100% CPU during this 20 seconds. Within other editors like Eclipse PDT there is no slowness.
The syntax highlighter seems to be going wild!
With :syn off the save is instant. I tested this with the default spf13-vim config on three machines.
What have I tried without success:
Disable folding
http://stackoverflow.com/questions/4775605/vim-syntax-highlight-improve-performance
Install vim package from debian sid and squeeze
Use gvim
Use vim in tty1
Compile and use the latest version of vim

I can't believe i'm the only one having this issue. The three machines are all debian tho.
With PIV disabled the problem is solved, but no more sweet completion :(


Reply to this email directly or view it on GitHub (#15 (comment)).

@mauserrifle

This comment has been minimized.

Show comment Hide comment
@mauserrifle

mauserrifle Sep 20, 2012

Hi Steve,

I have just tried an Arch Linux LiveCD (http://ctkarch.org/), so that is not Debian related. I do not lose the syntax there, but I still have the slow save and 100% CPU on the files i've sent you through e-mail. It even takes 30 seconds because its in virtualbox.

The losing syntax seems Debian related and the slow saving is not Debian related. I think it's one bug, it just acts different on systems.

Regards,
Maurice

Hi Steve,

I have just tried an Arch Linux LiveCD (http://ctkarch.org/), so that is not Debian related. I do not lose the syntax there, but I still have the slow save and 100% CPU on the files i've sent you through e-mail. It even takes 30 seconds because its in virtualbox.

The losing syntax seems Debian related and the slow saving is not Debian related. I think it's one bug, it just acts different on systems.

Regards,
Maurice

@mauserrifle

This comment has been minimized.

Show comment Hide comment
@mauserrifle

mauserrifle Sep 22, 2012

Hello Steve,

Ok I might have precious information.

Slow saving

I changed php_folding to '0' within ~/.vim/bundle/PIV/ftplugin/php.vim

This is 100% the caus of the 20 sec saving! Saving is instant now!

Changed it back to '1' to find its root cause.

The bug is within line 577 of ~/.vim/bundle/PIV/syntax/php.vim:

 syn region phpFoldFunction matchgroup=Storageclass start="^\z(\s*\)\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function\s\([^};]*$\)\@="rs=e-9 matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldHtmlInside,phpFCKeyword contained transparent fold extend

Removing that line fixes my slow save, the same as completely disabling php_folding.

Currently no idea how to debug this line as I am not really a vim expert.

Losing syntax

Still losing syntax highlighting on saving.

Removing the following within ~/.vim/bundle/PIV/syntax/php.vim:

" Clusters
syn cluster phpClConst contains=phpFunctions,phpClasses,phpIdentifier,phpStatement,phpOperator,phpStringSingle,phpStringDouble,phpBacktick,phpNumber,phpType,phpBoolean,phpStructure,phpMethodsVar,phpConstants,phpException,phpSuperglobals,phpMagicConstants,phpServerVars
syn cluster phpClInside contains=@phpClConst,phpComment,phpParent,phpParentError,phpInclude,phpHereDoc,phpNowDoc
syn cluster phpClFunction contains=@phpClInside,phpDefine,phpParentError,phpStorageClass,phpSpecial
syn cluster phpClTop contains=@phpClFunction,phpFoldFunction,phpFoldClass,phpFoldInterface,phpFoldTry,phpFoldCatch

" Php Region
if exists("php_parent_error_open")
  syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop
else
  syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop keepend
endif

Gives the same syntax on loading as when I'm done saving (very gray).

Same goes for removing the whole ~/.vim/bundle/ftplugin/php.vim. This way it's lacking colors, but not complete grayness on save.

Hope this might ring a bell!

Cheers,
Maurice

Hello Steve,

Ok I might have precious information.

Slow saving

I changed php_folding to '0' within ~/.vim/bundle/PIV/ftplugin/php.vim

This is 100% the caus of the 20 sec saving! Saving is instant now!

Changed it back to '1' to find its root cause.

The bug is within line 577 of ~/.vim/bundle/PIV/syntax/php.vim:

 syn region phpFoldFunction matchgroup=Storageclass start="^\z(\s*\)\(abstract\s\+\|final\s\+\|private\s\+\|protected\s\+\|public\s\+\|static\s\+\)*function\s\([^};]*$\)\@="rs=e-9 matchgroup=Delimiter end="^\z1}" contains=@phpClFunction,phpFoldHtmlInside,phpFCKeyword contained transparent fold extend

Removing that line fixes my slow save, the same as completely disabling php_folding.

Currently no idea how to debug this line as I am not really a vim expert.

Losing syntax

Still losing syntax highlighting on saving.

Removing the following within ~/.vim/bundle/PIV/syntax/php.vim:

" Clusters
syn cluster phpClConst contains=phpFunctions,phpClasses,phpIdentifier,phpStatement,phpOperator,phpStringSingle,phpStringDouble,phpBacktick,phpNumber,phpType,phpBoolean,phpStructure,phpMethodsVar,phpConstants,phpException,phpSuperglobals,phpMagicConstants,phpServerVars
syn cluster phpClInside contains=@phpClConst,phpComment,phpParent,phpParentError,phpInclude,phpHereDoc,phpNowDoc
syn cluster phpClFunction contains=@phpClInside,phpDefine,phpParentError,phpStorageClass,phpSpecial
syn cluster phpClTop contains=@phpClFunction,phpFoldFunction,phpFoldClass,phpFoldInterface,phpFoldTry,phpFoldCatch

" Php Region
if exists("php_parent_error_open")
  syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop
else
  syn region phpRegion matchgroup=Delimiter start="<?\(php\)\=" end="?>" contains=@phpClTop keepend
endif

Gives the same syntax on loading as when I'm done saving (very gray).

Same goes for removing the whole ~/.vim/bundle/ftplugin/php.vim. This way it's lacking colors, but not complete grayness on save.

Hope this might ring a bell!

Cheers,
Maurice

@gonzaloserrano

This comment has been minimized.

Show comment Hide comment
@gonzaloserrano

gonzaloserrano Oct 31, 2012

Same thing under OSX, vim version 7.3.672 compiled using homebrew formula and latest PIV from Vundle.

For now i just removed PIV, will try to fix it this weekend.

Same thing under OSX, vim version 7.3.672 compiled using homebrew formula and latest PIV from Vundle.

For now i just removed PIV, will try to fix it this weekend.

@mauserrifle

This comment has been minimized.

Show comment Hide comment
@mauserrifle

mauserrifle Oct 31, 2012

Glad I'm not the only one. I haven't looked into it anymore because I gave up on Vim as my primary IDE due to no intellisense autocompletion like i'm used to from Eclipse.

I hope you get the problem fixed. If I need to test things, i'll be happy to!

Glad I'm not the only one. I haven't looked into it anymore because I gave up on Vim as my primary IDE due to no intellisense autocompletion like i'm used to from Eclipse.

I hope you get the problem fixed. If I need to test things, i'll be happy to!

@Taluu

This comment has been minimized.

Show comment Hide comment
@Taluu

Taluu Feb 27, 2013

Hi,

I think I have kind of the same problem. Not while I'm saving though, but when I'm navigating in any php file : everything becomes gray, and only things like '>' are marked in red... I have to scroll up for a while,n then stop to re-enable the correct syntax highlight.

Taluu commented Feb 27, 2013

Hi,

I think I have kind of the same problem. Not while I'm saving though, but when I'm navigating in any php file : everything becomes gray, and only things like '>' are marked in red... I have to scroll up for a while,n then stop to re-enable the correct syntax highlight.

@mauserrifle

This comment has been minimized.

Show comment Hide comment
@mauserrifle

mauserrifle Feb 27, 2013

Ye it happens on different moments. For me it was mainly saving. Haven't touched vim anymore :( I was 'trying' vim when I found out. Surprised the bug is still there. Hope someone finds it. I have no idea where to search (except my finding above this post)

Ye it happens on different moments. For me it was mainly saving. Haven't touched vim anymore :( I was 'trying' vim when I found out. Surprised the bug is still there. Hope someone finds it. I have no idea where to search (except my finding above this post)

@karolsojko

This comment has been minimized.

Show comment Hide comment
@karolsojko

karolsojko May 8, 2013

I'm having the same issue. With editing PHP files. Only :syn on helps

I'm having the same issue. With editing PHP files. Only :syn on helps

@jaywilliams

This comment has been minimized.

Show comment Hide comment
@jaywilliams

jaywilliams May 8, 2013

For those of you still having issues, you can try using something lighter than PIV. I personally switched to this one myself: https://github.com/StanAngeloff/php.vim

For those looking for a really lightweight alternative, see: https://github.com/mageekguy/php.vim

Of course, neither of these options support as much as PIV, but that's part of the reason why they're faster.

For those of you still having issues, you can try using something lighter than PIV. I personally switched to this one myself: https://github.com/StanAngeloff/php.vim

For those looking for a really lightweight alternative, see: https://github.com/mageekguy/php.vim

Of course, neither of these options support as much as PIV, but that's part of the reason why they're faster.

@brain90

This comment has been minimized.

Show comment Hide comment
@brain90

brain90 Mar 19, 2014

Bump! Also meet same issues here.

Environment:
* Ubuntu 10.10,  
* Vim 7.4 (2013 Aug 10, compiled Oct 17 2013 16:16:48) 

Reproduce:
* Do curl http://j.mp/spf13-vim3 -L -o - | sh
* Wait until spf13 successfuly installed.
* Ctrl + P, Open a  pure php class with more than 100 lines 
* Every function within class are folded by default. 
(Color themes shown correctly). 
* Navigate up and down, then editor goes in gray mode.

brain90 commented Mar 19, 2014

Bump! Also meet same issues here.

Environment:
* Ubuntu 10.10,  
* Vim 7.4 (2013 Aug 10, compiled Oct 17 2013 16:16:48) 

Reproduce:
* Do curl http://j.mp/spf13-vim3 -L -o - | sh
* Wait until spf13 successfuly installed.
* Ctrl + P, Open a  pure php class with more than 100 lines 
* Every function within class are folded by default. 
(Color themes shown correctly). 
* Navigate up and down, then editor goes in gray mode.
@lian4187

This comment has been minimized.

Show comment Hide comment
@lian4187

lian4187 Mar 29, 2015

remove

58 call s:InitVariable("g:load_doxygen_syntax", 1)
59 call s:InitVariable("g:syntax_extra_php", 'doxygen')
60 call s:InitVariable("g:syntax_extra_inc", 'doxygen')

in ~/.spf13-vim-3/.vim/bundle/PIV/ftplugin/php.vim

remove

58 call s:InitVariable("g:load_doxygen_syntax", 1)
59 call s:InitVariable("g:syntax_extra_php", 'doxygen')
60 call s:InitVariable("g:syntax_extra_inc", 'doxygen')

in ~/.spf13-vim-3/.vim/bundle/PIV/ftplugin/php.vim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment