javascript.vim syntax file

31 views
Skip to first unread message

Fernando Basso

unread,
Feb 8, 2012, 5:44:45 AM2/8/12
to vim_use
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.

I'm I misunderstanding it?

Anyway, perhaps someone uses another javascript syntax file and would
like to share?


Thanks in advance.

Fernando Basso

unread,
Feb 8, 2012, 11:28:19 AM2/8/12
to vim_use

esquifit

unread,
Feb 10, 2012, 3:36:55 AM2/10/12
to vim...@googlegroups.com


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.

Fernando Basso

unread,
Feb 11, 2012, 4:08:57 AM2/11/12
to vim_use


On Feb 10, 6:36 am, esquifit <esqui...@googlemail.com> wrote:

> "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.

Okay. Useful info. I'm getting started with javascript and didn't know
that. Thanks.
Reply all
Reply to author
Forward
0 new messages