spf13-vim icon indicating copy to clipboard operation
spf13-vim copied to clipboard

php "lost" syntax highlighting

Open cassiel74 opened this issue 12 years ago • 14 comments

I work on several php projects and it happens quite often that code turns grey at a point, indentation for all subsequent edits breaks up and so does complention.

Php files are drupal modules so I've added autocmd BufRead,BufNewFile *.module set filetype=php" to my vimrc.local but problem is still there.

cassiel74 avatar Nov 11 '14 07:11 cassiel74

I have this problem every once in a while as well. Although I don't have a fix for the root of the problem running the colon command syn sync fromstart usually fixes the issue for me after the fact.

bronzehedwick avatar Nov 11 '14 12:11 bronzehedwick

Well, I fix that by going backward to the top of file using PgUp and usually it fixes after some hits.

EDIT syn sync fromstart is formally better and easily to map beside EnablePHPFolds ;-) thank you for pointing this out

cassiel74 avatar Nov 11 '14 14:11 cassiel74

I find this happens from time to time when you overwrite a swap file. It's easily fixed on the file in question with something like this:

:set syntax=PHP

seyDoggy avatar Nov 19 '14 12:11 seyDoggy

do any of you follks still have the csapprox plugin installed? i haven't seen this issue since i removed it, but that could just be coincidence.

ghost avatar Nov 19 '14 12:11 ghost

On 19/11/14 at 04:10am, Adam Merrifield wrote:

I find this happens from time to time when you overwrite a swap file. It's easily fixed on the file in question with something like this:

:set syntax=PHP

not a permanent solution nor a good one, it happens really often (on big files at least)

it's better to add this line to your .vimrc.local

map :syn sync fromstart

cassiel74 avatar Nov 19 '14 12:11 cassiel74

On 19/11/14 at 04:18am, Johnny Robeson wrote:

do any of you follks still have the csapprox plugin installed? i haven't seen this issue since i removed it, but that could just be coincidence.

nope, it's not in the bundle

cassiel74 avatar Nov 19 '14 12:11 cassiel74

I get this too, mostly on big files. I'm working in Ruby/Puppet so it isn't specific to any one language. Thanks for the key mapping tip, @cassiel74 .

tthayer avatar Nov 25 '14 18:11 tthayer

I have the same problem with php files. It usually happens on big files with folds.

novalore avatar Nov 26 '14 09:11 novalore

I have same issues here, with php file and folds. When I expand a fold in the beginning of the file it has colors, if I continue expanding folders in sequences, colors works, but If I skip one fold and expand the next, no colors around. Will turn off auto auto folding for now.

For the record, it just happens if file's extension is not .php, in my case, .inc

rbgarga avatar Nov 26 '14 17:11 rbgarga

Just sharing. I've had the same problem with a PHP file. It seems to be a problem with folding. The "syn sync" command didn't solved it. When I unfold all blocks The highlight works and, after that, it still working even if I close the file and reopen it. Don't know why.

diraol avatar May 02 '15 22:05 diraol

I probably stays working because of the .view built for that file in .vimviews. Try deleting it. It should go back to a broken state again.

ghost avatar May 02 '15 23:05 ghost

Same problem here: Large PHP files with lots of folds. Some content within folds have syntax highlighting while others do not. Executing :syn sync fromstart works to remedy the problem.

Still looking for a way to prevent this automatically ...

bmeynell avatar Mar 17 '16 20:03 bmeynell

Same problem, usually in connection with deleted swap files as @seyDoggy . :syn sync fromstart didn't fix the issue for me, setting the filetype explicitly with :set syntax=tex helped.

jf87 avatar May 09 '16 08:05 jf87

Thanks @jrobeson! The issue for me was .vimviews. Somehow I removed the folds from my PHP files and all the text was gray. Deleting the views via sudo rm -R ~/.vimviews/* did the trick!

jimafisk avatar May 09 '16 20:05 jimafisk