-
Notifications
You must be signed in to change notification settings - Fork 352
Remove $ from iskeyword in PHP files #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm confused, which file is this? |
I think what he means is that when a PHP file loads this JS, to not have $ be iskeyword? This might or might not be possible, we'd have to look at the standard PHP file |
I think you should replace this line: https://github.com/pangloss/vim-javascript/blob/master/syntax/javascript.vim#L26 With this
So that it only sets it on javascript files... |
Yes please fix, this is very annoying for PHP users that use this plugin :( |
as a temp fix you can do the following: https://github.com/zeroasterisk/home/blob/master/.vimrc#L375
|
So, this only represents my opinion on the matter (that of a single maintainer), not necessarily representative of all the other maintainer on this project. If we look at the problem as it exists, it's a differing implementation between PHP and Javascript. This is a FileType plugin dedicated to Javascript. Javascript knows nothing about PHP, in fact it's the other way around. PHP is the superset that incorporates Javascript into its templates. Furthermore, jQuery is a very popular library that depends heavily on the So, the TL;DR from my perspective is I vote for a won't fix, other than perhaps a note in the README for PHP developers who use this plugin. Just a note for you guys on your autocmd fix. The way you have it now, every time you source your vimrc, (or if this was added to a syntax file, every time you source that syntax file) it's going to add ANOTHER autocmd. What you should do is something more akin to this:
This will ensure that every time you source your vimrc or a respective syntax file with that snippet included, it will first clear those autocmds before adding them. |
I find this argument compelling. It's up to the PHP highlighter to behave appropriately in the various contexts which can exist in a .php file (PHP, HTML, CSS, and JavaScript). |
Hold on - i fully agree that "It's up to the PHP highlighter to behave appropriately" That makes a whole lot of sense. But what I take issue with is that this plugin is making a globally scoped change in vim that is unexpected... namely adding You're argument could very easily be modified to "It's up to the javascript plugin to only affect javascript file when setting defaults" PHP is just one example where changing the behaviour of oh, and @amadeus thanks for the autocmd help! |
The problem is that Vim does not provide very good support for having nested syntaxes. In JavaScript, $ is a keyword character. The only way to reflect this in Vim -- the only way for JavaScript syntax to behave appropriately -- is to add $ to iskeyword. It's not feasible for JavaScript syntax to support every other syntax in the world that might want to embed it; it's the responsibility of other syntaxes embedding JavaScript to make sure they behave as their users expect. Our syntax plugin behaves the way our users expect. |
Well I guess we agree to disagree. If vim does default $ to a keyword and I install a JavaScript plugin, I I'll stop beating this dead horse, as I have a viable workaround. But I Thanks, |
I'm with 0*, IMHO i don't get why making $ to be part of the iskeyword option in ANY file (JS or not JS) is not considered a bug. |
It doesn't; it treats $ differently whenever you tell vim that the syntax is JavaScript, as your PHP syntax likely does. It's the fault of the PHP syntax for not setting iskeyword explicitly after loading other syntax files that might interfere. Even then, your javascript syntax is going to behave incorrectly, because $ will not be treated like a keyword where it should. It's just a question of which way you want it to be wrong. What is more reasonable, to expect us to account for a potentially infinite number of other syntax plugins that want to embed JavaScript, or for other syntax plugins to pay attention to the scripts they embed?
In JavaScript syntax, $ is a keyword character. Thus, when you tell vim to load JavaScript syntax, $ should be treated like a keyword, unless the situation is exceptional -- for example, if the JavaScript is merely embedded in another language for which $ is not a keyword character. In this case, the other language plugin has decided to include this plugin; we have not decided to be included. The onus is on them to ensure that their shortcut doesn't screw up behaviour. |
Related: #196 |
There seems to be a parallel discussion also going on regarding the validity of setting iskeyword. For the record, we don't Furthermore, I did a quick grep throughout the default vim runtime syntax files, and there are around 120 instances of In summary, I believe the way we are doing it now is the standard way the community does it. It's not the job of this plugin to fix another syntax file which embeds our own. And onus should be on the PHP maintainer to provide a fix for other languages that they may be embedding. I, (and I assume we) would be happy to accept a pull request that puts a note in the README regarding this issue, assuming the aforementioned fix works (I haven't done anything with PHP in years, so I've never come across this issue.) |
I would like to extend the suggestion for a fix to the authors of the syntax plugins in question; those of you experiencing bad behaviour, inform the maintainers of the root-level syntax plugin (probably php) sourcing JavaScript that they need to I'd be happy to make issues / pull requests against the other syntax plugins if somebody would like to point me at their repositories. |
A cursory glance at the comments in my |
Hi, Sorry for the delay, forgot this till i re-installed everything and got the same problem again :P I'm using spf13 vim distributuion but instead of the default PHP stuff from https://github.com/spf13/PIV i'm using https://github.com/StanAngeloff/php.vim. I'm not an expert but as you say i think it embeds HTML & JS stuff so the JS syntax file will be loaded and the isk+=$ will be executed, so meh for me. Maybe @StanAngeloff has more hints about this stuff? |
@sp-gonzalo-serrano late to the party, see the referenced commit in the php.vim repository. The |
Awesome, thanks a lot guys! |
sweet - thanks! |
Since it looks like everything is good, closing. |
No description provided.
The text was updated successfully, but these errors were encountered: