spf13 / PIV

PHP Integration environment for Vim
250 stars 36 forks source link

Losing syntax on save #15

Open mauserrifle opened 11 years ago

mauserrifle commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 (https://github.com/spf13/PIV/issues/15#issuecomment-8701734).

mauserrifle commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

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

jaywilliams commented 11 years ago

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 commented 10 years ago

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 commented 9 years ago

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