Friday, February 10, 2012

Re: javascript.vim syntax file



El dimecres 8 de febrer de 2012 11:44:45 UTC+1, Fernando Basso va escriure:
I found this javascript sytax file for vim:

https://github.com/dexteryy/yy-vimscript/blob/master/syntax/javascript.vim

Looking at the file it seems that it should highlight 'words' like
"getElementById", "slice" or "childNodes", but it doesn't.

"getElementById" and "childNodes" are not part of the javascript language, that's why they are not highlighted.
These are methods of native objects of the host environment in which javascript runs, which is usually a web browser but it needs not.

The javascript specs (more properly the ECMAScript specification) distinguishes among native, built-in and host objects.  The DOM Objects (for example the window object) in a browser environment is an example of host object; they don't belong to the language itself. Consequently they and their methods are not highlighted by a pure javascript syntax file.

Regarding 'slice', there is a javascript method of the native Array object called slice. I'd expect it to be highlighted. It is however possible for host objects to have methods also called this way, or that the javascript syntax file cannot decide whether a particular variable represents a native, a user-defined or a host object and for this reason the word is not highlighted.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: