Skip to content

Commit

Permalink
merge sjs syntax support for vim
Browse files Browse the repository at this point in the history
  • Loading branch information
timbertson committed Apr 20, 2014
1 parent aaf6c65 commit b510200
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -67,6 +67,11 @@ emacs/

- StratifiedJS syntax highlighting support for emacs (GPL).

vim/
--------

- StratifiedJS syntax highlighting support for vim (Vim licence, GPL compatible).


How to build
------------
Expand Down
11 changes: 11 additions & 0 deletions vim/README.md
@@ -0,0 +1,11 @@
# Vim syntax support for [stratified javascript][sjs]

Based on the builtin Javascript

To use with [pathogen][], copy the `stratifiedjs` folder into
`~/.vim/bundle`. If you don't use [pathogen][] (or something
similar), now's a good time to start - but you can always
install manually if you're stubborn.

[pathogen]: https://github.com/tpope/vim-pathogen
[sjs]: http://onilabs.com/stratifiedjs
1 change: 1 addition & 0 deletions vim/VERSION
@@ -0,0 +1 @@
0.1.9
5 changes: 5 additions & 0 deletions vim/stratifiedjs/ftdetect/sjs.vim
@@ -0,0 +1,5 @@
autocmd BufNewFile,BufRead *.sjs set filetype=sjs
autocmd BufNewFile,BufRead *.app set filetype=sjs
autocmd BufNewFile,BufRead *.api set filetype=sjs
autocmd BufNewFile,BufRead *.gen set filetype=sjs
autocmd BufNewFile,BufRead *.mho set filetype=sjs
28 changes: 28 additions & 0 deletions vim/stratifiedjs/ftplugin/sjs.vim
@@ -0,0 +1,28 @@
" Vim filetype plugin file

if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1

let s:cpo_save = &cpo
set cpo-=C

" Set 'formatoptions' to break comment lines but not other lines,
" " and insert the comment leader when hitting <CR> or using "o".
setlocal formatoptions-=t formatoptions+=croql

" Set completion with CTRL-X CTRL-O to autoloaded function.
if exists('&ofu')
setlocal omnifunc=javascriptcomplete#CompleteJS
endif

" Set 'comments' to format dashed lists in comments.
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://

setlocal commentstring=//%s

let b:undo_ftplugin = "setl fo< ofu< com< cms<"

let &cpo = s:cpo_save
unlet s:cpo_save
130 changes: 130 additions & 0 deletions vim/stratifiedjs/syntax/sjs.vim
@@ -0,0 +1,130 @@
" Vim syntax file
" Language: StratifiedJS
" Maintainer: Tim Cuthbertson <tim@onilabs.com>
" URL: https://github.com/onilabs/stratifiedjs/tree/master/vim/
"
" forked from javascript.vim in vim 7.3.

" tuning parameters:
" unlet sjs_fold

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

" Drop fold if it set but vim doesn't support it.
if version < 600 && exists("sjs_fold")
unlet sjs_fold
endif

syn keyword sjsCommentTodo TODO FIXME XXX TBD contained
syn match sjsLineComment "\/\/.*" contains=@Spell,sjsCommentTodo
syn match sjsCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
syn region sjsComment start="/\*" end="\*/" contains=@Spell,sjsCommentTodo
syn match sjsSpecial "\\\d\d\d\|\\."
syn region sjsStringD start=+"+ skip=+\\\\\|\\"+ end=+"\|$+ contains=sjsSpecial,@htmlPreproc
syn region sjsStringS start=+'+ skip=+\\\\\|\\'+ end=+'\|$+ contains=sjsSpecial,@htmlPreproc

syn match sjsSpecialCharacter "'\\.'"
syn match sjsNumber "-\=\<\d\+L\=\>\|0[xX][0-9a-fA-F]\+\>"
syn region sjsRegexpString start=+/[^/*]+me=e-1 skip=+\\\\\|\\/+ end=+/[gim]\{0,3\}\s*$+ end=+/[gim]\{0,3\}\s*[;.,)\]}]+me=e-1 contains=@htmlPreproc oneline

syn keyword sjsConditional if else switch
syn keyword sjsRepeat while for do in
syn keyword sjsBranch break continue
syn keyword sjsOperator new delete instanceof typeof
syn keyword sjsType Array Boolean Date Function Number Object String RegExp
syn keyword sjsStatement return with using
syn keyword sjsBoolean true false
syn keyword sjsNull null undefined
syn keyword sjsIdentifier arguments this var let
syn match sjsAltnsIdentifier "@[a-zA-Z_0-9]*"
syn keyword sjsLabel case default
syn keyword sjsException try catch finally throw
syn keyword sjsMessage alert confirm prompt status
syn keyword sjsGlobal window
syn keyword sjsReserved abstract boolean byte char class const debugger double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile

syn region sjsParenBlock matchgroup=sjsBraces start="(" end=")" contains=TOP
syn region sjsBlock matchgroup=sjsBraces start="{" end="}" contains=TOP
syn region sjsBlock matchgroup=sjsBraces start="\[" end="\]" contains=TOP
syn keyword sjsException and or retract
syn keyword sjsGlobal waitfor spawn require hold
syn keyword sjsStatement using
syn region sjsStringD start=+"+ skip=+\\\\\|\\"\\#+ end=+"+ contains=sjsSpecial,@htmlPreproc
syn region sjsStringB start=+`+ skip=+\\\\\|\\`\\$+ end=+`+ contains=sjsSpecial,@htmlPreproc,sjsInterpolationDelimiter
syn region sjsStringS start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=sjsSpecial,@htmlPreproc
syn region sjsInterpolation matchgroup=sjsInterpolationDelimiter start="#{" end="}" contained contains=TOP containedIn=sjsStringD
syn region sjsInterpolation matchgroup=sjsInterpolationDelimiter start="${" end="}" contained contains=TOP containedIn=sjsStringB
syn match sjsInterpolationDelimiter contained nextgroup=sjsNakedQuasiValue "\$\ze[^{]"
syn region sjsNakedQuasiValue start="[a-zA-Z0-9_]" end="[a-zA-Z0-9_]*" contained nextgroup=sjsParenBlock
syn region sjsNakedQuasiValue matchgroup=sjsAltnsIdentifier start="@" end="[a-zA-Z0-9_]*" contained nextgroup=sjsParenBlock

syn keyword sjsFunction function

"uncomment for debugging:
"map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
"\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
"\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>

syn sync fromstart
syn sync maxlines=100

if main_syntax == "sjs"
syn sync ccomment sjsComment
endif

" 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_sjs_syn_inits")
" if version < 508
" let did_sjs_syn_inits = 1
command -nargs=+ HiLink hi link <args>
" else
" command -nargs=+ HiLink hi def link <args>
" endif
HiLink sjsComment Comment
HiLink sjsLineComment Comment
HiLink sjsCommentTodo Todo
HiLink sjsSpecial Special
HiLink sjsStringS String
HiLink sjsStringD String
HiLink sjsStringB String
HiLink sjsCharacter Character
HiLink sjsSpecialCharacter sjsSpecial
HiLink sjsNumber sjsValue
HiLink sjsConditional Conditional
HiLink sjsRepeat Repeat
HiLink sjsBranch Conditional
HiLink sjsOperator Operator
HiLink sjsType Type
HiLink sjsStatement Statement
HiLink sjsFunction Function
HiLink sjsBraces Function
HiLink sjsInterpolationDelimiter sjsBraces
HiLink sjsError Error
HiLink sjsParenError sjsError
HiLink sjsNull Keyword
HiLink sjsBoolean Boolean
HiLink sjsRegexpString String

HiLink sjsIdentifier Identifier
HiLink sjsAltnsIdentifier sjsGlobal
HiLink sjsLabel Label
HiLink sjsException Exception
HiLink sjsMessage Keyword
HiLink sjsGlobal Keyword
HiLink sjsReserved Keyword
HiLink sjsDebug Debug
HiLink sjsConstant Label

delcommand HiLink
" endif

let b:current_syntax = "sjs"
if main_syntax == 'sjs'
unlet main_syntax
endif

" vim: ts=8
1 change: 1 addition & 0 deletions vim/vim-stratifiedjs.dist
@@ -0,0 +1 @@
stratifiedjs
27 changes: 27 additions & 0 deletions vim/vim-stratifiedjs.xml.template
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<?xml-stylesheet type='text/xsl' href='interface.xsl'?>
<interface xmlns="http://zero-install.sourceforge.net/2004/injector/interface" xmlns:compile="http://zero-install.sourceforge.net/2006/namespaces/0compile" xmlns:release="http://zero-install.sourceforge.net/2007/namespaces/0release">
<name>vim-stratifiedjs</name>
<summary>vim stratifiedjs syntax support</summary>
<publish xmlns="http://gfxmonk.net/dist/0install" mode="third-party"/>
<description>
# Vim syntax support for [stratified javascript][sjs]

To use with [pathogen][], copy the `stratifiedjs` folder into
`~/.vim/bundle`. If you don't use [pathogen][] (or something
similar), now's a good time to start - but you can always
install manually if you're stubborn.

[pathogen]: https://github.com/tpope/vim-pathogen
[sjs]: http://onilabs.com/stratifiedjs
</description>
<homepage>http://gfxmonk.github.com/vim-stratifiedjs/</homepage>
<feed-for interface="http://gfxmonk.net/dist/0install/vim-stratifiedjs.xml"/>
<group>
<environment insert="stratifiedjs" mode="prepend" name="VIMPATH"/>
<implementation version="{version}">
<manifest-digest/>
<archive extract="" href="{archive}"/>
</implementation>
</group>
</interface>

0 comments on commit b510200

Please sign in to comment.