Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial commit

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

0 comments on commit 709b3f7

Please sign in to comment.
Something went wrong with that request. Please try again.