Skip to content

Commit

Permalink
Import from git://github.com/nono/merb.vim.git
Browse files Browse the repository at this point in the history
  • Loading branch information
nono committed May 4, 2011
0 parents commit ad90788
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2011 Bruno Michel

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Vim syntax for jQuery
=====================

About
-----

jQuery is a fast and concise JavaScript Library that simplifies HTML document
traversing, event handling, animating, and Ajax interactions for rapid web
development. jQuery is designed to change the way that you write JavaScript.
See http://jquery.com/ for more details.

The syntax file for Vim add some colorations for jQuery keywords (empty clone
hasClass hide show animate ...) and for CSS selectors (:empty :hidden :selected
:first ...).


Install
-------

Copy the `syntax/jquery.vim` file to `$HOME/.vim/syntax/`
and add the following line to your vimrc:

au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery


Credits
-------

Copyright (c) 2011 Bruno Michel <bmichel@menfin.info>, released under the MIT license
114 changes: 114 additions & 0 deletions syntax/jquery.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
" Vim syntax file
" Language: jQuery
" Maintainer: Bruno Michel <brmichel@free.fr>
" Last Change: Feb 2nd, 2010
" Version: 0.4
" URL: http://jquery.com/

if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif

if !exists("main_syntax")
let main_syntax = 'javascript'
endif

ru! syntax/javascript.vim
unlet b:current_syntax

syn match jQuery /jQuery\|\$/


syn match jFunc /\.\w\+(\@=/ contains=@jFunctions

syn cluster jFunctions contains=jCore,jAttributes,jTraversing,jManipulation,jCSS,jEvents,jAjax,jUtilities,jEffects
syn keyword jCore contained each size length selector context eq get index toArray
syn keyword jCore contained data removeData clearQueue queue dequeue
syn keyword jCore contained extend noConflict
syn keyword jAttributes contained attr removeAttr addClass removeClass toggleClass html text val
syn keyword jTraversing contained eq filter has is map not slice
syn keyword jTraversing contained add children closest contents find next nextAll nextUntil parent parents parentsUntil prev prevAll prevUntil siblings
syn keyword jTraversing contained andSelf end
syn keyword jManipulation contained append appendTo preprend prependTo
syn keyword jManipulation contained after before insertAfter insertBefore
syn keyword jManipulation contained unwrap wrap wrapAll wrapInner
syn keyword jManipulation contained replaceWith replaceAll
syn keyword jManipulation contained detach empty remove
syn keyword jManipulation contained clone
syn keyword jCSS contained css
syn keyword jCSS contained offset offsetParent position scrollTop scrollLeft
syn keyword jCSS contained height width innerHeight innerWidth outerHeight outerWidth
syn keyword jEvents contained ready
syn keyword jEvents contained bind one trigger triggerHandler unbind
syn keyword jEvents contained live die
syn keyword jEvents contained hover toggle
syn keyword jEvents contained blur change click dblclick error focus focusin focusout keydown keypress keyup load
syn keyword jEvents contained mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup resize scroll select submit unload
syn keyword jEffects contained show hide toggle
syn keyword jEffects contained slideDown slideUp slideToggle
syn keyword jEffects contained fadeIn fadeOut fadeTo
syn keyword jEffects contained animate stop delay
syn keyword jAjax contained ajax load get getJSON getScript post
syn keyword jAjax contained ajaxComplete ajaxError ajaxSend ajaxStart ajaxStop ajaxSuccess
syn keyword jAjax contained ajaxSetup serialize serializeArray
syn keyword jUtilities contained support browser boxModel
syn keyword jUtilities contained extend grep makeArray map inArray merge noop proxy unique
syn keyword jUtilities contained isArray isEmptyObject isFunction isPlainObject
syn keyword jUtilities contained trim param


syn region javaScriptStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=javaScriptSpecial,@htmlPreproc,@jSelectors
syn region javaScriptStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=javaScriptSpecial,@htmlPreproc,@jSelectors

syn cluster jSelectors contains=jId,jClass,jOperators,jBasicFilters,jContentFilters,jVisibility,jChildFilters,jForms,jFormFilters
syn match jId contained /#[0-9A-Za-z_\-]\+/
syn match jClass contained /\.[0-9A-Za-z_\-]\+/
syn match jOperators contained /*\|>\|>|\~/
syn match jBasicFilters contained /:\(first\|last\|not\|even\|odd\|eq\|gt\|lt\|header\|animated\)/
syn match jContentFilters contained /:\(contains\|empty\|has\|parent\)/
syn match jVisibility contained /:\(hidden\|visible\)/
syn match jChildFilters contained /:\(nth\|first\|last\|only\)-child/
syn match jForms contained /:\(input\|text\|password\|radio\|checkbox\|submit\|image\|reset\|button\|file\)/
syn match jFormFilters contained /:\(enabled\|disabled\|checked\|selected\)/


" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_lisp_syntax_inits")
if version < 508
let did_lisp_syntax_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif

HiLink jQuery Constant

HiLink jCore Identifier
HiLink jAttributes Identifier
HiLink jTraversing Identifier
HiLink jManipulation Identifier
HiLink jCSS Identifier
HiLink jEvents Identifier
HiLink jEffects Identifier
HiLink jAjax Identifier
HiLink jUtilities Identifier

HiLink jId Identifier
HiLink jClass Constant
HiLink jOperators Special
HiLink jBasicFilters Statement
HiLink jContentFilters Statement
HiLink jVisibility Statement
HiLink jChildFilters Statement
HiLink jForms Statement
HiLink jFormFilters Statement

delcommand HiLink
endif


let b:current_syntax = 'jquery'

0 comments on commit ad90788

Please sign in to comment.