othree / yajs.vim

YAJS.vim: Yet Another JavaScript Syntax for Vim
http://www.vim.org/scripts/script.php?script_id=4974
Vim License
688 stars 41 forks source link

Losing syntax highlighting when switching between files in buffer #10

Closed ixtli closed 9 years ago

ixtli commented 9 years ago

A simple example of a js file with ES6 syntax, as follows:

import Ember from 'ember';

export default Ember.Select.extend({
});

This highlights fine normally, but if i switch between this and another file, then switch back again (say using NERDTree, Command-T, etc) it marks import and export as javascriptReserved->Error, as reported by SyntaxAttr.

I realize this is difficult to debug, but let me know if there's any other relevant information I can provide. I also realize that it could be a configuration issue so my current vimrc is as follows: https://gist.github.com/ixtli/a11c1b10d9565905a4ed

othree commented 9 years ago

I use NERDTree and can't reproduce. Will try your vimrc later.

ixtli commented 9 years ago

thanks :)

myme commented 9 years ago

I'm getting the same error. Syntax highlighting is broken when the filetype in the buffer change from javascript to something else, then back to javascript again.

Looking at syntax/javascript.vim I see that you're short-circuiting if either b:yajs_loaded or b:current_syntax are set. These variables survive a buffer filetype mode change, so the rest of the script isn't run when switching back to javascript.

othree commented 9 years ago

Thanks, this information help a lot 2015年1月27日 上午6:38 於 "Martin Øinæs Myrseth" notifications@github.com 寫道:

I'm getting the same error. Syntax highlighting is broken when the filetype in the buffer change from javascript to something else, then back to javascript again.

Looking at syntax/javascript.vim I see that you're short-circuiting if either b:yajs_loaded or b:current_syntax are set. These variables survive a buffer filetype mode change, so the rest of the script isn't run when switching back to javascript.

— Reply to this email directly or view it on GitHub https://github.com/othree/yajs.vim/issues/10#issuecomment-71553665.

othree commented 9 years ago

The latest reversion remove the yajs_loaded part. Please try again.