Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit 709b3f79b15a0b0e81c4a81044df8767b44341a8 @wavded committed Mar 15, 2011
Showing with 143 additions and 0 deletions.
  1. +3 −0 ftdetect/stylus.vim
  2. +53 −0 ftplugin/stylus.vim
  3. +38 −0 indent/stylus.vim
  4. +47 −0 syntax/stylus.vim
  5. +2 −0 test.styl
@@ -0,0 +1,3 @@
+" Stylus
+autocmd BufNewFile,BufReadPost *.styl set filetype=stylus
+autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus
@@ -0,0 +1,53 @@
+" Vim filetype plugin
+" Language: Stylus
+" Maintainer: Marc Harter
+" Credits: Tim Pope
+
+" Only do this when not done yet for this buffer
+if exists("b:did_ftplugin")
+ finish
+endif
+
+let s:save_cpo = &cpo
+set cpo-=C
+
+" Define some defaults in case the included ftplugins don't set them.
+let s:undo_ftplugin = ""
+let s:browsefilter = "All Files (*.*)\t*.*\n"
+let s:match_words = ""
+
+runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
+unlet! b:did_ftplugin
+
+" Override our defaults if these were set by an included ftplugin.
+if exists("b:undo_ftplugin")
+ let s:undo_ftplugin = b:undo_ftplugin
+ unlet b:undo_ftplugin
+endif
+if exists("b:browsefilter")
+ let s:browsefilter = b:browsefilter
+ unlet b:browsefilter
+endif
+if exists("b:match_words")
+ let s:match_words = b:match_words
+ unlet b:match_words
+endif
+
+" Change the browse dialog on Win32 to show mainly Styl-related files
+if has("gui_win32")
+ let b:browsefilter="Stylus Files (*.styl)\t*.styl\n" . s:browsefilter
+endif
+
+" Load the combined list of match_words for matchit.vim
+if exists("loaded_matchit")
+ let b:match_words = s:match_words
+endif
+
+setlocal comments= commentstring=//\ %s
+
+let b:undo_ftplugin = "setl cms< com< "
+ \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin
+
+let &cpo = s:save_cpo
+
+" vim:set sw=2:
@@ -0,0 +1,38 @@
+" Vim indent file
+" Language: Stylus
+" Maintainer: Marc Harter
+" Based On: Tim Pope (sass.vim)
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal autoindent sw=2 et
+setlocal indentexpr=GetStylusIndent()
+setlocal indentkeys=o,O,*<Return>,<:>,!^F
+
+" Only define the function once.
+if exists("*GetStylusIndent")
+ finish
+endif
+
+function! GetStylusIndent()
+ let lnum = prevnonblank(v:lnum-1)
+ let line = substitute(getline(lnum),'\s\+$','','')
+ let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
+ let lastcol = strlen(line)
+ let line = substitute(line,'^\s\+','','')
+ let indent = indent(lnum)
+ let cindent = indent(v:lnum)
+
+ if line =~ '^\s*'
+ return increase
+ elseif group =~? '\v^%(stylusId|stylusClass)$'
+ return increase
+ else
+ return indent
+ endif
+endfunction
+
+" vim:set sw=2:
@@ -0,0 +1,47 @@
+" Vim syntax file
+" Language: Stylus
+" Maintainer: Marc Harter
+" Filenames: *.styl,*.stylus
+
+if exists("b:current_syntax")
+ finish
+endif
+
+if !exists("main_syntax")
+ let main_syntax = 'stylus'
+endif
+
+runtime! syntax/css.vim
+unlet! b:current_syntax
+
+syn match stylusKeyword "@([-\w]+)"
+syn match stylusId "(#)[a-zA-Z][a-zA-Z0-9_-]*"
+syn match stylusClass "(\.)[a-zA-Z0-9_-]+"
+syn match stylusPsuedoElement "(:+)\b(after|before|first-child|first-letter|first-line|selection)\b"
+syn match stylusPsuedoClass "(:)\b(active|hover|link|visited|focus)\b"
+syn match stylusControl "\b(!important|for|in|return|true|false|null|if|else|unless|return)\b"
+syn match stylusNumeric "(?:\b(\d+))|(#[a-fA-F0-9]+)"
+syn region stylusDoubleString start="\"" end="\""
+syn region stylusSingleString start="'" end="'"
+syn region stylusMultiLineComment start="/\*" end="\*/"
+syn match stylusSingleLineComment "(?:^[ \t]+)?(\/\/).*$\n?"
+syn match stylusFunction "([-a-zA-Z_][-\w]*)?(\()"
+
+hi def link stylusKeyword Type
+hi def link stylusId Statement
+hi def link stylusClass Identifier
+hi def link stylusPsuedoElement PreProc
+hi def link stylusPsuedoClass Special
+hi def link stylusControl PreProc
+hi def link stylusNumeric Number
+hi def link stylusDoubleString String
+hi def link stylusSingleString String
+hi def link stylusMultiLineComment Comment
+hi def link stylusSingleLineComment Comment
+hi def link stylusFunction Function
+
+let b:current_syntax = "stylus"
+
+if main_syntax == "stylus"
+ unlet main_syntax
+endif
@@ -0,0 +1,2 @@
+#hello, #world, .wassup
+

0 comments on commit 709b3f7

Please sign in to comment.