diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 16:17:03 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 16:17:03 +0200 | 
| commit | 01fe1500df97577452f755b526c09d8ed0c802ea (patch) | |
| tree | 9e2e038630cc9e82abcd17da6dd3407a9b3bc62a | |
| parent | dce12af91b404835938e95de9e6d839d52487ed5 (diff) | |
| download | vim-polyglot-01fe1500df97577452f755b526c09d8ed0c802ea.tar.gz vim-polyglot-01fe1500df97577452f755b526c09d8ed0c802ea.zip | |
Add support for basic languages
coffee, cucumbeer, eruby, haml, haskell, javascript,
json, less, nginx, ocaml, ruby, sass, scss, slim,
stylus, textile, tmux
74 files changed, 9074 insertions, 1 deletions
| diff --git a/after/indent/html.vim b/after/indent/html.vim new file mode 100644 index 00000000..10ca6ce5 --- /dev/null +++ b/after/indent/html.vim @@ -0,0 +1,33 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +" Load the coffee and html indent functions. +unlet b:did_indent +runtime indent/coffee.vim +let s:coffeeIndentExpr = &l:indentexpr + +" Load html last so it can overwrite coffee settings. +unlet b:did_indent +runtime indent/html.vim +let s:htmlIndentExpr = &l:indentexpr + +" Inject our wrapper indent function. +setlocal indentexpr=GetCoffeeHtmlIndent(v:lnum) + +function! GetCoffeeHtmlIndent(curlinenum) +  " See if we're inside a coffeescript block. +  let scriptlnum = searchpair('<script [^>]*type="text/coffeescript"[^>]*>', '', +  \                           '</script>', 'bWn') +  let prevlnum = prevnonblank(a:curlinenum) + +  " If we're in the script block and the previous line isn't the script tag +  " itself, use coffee indenting. +  if scriptlnum && scriptlnum != prevlnum +    exec 'return ' s:coffeeIndentExpr +  endif + +  " Otherwise use html indenting. +  exec 'return ' s:htmlIndentExpr +endfunction diff --git a/after/syntax/coffee.vim b/after/syntax/coffee.vim new file mode 100644 index 00000000..92b83596 --- /dev/null +++ b/after/syntax/coffee.vim @@ -0,0 +1,21 @@ +" This file describes a very basic syntax for TomDoc comments in a +" CoffeeScript file. +" +" For more information on TomDoc, check it out here: http://tomdoc.org/ +" + +syn keyword tomdocKeywords Returns containedin=coffeeComment contained +syn keyword tomdocKeywords Yields containedin=coffeeComment contained +syn keyword tomdocKeywords Raises containedin=coffeeComment contained +syn keyword tomdocKeywords Examples containedin=coffeeComment contained +syn keyword tomdocKeywords Signature containedin=coffeeComment contained + +syn match tomdocArguments +\s*[A-Za-z0-9_\-&\*:]*\(\s*- \)+he=e-3 containedin=coffeeComment contained + +syn match tomdocDescriptions +\s*Public:+he=e-1 containedin=coffeeComment contained +syn match tomdocDescriptions +\s*Internal:+he=e-1 containedin=coffeeComment contained +syn match tomdocDescriptions +\s*Deprecated:+he=e-1 containedin=coffeeComment contained + +hi default link tomdocDescriptions TODO +hi default link tomdocKeywords TODO +hi default link tomdocArguments HELP diff --git a/after/syntax/haml.vim b/after/syntax/haml.vim new file mode 100644 index 00000000..4c517ebb --- /dev/null +++ b/after/syntax/haml.vim @@ -0,0 +1,13 @@ +" Language:    CoffeeScript +" Maintainer:  Sven Felix Oberquelle <Svelix.Github@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +" Inherit coffee from html so coffeeComment isn't redefined and given higher +" priority than hamlInterpolation. +syn cluster hamlCoffeescript contains=@htmlCoffeeScript +syn region  hamlCoffeescriptFilter matchgroup=hamlFilter +\                                  start="^\z(\s*\):coffee\z(script\)\?\s*$" +\                                  end="^\%(\z1 \| *$\)\@!" +\                                  contains=@hamlCoffeeScript,hamlInterpolation +\                                  keepend diff --git a/after/syntax/html.vim b/after/syntax/html.vim new file mode 100644 index 00000000..9e2eb3a1 --- /dev/null +++ b/after/syntax/html.vim @@ -0,0 +1,11 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +" Syntax highlighting for text/coffeescript script tags +syn include @htmlCoffeeScript syntax/coffee.vim +syn region coffeeScript start=#<script [^>]*type="text/coffeescript"[^>]*># +\                       end=#</script>#me=s-1 keepend +\                       contains=@htmlCoffeeScript,htmlScriptTag,@htmlPreproc +\                       containedin=htmlHead diff --git a/after/syntax/ruby.vim b/after/syntax/ruby.vim new file mode 100644 index 00000000..1d164fdf --- /dev/null +++ b/after/syntax/ruby.vim @@ -0,0 +1,20 @@ +" This file describes a very basic syntax for TomDoc comments in a Ruby file. +" +" For more information on TomDoc, check it out here: http://tomdoc.org/ +" + +syn keyword tomdocKeywords Returns containedin=rubyComment contained +syn keyword tomdocKeywords Yields containedin=rubyComment contained +syn keyword tomdocKeywords Raises containedin=rubyComment contained +syn keyword tomdocKeywords Examples containedin=rubyComment contained +syn keyword tomdocKeywords Signature containedin=rubyComment contained + +syn match tomdocArguments +\s*[A-Za-z0-9_\-&\*:]*\(\s*- \)+he=e-3 containedin=rubyComment contained + +syn match tomdocDescriptions +\s*Public:+he=e-1 containedin=rubyComment contained +syn match tomdocDescriptions +\s*Internal:+he=e-1 containedin=rubyComment contained +syn match tomdocDescriptions +\s*Deprecated:+he=e-1 containedin=rubyComment contained + +hi default link tomdocDescriptions TODO +hi default link tomdocKeywords TODO +hi default link tomdocArguments HELP diff --git a/autoload/coffee.vim b/autoload/coffee.vim new file mode 100644 index 00000000..04d5efba --- /dev/null +++ b/autoload/coffee.vim @@ -0,0 +1,54 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +" Set up some common global/buffer variables. +function! coffee#CoffeeSetUpVariables() +  " Path to coffee executable +  if !exists('g:coffee_compiler') +    let g:coffee_compiler = 'coffee' +  endif + +  " Options passed to coffee with make +  if !exists('g:coffee_make_options') +    let g:coffee_make_options = '' +  endif + +  " Path to cake executable +  if !exists('g:coffee_cake') +    let g:coffee_cake = 'cake' +  endif + +  " Extra options passed to cake +  if !exists('g:coffee_cake_options') +    let g:coffee_cake_options = '' +  endif + +  " Path to coffeelint executable +  if !exists('g:coffee_linter') +    let g:coffee_linter = 'coffeelint' +  endif + +  " Options passed to CoffeeLint +  if !exists('g:coffee_lint_options') +    let g:coffee_lint_options = '' +  endif + +  " Pass the litcoffee flag to tools in this buffer if a litcoffee file is open. +  " Let the variable be overwritten so it can be updated if a different filetype +  " is set. +  if &filetype == 'litcoffee' +    let b:coffee_litcoffee = '--literate' +  else +    let b:coffee_litcoffee = '' +  endif +endfunction + +function! coffee#CoffeeSetUpErrorFormat() +  CompilerSet errorformat=Error:\ In\ %f\\,\ %m\ on\ line\ %l, +                         \Error:\ In\ %f\\,\ Parse\ error\ on\ line\ %l:\ %m, +                         \SyntaxError:\ In\ %f\\,\ %m, +                         \%f:%l:%c:\ error:\ %m, +                         \%-G%.%# +endfunction diff --git a/autoload/rubycomplete.vim b/autoload/rubycomplete.vim new file mode 100644 index 00000000..df7ef5c9 --- /dev/null +++ b/autoload/rubycomplete.vim @@ -0,0 +1,831 @@ +" Vim completion script +" Language:             Ruby +" Maintainer:           Mark Guzman <segfault@hasno.info> +" URL:                  https://github.com/vim-ruby/vim-ruby +" Release Coordinator:  Doug Kearns <dougkearns@gmail.com> +" Maintainer Version:   0.8.1 +" ---------------------------------------------------------------------------- +" +" Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com) +" ---------------------------------------------------------------------------- + +" {{{ requirement checks + +function! s:ErrMsg(msg) +    echohl ErrorMsg +    echo a:msg +    echohl None +endfunction + +if !has('ruby') +    call s:ErrMsg( "Error: Rubycomplete requires vim compiled with +ruby" ) +    call s:ErrMsg( "Error: falling back to syntax completion" ) +    " lets fall back to syntax completion +    setlocal omnifunc=syntaxcomplete#Complete +    finish +endif + +if version < 700 +    call s:ErrMsg( "Error: Required vim >= 7.0" ) +    finish +endif +" }}} requirement checks + +" {{{ configuration failsafe initialization +if !exists("g:rubycomplete_rails") +    let g:rubycomplete_rails = 0 +endif + +if !exists("g:rubycomplete_classes_in_global") +    let g:rubycomplete_classes_in_global = 0 +endif + +if !exists("g:rubycomplete_buffer_loading") +    let g:rubycomplete_buffer_loading = 0 +endif + +if !exists("g:rubycomplete_include_object") +    let g:rubycomplete_include_object = 0 +endif + +if !exists("g:rubycomplete_include_objectspace") +    let g:rubycomplete_include_objectspace = 0 +endif +" }}} configuration failsafe initialization + +" {{{ vim-side support functions +let s:rubycomplete_debug = 0 + +function! s:dprint(msg) +    if s:rubycomplete_debug == 1 +        echom a:msg +    endif +endfunction + +function! s:GetBufferRubyModule(name, ...) +    if a:0 == 1 +        let [snum,enum] = s:GetBufferRubyEntity(a:name, "module", a:1) +    else +        let [snum,enum] = s:GetBufferRubyEntity(a:name, "module") +    endif +    return snum . '..' . enum +endfunction + +function! s:GetBufferRubyClass(name, ...) +    if a:0 >= 1 +        let [snum,enum] = s:GetBufferRubyEntity(a:name, "class", a:1) +    else +        let [snum,enum] = s:GetBufferRubyEntity(a:name, "class") +    endif +    return snum . '..' . enum +endfunction + +function! s:GetBufferRubySingletonMethods(name) +endfunction + +function! s:GetBufferRubyEntity( name, type, ... ) +    let lastpos = getpos(".") +    let lastline = lastpos +    if (a:0 >= 1) +        let lastline = [ 0, a:1, 0, 0 ] +        call cursor( a:1, 0 ) +    endif + +    let stopline = 1 + +    let crex = '^\s*\<' . a:type . '\>\s*\<' . escape(a:name, '*') . '\>\s*\(<\s*.*\s*\)\?' +    let [lnum,lcol] = searchpos( crex, 'w' ) +    "let [lnum,lcol] = searchpairpos( crex . '\zs', '', '\(end\|}\)', 'w' ) + +    if lnum == 0 && lcol == 0 +        call cursor(lastpos[1], lastpos[2]) +        return [0,0] +    endif + +    let curpos = getpos(".") +    let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'wr' ) +    call cursor(lastpos[1], lastpos[2]) + +    if lnum > enum +        return [0,0] +    endif +    " we found a the class def +    return [lnum,enum] +endfunction + +function! s:IsInClassDef() +    return s:IsPosInClassDef( line('.') ) +endfunction + +function! s:IsPosInClassDef(pos) +    let [snum,enum] = s:GetBufferRubyEntity( '.*', "class" ) +    let ret = 'nil' + +    if snum < a:pos && a:pos < enum +        let ret = snum . '..' . enum +    endif + +    return ret +endfunction + +function! s:GetRubyVarType(v) +    let stopline = 1 +    let vtp = '' +    let pos = getpos('.') +    let sstr = '^\s*#\s*@var\s*'.escape(a:v, '*').'\>\s\+[^ \t]\+\s*$' +    let [lnum,lcol] = searchpos(sstr,'nb',stopline) +    if lnum != 0 && lcol != 0 +        call setpos('.',pos) +        let str = getline(lnum) +        let vtp = substitute(str,sstr,'\1','') +        return vtp +    endif +    call setpos('.',pos) +    let ctors = '\(now\|new\|open\|get_instance' +    if exists('g:rubycomplete_rails') && g:rubycomplete_rails == 1 && s:rubycomplete_rails_loaded == 1 +        let ctors = ctors.'\|find\|create' +    else +    endif +    let ctors = ctors.'\)' + +    let fstr = '=\s*\([^ \t]\+.' . ctors .'\>\|[\[{"''/]\|%[xwQqr][(\[{@]\|[A-Za-z0-9@:\-()\.]\+...\?\|lambda\|&\)' +    let sstr = ''.escape(a:v, '*').'\>\s*[+\-*/]*'.fstr +    let [lnum,lcol] = searchpos(sstr,'nb',stopline) +    if lnum != 0 && lcol != 0 +        let str = matchstr(getline(lnum),fstr,lcol) +        let str = substitute(str,'^=\s*','','') + +        call setpos('.',pos) +        if str == '"' || str == '''' || stridx(tolower(str), '%q[') != -1 +            return 'String' +        elseif str == '[' || stridx(str, '%w[') != -1 +            return 'Array' +        elseif str == '{' +            return 'Hash' +        elseif str == '/' || str == '%r{' +            return 'Regexp' +        elseif strlen(str) >= 4 && stridx(str,'..') != -1 +            return 'Range' +        elseif stridx(str, 'lambda') != -1 || str == '&' +            return 'Proc' +        elseif strlen(str) > 4 +            let l = stridx(str,'.') +            return str[0:l-1] +        end +        return '' +    endif +    call setpos('.',pos) +    return '' +endfunction + +"}}} vim-side support functions + +"{{{ vim-side completion function +function! rubycomplete#Init() +    execute "ruby VimRubyCompletion.preload_rails" +endfunction + +function! rubycomplete#Complete(findstart, base) +     "findstart = 1 when we need to get the text length +    if a:findstart +        let line = getline('.') +        let idx = col('.') +        while idx > 0 +            let idx -= 1 +            let c = line[idx-1] +            if c =~ '\w' +                continue +            elseif ! c =~ '\.' +                idx = -1 +                break +            else +                break +            endif +        endwhile + +        return idx +    "findstart = 0 when we need to return the list of completions +    else +        let g:rubycomplete_completions = [] +        execute "ruby VimRubyCompletion.get_completions('" . a:base . "')" +        return g:rubycomplete_completions +    endif +endfunction +"}}} vim-side completion function + +"{{{ ruby-side code +function! s:DefRuby() +ruby << RUBYEOF +# {{{ ruby completion + +begin +    require 'rubygems' # let's assume this is safe...? +rescue Exception +    #ignore? +end +class VimRubyCompletion +# {{{ constants +  @@debug = false +  @@ReservedWords = [ +        "BEGIN", "END", +        "alias", "and", +        "begin", "break", +        "case", "class", +        "def", "defined", "do", +        "else", "elsif", "end", "ensure", +        "false", "for", +        "if", "in", +        "module", +        "next", "nil", "not", +        "or", +        "redo", "rescue", "retry", "return", +        "self", "super", +        "then", "true", +        "undef", "unless", "until", +        "when", "while", +        "yield", +      ] + +  @@Operators = [ "%", "&", "*", "**", "+",  "-",  "/", +        "<", "<<", "<=", "<=>", "==", "===", "=~", ">", ">=", ">>", +        "[]", "[]=", "^", ] +# }}} constants + +# {{{ buffer analysis magic +  def load_requires +    buf = VIM::Buffer.current +    enum = buf.line_number +    nums = Range.new( 1, enum ) +    nums.each do |x| +      ln = buf[x] +      begin +        eval( "require %s" % $1 ) if /.*require\s*(.*)$/.match( ln ) +      rescue Exception +        #ignore? +      end +    end +  end + +  def load_gems +    fpath = VIM::evaluate("get(g:, 'rubycomplete_gemfile_path', 'Gemfile')") +    return unless File.file?(fpath) && File.readable?(fpath) +    want_bundler = VIM::evaluate("get(g:, 'rubycomplete_use_bundler')") +    parse_file = !want_bundler +    begin +      require 'bundler' +      Bundler.setup +      Bundler.require +    rescue Exception +      parse_file = true +    end +    if parse_file +      File.new(fpath).each_line do |line| +        begin +          require $1 if /\s*gem\s*['"]([^'"]+)/.match(line) +        rescue Exception +        end +      end +    end +  end + +  def load_buffer_class(name) +    dprint "load_buffer_class(%s) START" % name +    classdef = get_buffer_entity(name, 's:GetBufferRubyClass("%s")') +    return if classdef == nil + +    pare = /^\s*class\s*(.*)\s*<\s*(.*)\s*\n/.match( classdef ) +    load_buffer_class( $2 ) if pare != nil  && $2 != name # load parent class if needed + +    mixre = /.*\n\s*(include|prepend)\s*(.*)\s*\n/.match( classdef ) +    load_buffer_module( $2 ) if mixre != nil && $2 != name # load mixins if needed + +    begin +      eval classdef +    rescue Exception +      VIM::evaluate( "s:ErrMsg( 'Problem loading class \"%s\", was it already completed?' )" % name ) +    end +    dprint "load_buffer_class(%s) END" % name +  end + +  def load_buffer_module(name) +    dprint "load_buffer_module(%s) START" % name +    classdef = get_buffer_entity(name, 's:GetBufferRubyModule("%s")') +    return if classdef == nil + +    begin +      eval classdef +    rescue Exception +      VIM::evaluate( "s:ErrMsg( 'Problem loading module \"%s\", was it already completed?' )" % name ) +    end +    dprint "load_buffer_module(%s) END" % name +  end + +  def get_buffer_entity(name, vimfun) +    loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") +    return nil if loading_allowed.to_i.zero? +    return nil if /(\"|\')+/.match( name ) +    buf = VIM::Buffer.current +    nums = eval( VIM::evaluate( vimfun % name ) ) +    return nil if nums == nil +    return nil if nums.min == nums.max && nums.min == 0 + +    dprint "get_buffer_entity START" +    visited = [] +    clscnt = 0 +    bufname = VIM::Buffer.current.name +    classdef = "" +    cur_line = VIM::Buffer.current.line_number +    while (nums != nil && !(nums.min == 0 && nums.max == 0) ) +      dprint "visited: %s" % visited.to_s +      break if visited.index( nums ) +      visited << nums + +      nums.each do |x| +        if x != cur_line +          next if x == 0 +          ln = buf[x] +          if /^\s*(module|class|def|include)\s+/.match(ln) +            clscnt += 1 if $1 == "class" +            #dprint "\$1$1 +            classdef += "%s\n" % ln +            classdef += "end\n" if /def\s+/.match(ln) +            dprint ln +          end +        end +      end + +      nm = "%s(::.*)*\", %s, \"" % [ name, nums.last ] +      nums = eval( VIM::evaluate( vimfun % nm ) ) +      dprint "nm: \"%s\"" % nm +      dprint "vimfun: %s" % (vimfun % nm) +      dprint "got nums: %s" % nums.to_s +    end +    if classdef.length > 1 +        classdef += "end\n"*clscnt +        # classdef = "class %s\n%s\nend\n" % [ bufname.gsub( /\/|\\/, "_" ), classdef ] +    end + +    dprint "get_buffer_entity END" +    dprint "classdef====start" +    lns = classdef.split( "\n" ) +    lns.each { |x| dprint x } +    dprint "classdef====end" +    return classdef +  end + +  def get_var_type( receiver ) +    if /(\"|\')+/.match( receiver ) +      "String" +    else +      VIM::evaluate("s:GetRubyVarType('%s')" % receiver) +    end +  end + +  def dprint( txt ) +    print txt if @@debug +  end + +  def escape_vim_singlequote_string(str) +    str.to_s.gsub(/'/,"\\'") +  end + +  def get_buffer_entity_list( type ) +    # this will be a little expensive. +    loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") +    allow_aggressive_load = VIM::evaluate("exists('g:rubycomplete_classes_in_global') && g:rubycomplete_classes_in_global") +    return [] if allow_aggressive_load.to_i.zero? || loading_allowed.to_i.zero? + +    buf = VIM::Buffer.current +    eob = buf.length +    ret = [] +    rg = 1..eob +    re = eval( "/^\s*%s\s*([A-Za-z0-9_:-]*)(\s*<\s*([A-Za-z0-9_:-]*))?\s*/" % type ) + +    rg.each do |x| +      if re.match( buf[x] ) +        next if type == "def" && eval( VIM::evaluate("s:IsPosInClassDef(%s)" % x) ) != nil +        ret.push $1 +      end +    end + +    return ret +  end + +  def get_buffer_modules +    return get_buffer_entity_list( "modules" ) +  end + +  def get_buffer_methods +    return get_buffer_entity_list( "def" ) +  end + +  def get_buffer_classes +    return get_buffer_entity_list( "class" ) +  end + + +  def load_rails +    allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") +    return if allow_rails.to_i.zero? + +    buf_path = VIM::evaluate('expand("%:p")') +    file_name = VIM::evaluate('expand("%:t")') +    vim_dir = VIM::evaluate('getcwd()') +    file_dir = buf_path.gsub( file_name, '' ) +    file_dir.gsub!( /\\/, "/" ) +    vim_dir.gsub!( /\\/, "/" ) +    vim_dir << "/" +    dirs = [ vim_dir, file_dir ] +    sdirs = [ "", "./", "../", "../../", "../../../", "../../../../" ] +    rails_base = nil + +    dirs.each do |dir| +      sdirs.each do |sub| +        trail = "%s%s" % [ dir, sub ] +        tcfg = "%sconfig" % trail + +        if File.exists?( tcfg ) +          rails_base = trail +          break +        end +      end +      break if rails_base +    end + +    return if rails_base == nil +    $:.push rails_base unless $:.index( rails_base ) + +    rails_config = rails_base + "config/" +    rails_lib = rails_base + "lib/" +    $:.push rails_config unless $:.index( rails_config ) +    $:.push rails_lib unless $:.index( rails_lib ) + +    bootfile = rails_config + "boot.rb" +    envfile = rails_config + "environment.rb" +    if File.exists?( bootfile ) && File.exists?( envfile ) +      begin +        require bootfile +        require envfile +        begin +          require 'console_app' +          require 'console_with_helpers' +        rescue Exception +          dprint "Rails 1.1+ Error %s" % $! +          # assume 1.0 +        end +        #eval( "Rails::Initializer.run" ) #not necessary? +        VIM::command('let s:rubycomplete_rails_loaded = 1') +        dprint "rails loaded" +      rescue Exception +        dprint "Rails Error %s" % $! +        VIM::evaluate( "s:ErrMsg('Error loading rails environment')" ) +      end +    end +  end + +  def get_rails_helpers +    allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") +    rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') +    return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero? + +    buf_path = VIM::evaluate('expand("%:p")') +    buf_path.gsub!( /\\/, "/" ) +    path_elm = buf_path.split( "/" ) +    dprint "buf_path: %s" % buf_path +    types = [ "app", "db", "lib", "test", "components", "script" ] + +    i = nil +    ret = [] +    type = nil +    types.each do |t| +      i = path_elm.index( t ) +      break if i +    end +    type = path_elm[i] +    type.downcase! + +    dprint "type: %s" % type +    case type +      when "app" +        i += 1 +        subtype = path_elm[i] +        subtype.downcase! + +        dprint "subtype: %s" % subtype +        case subtype +          when "views" +            ret += ActionView::Base.instance_methods +            ret += ActionView::Base.methods +          when "controllers" +            ret += ActionController::Base.instance_methods +            ret += ActionController::Base.methods +          when "models" +            ret += ActiveRecord::Base.instance_methods +            ret += ActiveRecord::Base.methods +        end + +      when "db" +        ret += ActiveRecord::ConnectionAdapters::SchemaStatements.instance_methods +        ret += ActiveRecord::ConnectionAdapters::SchemaStatements.methods +    end + + +    return ret +  end + +  def add_rails_columns( cls ) +    allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") +    rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') +    return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero? + +    begin +        eval( "#{cls}.establish_connection" ) +        return [] unless eval( "#{cls}.ancestors.include?(ActiveRecord::Base).to_s" ) +        col = eval( "#{cls}.column_names" ) +        return col if col +    rescue +        dprint "add_rails_columns err: (cls: %s) %s" % [ cls, $! ] +        return [] +    end +    return [] +  end + +  def clean_sel(sel, msg) +    ret = sel.reject{|x|x.nil?}.uniq +    ret = ret.grep(/^#{Regexp.quote(msg)}/) if msg != nil +    ret +  end + +  def get_rails_view_methods +    allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") +    rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') +    return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero? + +    buf_path = VIM::evaluate('expand("%:p")') +    buf_path.gsub!( /\\/, "/" ) +    pelm = buf_path.split( "/" ) +    idx = pelm.index( "views" ) + +    return [] unless idx +    idx += 1 + +    clspl = pelm[idx].camelize.pluralize +    cls = clspl.singularize + +    ret = [] +    begin +      ret += eval( "#{cls}.instance_methods" ) +      ret += eval( "#{clspl}Helper.instance_methods" ) +    rescue Exception +      dprint "Error: Unable to load rails view helpers for %s: %s" % [ cls, $! ] +    end + +    return ret +  end +# }}} buffer analysis magic + +# {{{ main completion code +  def self.preload_rails +    a = VimRubyCompletion.new +    require 'Thread' +    Thread.new(a) do |b| +      begin +      b.load_rails +      rescue +      end +    end +    a.load_rails +  rescue +  end + +  def self.get_completions(base) +    b = VimRubyCompletion.new +    b.get_completions base +  end + +  def get_completions(base) +    loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") +    if loading_allowed.to_i == 1 +      load_requires +      load_rails +    end + +    want_gems = VIM::evaluate("get(g:, 'rubycomplete_load_gemfile')") +    load_gems unless want_gems.to_i.zero? +     + +    input = VIM::Buffer.current.line +    cpos = VIM::Window.current.cursor[1] - 1 +    input = input[0..cpos] +    input += base +    input.sub!(/.*[ \t\n\"\\'`><=;|&{(]/, '') # Readline.basic_word_break_characters +    input.sub!(/self\./, '') +    input.sub!(/.*((\.\.[\[(]?)|([\[(]))/, '') + +    dprint 'input %s' % input +    message = nil +    receiver = nil +    methods = [] +    variables = [] +    classes = [] +    constants = [] + +    case input +      when /^(\/[^\/]*\/)\.([^.]*)$/ # Regexp +        receiver = $1 +        message = Regexp.quote($2) +        methods = Regexp.instance_methods(true) + +      when /^([^\]]*\])\.([^.]*)$/ # Array +        receiver = $1 +        message = Regexp.quote($2) +        methods = Array.instance_methods(true) + +      when /^([^\}]*\})\.([^.]*)$/ # Proc or Hash +        receiver = $1 +        message = Regexp.quote($2) +        methods = Proc.instance_methods(true) | Hash.instance_methods(true) + +      when /^(:[^:.]*)$/ # Symbol +        dprint "symbol" +        if Symbol.respond_to?(:all_symbols) +          receiver = $1 +          message = $1.sub( /:/, '' ) +          methods = Symbol.all_symbols.collect{|s| s.id2name} +          methods.delete_if { |c| c.match( /'/ ) } +        end + +      when /^::([A-Z][^:\.\(]*)$/ # Absolute Constant or class methods +        dprint "const or cls" +        receiver = $1 +        methods = Object.constants +        methods.grep(/^#{receiver}/).collect{|e| "::" + e} + +      when /^(((::)?[A-Z][^:.\(]*)+?)::?([^:.]*)$/ # Constant or class methods +        receiver = $1 +        message = Regexp.quote($4) +        dprint "const or cls 2 [recv: \'%s\', msg: \'%s\']" % [ receiver, message ] +        load_buffer_class( receiver ) +        begin +          classes = eval("#{receiver}.constants") +          #methods = eval("#{receiver}.methods") +        rescue Exception +          dprint "exception: %s" % $! +          methods = [] +        end +        methods.grep(/^#{message}/).collect{|e| receiver + "::" + e} + +      when /^(:[^:.]+)\.([^.]*)$/ # Symbol +        dprint "symbol" +        receiver = $1 +        message = Regexp.quote($2) +        methods = Symbol.instance_methods(true) + +      when /^([0-9_]+(\.[0-9_]+)?(e[0-9]+)?)\.([^.]*)$/ # Numeric +        dprint "numeric" +        receiver = $1 +        message = Regexp.quote($4) +        begin +          methods = eval(receiver).methods +        rescue Exception +          methods = [] +        end + +      when /^(\$[^.]*)$/ #global +        dprint "global" +        methods = global_variables.grep(Regexp.new(Regexp.quote($1))) + +      when /^((\.?[^.]+)+?)\.([^.]*)$/ # variable +        dprint "variable" +        receiver = $1 +        message = Regexp.quote($3) +        load_buffer_class( receiver ) + +        cv = eval("self.class.constants") +        vartype = get_var_type( receiver ) +        dprint "vartype: %s" % vartype +        if vartype != '' +          load_buffer_class( vartype ) + +          begin +            methods = eval("#{vartype}.instance_methods") +            variables = eval("#{vartype}.instance_variables") +          rescue Exception +            dprint "load_buffer_class err: %s" % $! +          end +        elsif (cv).include?(receiver) +          # foo.func and foo is local var. +          methods = eval("#{receiver}.methods") +          vartype = receiver +        elsif /^[A-Z]/ =~ receiver and /\./ !~ receiver +          vartype = receiver +          # Foo::Bar.func +          begin +            methods = eval("#{receiver}.methods") +          rescue Exception +          end +        else +          # func1.func2 +          ObjectSpace.each_object(Module){|m| +            next if m.name != "IRB::Context" and +              /^(IRB|SLex|RubyLex|RubyToken)/ =~ m.name +            methods.concat m.instance_methods(false) +          } +        end +        variables += add_rails_columns( "#{vartype}" ) if vartype && vartype.length > 0 + +      when /^\(?\s*[A-Za-z0-9:^@.%\/+*\(\)]+\.\.\.?[A-Za-z0-9:^@.%\/+*\(\)]+\s*\)?\.([^.]*)/ +        message = $1 +        methods = Range.instance_methods(true) + +      when /^\.([^.]*)$/ # unknown(maybe String) +        message = Regexp.quote($1) +        methods = String.instance_methods(true) + +    else +      dprint "default/other" +      inclass = eval( VIM::evaluate("s:IsInClassDef()") ) + +      if inclass != nil +        dprint "inclass" +        classdef = "%s\n" % VIM::Buffer.current[ inclass.min ] +        found = /^\s*class\s*([A-Za-z0-9_-]*)(\s*<\s*([A-Za-z0-9_:-]*))?\s*\n$/.match( classdef ) + +        if found != nil +          receiver = $1 +          message = input +          load_buffer_class( receiver ) +          begin +            methods = eval( "#{receiver}.instance_methods" ) +            variables += add_rails_columns( "#{receiver}" ) +          rescue Exception +            found = nil +          end +        end +      end + +      if inclass == nil || found == nil +        dprint "inclass == nil" +        methods = get_buffer_methods +        methods += get_rails_view_methods + +        cls_const = Class.constants +        constants = cls_const.select { |c| /^[A-Z_-]+$/.match( c ) } +        classes = eval("self.class.constants") - constants +        classes += get_buffer_classes +        classes += get_buffer_modules + +        include_objectspace = VIM::evaluate("exists('g:rubycomplete_include_objectspace') && g:rubycomplete_include_objectspace") +        ObjectSpace.each_object(Class) { |cls| classes << cls.to_s } if include_objectspace == "1" +        message = receiver = input +      end + +      methods += get_rails_helpers +      methods += Kernel.public_methods +    end + + +    include_object = VIM::evaluate("exists('g:rubycomplete_include_object') && g:rubycomplete_include_object") +    methods = clean_sel( methods, message ) +    methods = (methods-Object.instance_methods) if include_object == "0" +    rbcmeth = (VimRubyCompletion.instance_methods-Object.instance_methods) # lets remove those rubycomplete methods +    methods = (methods-rbcmeth) + +    variables = clean_sel( variables, message ) +    classes = clean_sel( classes, message ) - ["VimRubyCompletion"] +    constants = clean_sel( constants, message ) + +    valid = [] +    valid += methods.collect { |m| { :name => m.to_s, :type => 'm' } } +    valid += variables.collect { |v| { :name => v.to_s, :type => 'v' } } +    valid += classes.collect { |c| { :name => c.to_s, :type => 't' } } +    valid += constants.collect { |d| { :name => d.to_s, :type => 'd' } } +    valid.sort! { |x,y| x[:name] <=> y[:name] } + +    outp = "" + +    rg = 0..valid.length +    rg.step(150) do |x| +      stpos = 0+x +      enpos = 150+x +      valid[stpos..enpos].each { |c| outp += "{'word':'%s','item':'%s','kind':'%s'}," % [ c[:name], c[:name], c[:type] ].map{|x|escape_vim_singlequote_string(x)} } +      outp.sub!(/,$/, '') + +      VIM::command("call extend(g:rubycomplete_completions, [%s])" % outp) +      outp = "" +    end +  end +# }}} main completion code + +end # VimRubyCompletion +# }}} ruby completion +RUBYEOF +endfunction + +let s:rubycomplete_rails_loaded = 0 + +call s:DefRuby() +"}}} ruby-side code + + +" vim:tw=78:sw=4:ts=8:et:fdm=marker:ft=vim:norl: @@ -3,7 +3,7 @@  set -E  DIRS=" -  syntax indent ftplugin ftdetect autoload compiler doc +  syntax indent ftplugin ftdetect autoload compiler    after/syntax after/indent  " @@ -44,3 +44,10 @@ syntax 'acustodioo/vim-tmux' &  syntax 'groenewege/vim-less' &  syntax 'wavded/vim-stylus' &  syntax 'tpope/vim-cucumber' & +syntax 'jrk/vim-ocaml' & +syntax 'wlangstroth/vim-haskell' & +syntax 'slim-template/vim-slim' & + +wait + +rm -rf tmp diff --git a/compiler/bundler.vim b/compiler/bundler.vim new file mode 100644 index 00000000..b129793a --- /dev/null +++ b/compiler/bundler.vim @@ -0,0 +1,26 @@ +" Vim compiler file + +if exists("current_compiler") +  finish +endif +let current_compiler = "bundler" + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=bundle + +CompilerSet errorformat= +      \%+E%f:%l:\ parse\ error, +      \%W%f:%l:\ warning:\ %m, +      \%E%f:%l:in\ %*[^:]:\ %m, +      \%E%f:%l:\ %m, +      \%-C%\tfrom\ %f:%l:in\ %.%#, +      \%-Z%\tfrom\ %f:%l, +      \%-Z%p^, +      \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: sw=2: diff --git a/compiler/cake.vim b/compiler/cake.vim new file mode 100644 index 00000000..0a3c7037 --- /dev/null +++ b/compiler/cake.vim @@ -0,0 +1,15 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +if exists('current_compiler') +  finish +endif + +let current_compiler = 'cake' +call coffee#CoffeeSetUpVariables() + +exec 'CompilerSet makeprg=' . escape(g:coffee_cake . ' ' . +\                                    g:coffee_cake_options . ' $*', ' ') +call coffee#CoffeeSetUpErrorFormat() diff --git a/compiler/coffee.vim b/compiler/coffee.vim new file mode 100644 index 00000000..f521ca9e --- /dev/null +++ b/compiler/coffee.vim @@ -0,0 +1,82 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +" All this is needed to support compiling filenames with spaces, quotes, and +" such. The filename is escaped and embedded into the `makeprg` setting. +" +" Because of this, `makeprg` must be updated on every file rename. And because +" of that, `CompilerSet` can't be used because it doesn't exist when the +" rename autocmd is ran. So, we have to do some checks to see whether `compiler` +" was called locally or globally, and respect that in the rest of the script. + +if exists('current_compiler') +  finish +endif + +let current_compiler = 'coffee' +call coffee#CoffeeSetUpVariables() + +" Pattern to check if coffee is the compiler +let s:pat = '^' . current_compiler + +" Get a `makeprg` for the current filename. +function! s:GetMakePrg() +  return g:coffee_compiler . +  \      ' -c' . +  \      ' ' . b:coffee_litcoffee . +  \      ' ' . g:coffee_make_options . +  \      ' ' . fnameescape(expand('%')) . +  \      ' $*' +endfunction + +" Set `makeprg` and return 1 if coffee is still the compiler, else return 0. +function! s:SetMakePrg() +  if &l:makeprg =~ s:pat +    let &l:makeprg = s:GetMakePrg() +  elseif &g:makeprg =~ s:pat +    let &g:makeprg = s:GetMakePrg() +  else +    return 0 +  endif + +  return 1 +endfunction + +" Set a dummy compiler so we can check whether to set locally or globally. +exec 'CompilerSet makeprg=' . current_compiler +" Then actually set the compiler. +call s:SetMakePrg() +call coffee#CoffeeSetUpErrorFormat() + +function! s:CoffeeMakeDeprecated(bang, args) +  echoerr 'CoffeeMake is deprecated! Please use :make instead, its behavior ' . +  \       'is identical.' +  sleep 5 +  exec 'make' . a:bang a:args +endfunction + +" Compile the current file. +command! -bang -bar -nargs=* CoffeeMake +\        call s:CoffeeMakeDeprecated(<q-bang>, <q-args>) + +" Set `makeprg` on rename since we embed the filename in the setting. +augroup CoffeeUpdateMakePrg +  autocmd! + +  " Update `makeprg` if coffee is still the compiler, else stop running this +  " function. +  function! s:UpdateMakePrg() +    if !s:SetMakePrg() +      autocmd! CoffeeUpdateMakePrg +    endif +  endfunction + +  " Set autocmd locally if compiler was set locally. +  if &l:makeprg =~ s:pat +    autocmd BufFilePost,BufWritePost <buffer> call s:UpdateMakePrg() +  else +    autocmd BufFilePost,BufWritePost          call s:UpdateMakePrg() +  endif +augroup END diff --git a/compiler/cucumber.vim b/compiler/cucumber.vim new file mode 100644 index 00000000..c020be6e --- /dev/null +++ b/compiler/cucumber.vim @@ -0,0 +1,29 @@ +" Vim compiler file +" Compiler:	Cucumber +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 Aug 09 + +if exists("current_compiler") +  finish +endif +let current_compiler = "cucumber" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=cucumber + +CompilerSet errorformat= +      \%W%m\ (Cucumber::Undefined), +      \%E%m\ (%.%#), +      \%Z%f:%l, +      \%Z%f:%l:%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2: diff --git a/compiler/eruby.vim b/compiler/eruby.vim new file mode 100644 index 00000000..45ad5eea --- /dev/null +++ b/compiler/eruby.vim @@ -0,0 +1,39 @@ +" Vim compiler file +" Language:		eRuby +" Maintainer:		Doug Kearns <dougkearns@gmail.com> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +if exists("current_compiler") +  finish +endif +let current_compiler = "eruby" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +if exists("eruby_compiler") && eruby_compiler == "eruby" +  CompilerSet makeprg=eruby +else +  CompilerSet makeprg=erb +endif + +CompilerSet errorformat= +    \eruby:\ %f:%l:%m, +    \%+E%f:%l:\ parse\ error, +    \%W%f:%l:\ warning:\ %m, +    \%E%f:%l:in\ %*[^:]:\ %m, +    \%E%f:%l:\ %m, +    \%-C%\tfrom\ %f:%l:in\ %.%#, +    \%-Z%\tfrom\ %f:%l, +    \%-Z%p^, +    \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/compiler/haml.vim b/compiler/haml.vim new file mode 100644 index 00000000..b06a672d --- /dev/null +++ b/compiler/haml.vim @@ -0,0 +1,28 @@ +" Vim compiler file +" Compiler:	Haml +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2013 May 30 + +if exists("current_compiler") +  finish +endif +let current_compiler = "haml" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=haml\ -c + +CompilerSet errorformat= +      \Haml\ %trror\ on\ line\ %l:\ %m, +      \Syntax\ %trror\ on\ line\ %l:\ %m, +      \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2: diff --git a/compiler/rake.vim b/compiler/rake.vim new file mode 100644 index 00000000..3bd9da0d --- /dev/null +++ b/compiler/rake.vim @@ -0,0 +1,35 @@ +" Vim compiler file +" Language:		Rake +" Maintainer:		Tim Pope <vimNOSPAM@tpope.org> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +if exists("current_compiler") +  finish +endif +let current_compiler = "rake" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=rake + +CompilerSet errorformat= +      \%D(in\ %f), +      \%\\s%#from\ %f:%l:%m, +      \%\\s%#from\ %f:%l:, +      \%\\s%##\ %f:%l:%m, +      \%\\s%##\ %f:%l, +      \%\\s%#[%f:%l:\ %#%m, +      \%\\s%#%f:%l:\ %#%m, +      \%\\s%#%f:%l:, +      \%m\ [%f:%l]: + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/compiler/rspec.vim b/compiler/rspec.vim new file mode 100644 index 00000000..7c340bab --- /dev/null +++ b/compiler/rspec.vim @@ -0,0 +1,33 @@ +" Vim compiler file +" Language:		RSpec +" Maintainer:		Tim Pope <vimNOSPAM@tpope.org> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +if exists("current_compiler") +  finish +endif +let current_compiler = "rspec" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=rspec + +CompilerSet errorformat= +    \%f:%l:\ %tarning:\ %m, +    \%E%.%#:in\ `load':\ %f:%l:%m, +    \%E%f:%l:in\ `%*[^']':\ %m, +    \%-Z\ \ \ \ \ \#\ %f:%l:%.%#, +    \%E\ \ %\\d%\\+)%.%#, +    \%C\ \ \ \ \ %m, +    \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/compiler/ruby.vim b/compiler/ruby.vim new file mode 100644 index 00000000..dcf7a401 --- /dev/null +++ b/compiler/ruby.vim @@ -0,0 +1,45 @@ +" Vim compiler file +" Language:		Ruby +" Function:		Syntax check and/or error reporting +" Maintainer:		Tim Pope <vimNOSPAM@tpope.org> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> +" ---------------------------------------------------------------------------- + +if exists("current_compiler") +  finish +endif +let current_compiler = "ruby" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +" default settings runs script normally +" add '-c' switch to run syntax check only: +" +"   CompilerSet makeprg=ruby\ -wc\ $* +" +" or add '-c' at :make command line: +" +"   :make -c %<CR> +" +CompilerSet makeprg=ruby\ -w\ $* + +CompilerSet errorformat= +    \%+E%f:%l:\ parse\ error, +    \%W%f:%l:\ warning:\ %m, +    \%E%f:%l:in\ %*[^:]:\ %m, +    \%E%f:%l:\ %m, +    \%-C%\tfrom\ %f:%l:in\ %.%#, +    \%-Z%\tfrom\ %f:%l, +    \%-Z%p^, +    \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/compiler/rubyunit.vim b/compiler/rubyunit.vim new file mode 100644 index 00000000..93a0c8e6 --- /dev/null +++ b/compiler/rubyunit.vim @@ -0,0 +1,33 @@ +" Vim compiler file +" Language:		Test::Unit - Ruby Unit Testing Framework +" Maintainer:		Doug Kearns <dougkearns@gmail.com> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +if exists("current_compiler") +  finish +endif +let current_compiler = "rubyunit" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=testrb + +CompilerSet errorformat=\%W\ %\\+%\\d%\\+)\ Failure:, +			\%C%m\ [%f:%l]:, +			\%E\ %\\+%\\d%\\+)\ Error:, +			\%C%m:, +			\%C\ \ \ \ %f:%l:%.%#, +			\%C%m, +			\%Z\ %#, +			\%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/compiler/sass.vim b/compiler/sass.vim new file mode 100644 index 00000000..376a52b3 --- /dev/null +++ b/compiler/sass.vim @@ -0,0 +1,30 @@ +" Vim compiler file +" Compiler:	Sass +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2013 May 30 + +if exists("current_compiler") +  finish +endif +let current_compiler = "sass" + +if exists(":CompilerSet") != 2		" older Vim always used :setlocal +  command -nargs=* CompilerSet setlocal <args> +endif + +let s:cpo_save = &cpo +set cpo-=C + +CompilerSet makeprg=sass\ -c + +CompilerSet errorformat= +      \%f:%l:%m\ (Sass::Syntax%trror), +      \%ESyntax\ %trror:%m, +      \%C%\\s%\\+on\ line\ %l\ of\ %f, +      \%Z%.%#, +      \%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2: diff --git a/ftdetect/coffee.vim b/ftdetect/coffee.vim new file mode 100644 index 00000000..50569298 --- /dev/null +++ b/ftdetect/coffee.vim @@ -0,0 +1,17 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +autocmd BufNewFile,BufRead *.coffee set filetype=coffee +autocmd BufNewFile,BufRead *Cakefile set filetype=coffee +autocmd BufNewFile,BufRead *.coffeekup,*.ck set filetype=coffee +autocmd BufNewFile,BufRead *._coffee set filetype=coffee + +function! s:DetectCoffee() +    if getline(1) =~ '^#!.*\<coffee\>' +        set filetype=coffee +    endif +endfunction + +autocmd BufNewFile,BufRead * call s:DetectCoffee() diff --git a/ftdetect/cucumber.vim b/ftdetect/cucumber.vim new file mode 100644 index 00000000..f00f9e2f --- /dev/null +++ b/ftdetect/cucumber.vim @@ -0,0 +1,2 @@ +" Cucumber +autocmd BufNewFile,BufReadPost *.feature,*.story set filetype=cucumber diff --git a/ftdetect/haml.vim b/ftdetect/haml.vim new file mode 100644 index 00000000..bf1de754 --- /dev/null +++ b/ftdetect/haml.vim @@ -0,0 +1,3 @@ +autocmd BufNewFile,BufRead *.haml,*.hamlbars setf haml +autocmd BufNewFile,BufRead *.sass setf sass +autocmd BufNewFile,BufRead *.scss setf scss diff --git a/ftdetect/haskell.vim b/ftdetect/haskell.vim new file mode 100644 index 00000000..1f511415 --- /dev/null +++ b/ftdetect/haskell.vim @@ -0,0 +1,2 @@ +" autocommand +au BufRead,BufNewFile *.hs set comments=sl:{-,mb:--,elx:-} diff --git a/ftdetect/javascript.vim b/ftdetect/javascript.vim new file mode 100644 index 00000000..805e1978 --- /dev/null +++ b/ftdetect/javascript.vim @@ -0,0 +1,11 @@ +au BufNewFile,BufRead *.js setf javascript +au BufNewFile,BufRead *.jsm setf javascript +au BufNewFile,BufRead *.json setf javascript +au BufNewFile,BufRead Jakefile setf javascript + +fun! s:SelectJavascript() +  if getline(1) =~# '^#!.*/bin/env\s\+node\>' +    set ft=javascript +  endif +endfun +au BufNewFile,BufRead * call s:SelectJavascript() diff --git a/ftdetect/json.vim b/ftdetect/json.vim new file mode 100644 index 00000000..5f6757de --- /dev/null +++ b/ftdetect/json.vim @@ -0,0 +1,8 @@ +autocmd BufNewFile,BufRead *.json set filetype=json + +augroup json_autocmd +  autocmd! +  autocmd FileType json setlocal autoindent +  autocmd FileType json setlocal formatoptions=tcq2l +  autocmd FileType json setlocal foldmethod=syntax +augroup END diff --git a/ftdetect/less.vim b/ftdetect/less.vim new file mode 100644 index 00000000..f1cb1d7e --- /dev/null +++ b/ftdetect/less.vim @@ -0,0 +1 @@ +autocmd BufNewFile,BufRead *.less setf less diff --git a/ftdetect/nginx.vim b/ftdetect/nginx.vim new file mode 100644 index 00000000..45bb1c15 --- /dev/null +++ b/ftdetect/nginx.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile /etc/nginx/*,/usr/local/nginx/*,*/nginx/vhosts.d/*,nginx.conf if &ft == '' | setfiletype nginx | endif diff --git a/ftdetect/ruby.vim b/ftdetect/ruby.vim new file mode 100644 index 00000000..a4e9a6d9 --- /dev/null +++ b/ftdetect/ruby.vim @@ -0,0 +1,62 @@ +" Ruby +au BufNewFile,BufRead *.rb,*.rbw,*.gemspec	set filetype=ruby + +" Ruby on Rails +au BufNewFile,BufRead *.builder,*.rxml,*.rjs	set filetype=ruby + +" Rakefile +au BufNewFile,BufRead [rR]akefile,*.rake	set filetype=ruby + +" Rantfile +au BufNewFile,BufRead [rR]antfile,*.rant	set filetype=ruby + +" IRB config +au BufNewFile,BufRead .irbrc,irbrc		set filetype=ruby + +" Pry config +au BufNewFile,BufRead .pryrc			set filetype=ruby + +" Rackup +au BufNewFile,BufRead *.ru			set filetype=ruby + +" Capistrano +au BufNewFile,BufRead Capfile			set filetype=ruby + +" Bundler +au BufNewFile,BufRead Gemfile			set filetype=ruby + +" Guard +au BufNewFile,BufRead Guardfile,.Guardfile	set filetype=ruby + +" Chef +au BufNewFile,BufRead Cheffile			set filetype=ruby +au BufNewFile,BufRead Berksfile			set filetype=ruby + +" Vagrant +au BufNewFile,BufRead [vV]agrantfile		set filetype=ruby + +" Autotest +au BufNewFile,BufRead .autotest			set filetype=ruby + +" eRuby +au BufNewFile,BufRead *.erb,*.rhtml		set filetype=eruby + +" Thor +au BufNewFile,BufRead [tT]horfile,*.thor	set filetype=ruby + +" Rabl +au BufNewFile,BufRead *.rabl			set filetype=ruby + +" Jbuilder +au BufNewFile,BufRead *.jbuilder		set filetype=ruby + +" Puppet librarian +au BufNewFile,BufRead Puppetfile		set filetype=ruby +" +" Buildr Buildfile +au BufNewFile,BufRead [Bb]uildfile		set filetype=ruby + +" Appraisal +au BufNewFile,BufRead Appraisals		set filetype=ruby + +" vim: nowrap sw=2 sts=2 ts=8 noet: diff --git a/ftdetect/slim.vim b/ftdetect/slim.vim new file mode 100644 index 00000000..b3415ced --- /dev/null +++ b/ftdetect/slim.vim @@ -0,0 +1 @@ +autocmd BufNewFile,BufRead *.slim setf slim diff --git a/ftdetect/stylus.vim b/ftdetect/stylus.vim new file mode 100644 index 00000000..49e04ecc --- /dev/null +++ b/ftdetect/stylus.vim @@ -0,0 +1,3 @@ +" Stylus +autocmd BufNewFile,BufReadPost *.styl set filetype=stylus +autocmd BufNewFile,BufReadPost *.stylus set filetype=stylus diff --git a/ftdetect/textile.vim b/ftdetect/textile.vim new file mode 100644 index 00000000..d02f9425 --- /dev/null +++ b/ftdetect/textile.vim @@ -0,0 +1,8 @@ +" textile.vim +" +" Tim Harper (tim.theenchanter.com) + +" Force filetype to be textile even if already set +" This will override the system ftplugin/changelog  +" set on some distros +au BufRead,BufNewFile *.textile set filetype=textile diff --git a/ftdetect/tmux.vim b/ftdetect/tmux.vim new file mode 100644 index 00000000..62cad9da --- /dev/null +++ b/ftdetect/tmux.vim @@ -0,0 +1 @@ +autocmd BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux diff --git a/ftplugin/coffee.vim b/ftplugin/coffee.vim new file mode 100644 index 00000000..c44fe979 --- /dev/null +++ b/ftplugin/coffee.vim @@ -0,0 +1,404 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +if exists('b:did_ftplugin') +  finish +endif + +let b:did_ftplugin = 1 +call coffee#CoffeeSetUpVariables() + +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:# commentstring=#\ %s +setlocal omnifunc=javascriptcomplete#CompleteJS + +" Create custom augroups. +augroup CoffeeBufUpdate | augroup END +augroup CoffeeBufNew | augroup END + +" Enable coffee compiler if a compiler isn't set already. +if !len(&l:makeprg) +  compiler coffee +endif + +" Switch to the window for buf. +function! s:SwitchWindow(buf) +  exec bufwinnr(a:buf) 'wincmd w' +endfunction + +" Create a new scratch buffer and return the bufnr of it. After the function +" returns, vim remains in the scratch buffer so more set up can be done. +function! s:ScratchBufBuild(src, vert, size) +  if a:size <= 0 +    if a:vert +      let size = winwidth(bufwinnr(a:src)) / 2 +    else +      let size = winheight(bufwinnr(a:src)) / 2 +    endif +  endif + +  if a:vert +    vertical belowright new +    exec 'vertical resize' size +  else +    belowright new +    exec 'resize' size +  endif + +  setlocal bufhidden=wipe buftype=nofile nobuflisted noswapfile nomodifiable +  nnoremap <buffer> <silent> q :hide<CR> + +  return bufnr('%') +endfunction + +" Replace buffer contents with text and delete the last empty line. +function! s:ScratchBufUpdate(buf, text) +  " Move to the scratch buffer. +  call s:SwitchWindow(a:buf) + +  " Double check we're in the scratch buffer before overwriting. +  if bufnr('%') != a:buf +    throw 'unable to change to scratch buffer' +  endif + +  setlocal modifiable +    silent exec '% delete _' +    silent put! =a:text +    silent exec '$ delete _' +  setlocal nomodifiable +endfunction + +" Parse the output of coffee into a qflist entry for src buffer. +function! s:ParseCoffeeError(output, src, startline) +  " Coffee error is always on first line? +  let match = matchlist(a:output, +  \                     '^\(\f\+\|\[stdin\]\):\(\d\):\(\d\): error: \(.\{-}\)' . "\n") + +  if !len(match) +    return +  endif + +  " Consider the line number from coffee as relative and add it to the beginning +  " line number of the range the command was called on, then subtract one for +  " zero-based relativity. +  call setqflist([{'bufnr': a:src, 'lnum': a:startline + str2nr(match[2]) - 1, +  \                'type': 'E', 'col': str2nr(match[3]), 'text': match[4]}], 'r') +endfunction + +" Reset source buffer variables. +function! s:CoffeeCompileResetVars() +  " Variables defined in source buffer: +  "   b:coffee_compile_buf: bufnr of output buffer +  " Variables defined in output buffer: +  "   b:coffee_src_buf: bufnr of source buffer +  "   b:coffee_compile_pos: previous cursor position in output buffer + +  let b:coffee_compile_buf = -1 +endfunction + +function! s:CoffeeWatchResetVars() +  " Variables defined in source buffer: +  "   b:coffee_watch_buf: bufnr of output buffer +  " Variables defined in output buffer: +  "   b:coffee_src_buf: bufnr of source buffer +  "   b:coffee_watch_pos: previous cursor position in output buffer + +  let b:coffee_watch_buf = -1 +endfunction + +function! s:CoffeeRunResetVars() +  " Variables defined in CoffeeRun source buffer: +  "   b:coffee_run_buf: bufnr of output buffer +  " Variables defined in CoffeeRun output buffer: +  "   b:coffee_src_buf: bufnr of source buffer +  "   b:coffee_run_pos: previous cursor position in output buffer + +  let b:coffee_run_buf = -1 +endfunction + +" Clean things up in the source buffers. +function! s:CoffeeCompileClose() +  " Switch to the source buffer if not already in it. +  silent! call s:SwitchWindow(b:coffee_src_buf) +  call s:CoffeeCompileResetVars() +endfunction + +function! s:CoffeeWatchClose() +  silent! call s:SwitchWindow(b:coffee_src_buf) +  silent! autocmd! CoffeeAuWatch * <buffer> +  call s:CoffeeWatchResetVars() +endfunction + +function! s:CoffeeRunClose() +  silent! call s:SwitchWindow(b:coffee_src_buf) +  call s:CoffeeRunResetVars() +endfunction + +" Compile the lines between startline and endline and put the result into buf. +function! s:CoffeeCompileToBuf(buf, startline, endline) +  let src = bufnr('%') +  let input = join(getline(a:startline, a:endline), "\n") + +  " Coffee doesn't like empty input. +  if !len(input) +    " Function should still return within output buffer. +    call s:SwitchWindow(a:buf) +    return +  endif + +  " Pipe lines into coffee. +  let output = system(g:coffee_compiler . +  \                   ' -scb' . +  \                   ' ' . b:coffee_litcoffee . +  \                   ' 2>&1', input) + +  " Paste output into output buffer. +  call s:ScratchBufUpdate(a:buf, output) + +  " Highlight as JavaScript if there were no compile errors. +  if v:shell_error +    call s:ParseCoffeeError(output, src, a:startline) +    setlocal filetype= +  else +    " Clear the quickfix list. +    call setqflist([], 'r') +    setlocal filetype=javascript +  endif +endfunction + +" Peek at compiled CoffeeScript in a scratch buffer. We handle ranges like this +" to prevent the cursor from being moved (and its position saved) before the +" function is called. +function! s:CoffeeCompile(startline, endline, args) +  if a:args =~ '\<watch\>' +    echoerr 'CoffeeCompile watch is deprecated! Please use CoffeeWatch instead' +    sleep 5 +    call s:CoffeeWatch(a:args) +    return +  endif + +  " Switch to the source buffer if not already in it. +  silent! call s:SwitchWindow(b:coffee_src_buf) + +  " Bail if not in source buffer. +  if !exists('b:coffee_compile_buf') +    return +  endif + +  " Build the output buffer if it doesn't exist. +  if bufwinnr(b:coffee_compile_buf) == -1 +    let src = bufnr('%') + +    let vert = exists('g:coffee_compile_vert') || a:args =~ '\<vert\%[ical]\>' +    let size = str2nr(matchstr(a:args, '\<\d\+\>')) + +    " Build the output buffer and save the source bufnr. +    let buf = s:ScratchBufBuild(src, vert, size) +    let b:coffee_src_buf = src + +    " Set the buffer name. +    exec 'silent! file [CoffeeCompile ' . src . ']' + +    " Clean up the source buffer when the output buffer is closed. +    autocmd BufWipeout <buffer> call s:CoffeeCompileClose() +    " Save the cursor when leaving the output buffer. +    autocmd BufLeave <buffer> let b:coffee_compile_pos = getpos('.') + +    " Run user-defined commands on new buffer. +    silent doautocmd CoffeeBufNew User CoffeeCompile + +    " Switch back to the source buffer and save the output bufnr. This also +    " triggers BufLeave above. +    call s:SwitchWindow(src) +    let b:coffee_compile_buf = buf +  endif + +  " Fill the scratch buffer. +  call s:CoffeeCompileToBuf(b:coffee_compile_buf, a:startline, a:endline) +  " Reset cursor to previous position. +  call setpos('.', b:coffee_compile_pos) + +  " Run any user-defined commands on the scratch buffer. +  silent doautocmd CoffeeBufUpdate User CoffeeCompile +endfunction + +" Update the scratch buffer and switch back to the source buffer. +function! s:CoffeeWatchUpdate() +  call s:CoffeeCompileToBuf(b:coffee_watch_buf, 1, '$') +  call setpos('.', b:coffee_watch_pos) +  silent doautocmd CoffeeBufUpdate User CoffeeWatch +  call s:SwitchWindow(b:coffee_src_buf) +endfunction + +" Continually compile a source buffer. +function! s:CoffeeWatch(args) +  silent! call s:SwitchWindow(b:coffee_src_buf) + +  if !exists('b:coffee_watch_buf') +    return +  endif + +  if bufwinnr(b:coffee_watch_buf) == -1 +    let src = bufnr('%') + +    let vert = exists('g:coffee_watch_vert') || a:args =~ '\<vert\%[ical]\>' +    let size = str2nr(matchstr(a:args, '\<\d\+\>')) + +    let buf = s:ScratchBufBuild(src, vert, size) +    let b:coffee_src_buf = src + +    exec 'silent! file [CoffeeWatch ' . src . ']' + +    autocmd BufWipeout <buffer> call s:CoffeeWatchClose() +    autocmd BufLeave <buffer> let b:coffee_watch_pos = getpos('.') + +    silent doautocmd CoffeeBufNew User CoffeeWatch + +    call s:SwitchWindow(src) +    let b:coffee_watch_buf = buf +  endif + +  " Make sure only one watch autocmd is defined on this buffer. +  silent! autocmd! CoffeeAuWatch * <buffer> + +  augroup CoffeeAuWatch +    autocmd InsertLeave <buffer> call s:CoffeeWatchUpdate() +    autocmd BufWritePost <buffer> call s:CoffeeWatchUpdate() +  augroup END + +  call s:CoffeeWatchUpdate() +endfunction + +" Run a snippet of CoffeeScript between startline and endline. +function! s:CoffeeRun(startline, endline, args) +  silent! call s:SwitchWindow(b:coffee_src_buf) + +  if !exists('b:coffee_run_buf') +    return +  endif + +  if bufwinnr(b:coffee_run_buf) == -1 +    let src = bufnr('%') + +    let buf = s:ScratchBufBuild(src, exists('g:coffee_run_vert'), 0) +    let b:coffee_src_buf = src + +    exec 'silent! file [CoffeeRun ' . src . ']' + +    autocmd BufWipeout <buffer> call s:CoffeeRunClose() +    autocmd BufLeave <buffer> let b:coffee_run_pos = getpos('.') + +    silent doautocmd CoffeeBufNew User CoffeeRun + +    call s:SwitchWindow(src) +    let b:coffee_run_buf = buf +  endif + +  if a:startline == 1 && a:endline == line('$') +    let output = system(g:coffee_compiler . +    \                   ' ' . b:coffee_litcoffee . +    \                   ' ' . fnameescape(expand('%')) . +    \                   ' ' . a:args) +  else +    let input = join(getline(a:startline, a:endline), "\n") + +    if !len(input) +      return +    endif + +    let output = system(g:coffee_compiler . +    \                   ' -s' . +    \                   ' ' . b:coffee_litcoffee . +    \                   ' ' . a:args, input) +  endif + +  call s:ScratchBufUpdate(b:coffee_run_buf, output) +  call setpos('.', b:coffee_run_pos) + +  silent doautocmd CoffeeBufUpdate User CoffeeRun +endfunction + +" Run coffeelint on a file, and add any errors between startline and endline +" to the quickfix list. +function! s:CoffeeLint(startline, endline, bang, args) +  let input = join(getline(a:startline, a:endline), "\n") + +  if !len(input) +    return +  endif + +  let output = system(g:coffee_linter . +  \                   ' -s --csv' . +  \                   ' ' . b:coffee_litcoffee . +  \                   ' ' . g:coffee_lint_options . +  \                   ' ' . a:args . +  \                   ' 2>&1', input) + +  " Convert output into an array and strip off the csv header. +  let lines = split(output, "\n")[1:] +  let buf = bufnr('%') +  let qflist = [] + +  for line in lines +    let match = matchlist(line, '^stdin,\(\d\+\),\d*,\(error\|warn\),\(.\+\)$') + +    " Ignore unmatched lines. +    if !len(match) +      continue +    endif + +    " The 'type' will result in either 'E' or 'W'. +    call add(qflist, {'bufnr': buf, 'lnum': a:startline + str2nr(match[1]) - 1, +    \                 'type': toupper(match[2][0]), 'text': match[3]}) +  endfor + +  " Replace the quicklist with our items. +  call setqflist(qflist, 'r') + +  " If not given a bang, jump to first error. +  if !len(a:bang) +    silent! cc 1 +  endif +endfunction + +" Complete arguments for Coffee* commands. +function! s:CoffeeComplete(cmd, cmdline, cursor) +  let args = ['vertical'] + +  " If no partial command, return all possibilities. +  if !len(a:cmd) +    return args +  endif + +  let pat = '^' . a:cmd + +  for arg in args +    if arg =~ pat +      return [arg] +    endif +  endfor +endfunction + +" Set initial state variables if they don't exist +if !exists('b:coffee_compile_buf') +  call s:CoffeeCompileResetVars() +endif + +if !exists('b:coffee_watch_buf') +  call s:CoffeeWatchResetVars() +endif + +if !exists('b:coffee_run_buf') +  call s:CoffeeRunResetVars() +endif + +command! -range=% -bar -nargs=* -complete=customlist,s:CoffeeComplete +\        CoffeeCompile call s:CoffeeCompile(<line1>, <line2>, <q-args>) +command! -bar -nargs=* -complete=customlist,s:CoffeeComplete +\        CoffeeWatch call s:CoffeeWatch(<q-args>) +command! -range=% -bar -nargs=* CoffeeRun +\        call s:CoffeeRun(<line1>, <line2>, <q-args>) +command! -range=% -bang -bar -nargs=* CoffeeLint +\        call s:CoffeeLint(<line1>, <line2>, <q-bang>, <q-args>) diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim new file mode 100644 index 00000000..1c1f0f25 --- /dev/null +++ b/ftplugin/cucumber.vim @@ -0,0 +1,148 @@ +" Vim filetype plugin +" Language:	Cucumber +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 Aug 09 + +" Only do this when not done yet for this buffer +if (exists("b:did_ftplugin")) +  finish +endif +let b:did_ftplugin = 1 + +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:# commentstring=#\ %s +setlocal omnifunc=CucumberComplete + +let b:undo_ftplugin = "setl fo< com< cms< ofu<" + +let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') + +if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") +  nnoremap <silent><buffer> <C-]>       :<C-U>exe <SID>jump('edit',v:count)<CR> +  nnoremap <silent><buffer> [<C-D>      :<C-U>exe <SID>jump('edit',v:count)<CR> +  nnoremap <silent><buffer> ]<C-D>      :<C-U>exe <SID>jump('edit',v:count)<CR> +  nnoremap <silent><buffer> <C-W>]      :<C-U>exe <SID>jump('split',v:count)<CR> +  nnoremap <silent><buffer> <C-W><C-]>  :<C-U>exe <SID>jump('split',v:count)<CR> +  nnoremap <silent><buffer> <C-W>d      :<C-U>exe <SID>jump('split',v:count)<CR> +  nnoremap <silent><buffer> <C-W><C-D>  :<C-U>exe <SID>jump('split',v:count)<CR> +  nnoremap <silent><buffer> <C-W>}      :<C-U>exe <SID>jump('pedit',v:count)<CR> +  nnoremap <silent><buffer> [d          :<C-U>exe <SID>jump('pedit',v:count)<CR> +  nnoremap <silent><buffer> ]d          :<C-U>exe <SID>jump('pedit',v:count)<CR> +  let b:undo_ftplugin .= +        \ "|sil! nunmap <buffer> <C-]>" . +        \ "|sil! nunmap <buffer> [<C-D>" . +        \ "|sil! nunmap <buffer> ]<C-D>" . +        \ "|sil! nunmap <buffer> <C-W>]" . +        \ "|sil! nunmap <buffer> <C-W><C-]>" . +        \ "|sil! nunmap <buffer> <C-W>d" . +        \ "|sil! nunmap <buffer> <C-W><C-D>" . +        \ "|sil! nunmap <buffer> <C-W>}" . +        \ "|sil! nunmap <buffer> [d" . +        \ "|sil! nunmap <buffer> ]d" +endif + +function! s:jump(command,count) +  let steps = s:steps('.') +  if len(steps) == 0 || len(steps) < a:count +    return 'echoerr "No matching step found"' +  elseif len(steps) > 1 && !a:count +    return 'echoerr "Multiple matching steps found"' +  else +    let c = a:count ? a:count-1 : 0 +    return a:command.' +'.steps[c][1].' '.escape(steps[c][0],' %#') +  endif +endfunction + +function! s:allsteps() +  let step_pattern = '\C^\s*\K\k*\>\s*(\=\s*\zs\S.\{-\}\ze\s*)\=\s*\%(do\|{\)\s*\%(|[^|]*|\s*\)\=\%($\|#\)' +  let steps = [] +  for file in split(glob(b:cucumber_root.'/**/*.rb'),"\n") +    let lines = readfile(file) +    let num = 0 +    for line in lines +      let num += 1 +      if line =~ step_pattern +        let type = matchstr(line,'\w\+') +        let steps += [[file,num,type,matchstr(line,step_pattern)]] +      endif +    endfor +  endfor +  return steps +endfunction + +function! s:steps(lnum) +  let c = match(getline(a:lnum), '\S') + 1 +  while synIDattr(synID(a:lnum,c,1),'name') !~# '^$\|Region$' +    let c = c + 1 +  endwhile +  let step = matchstr(getline(a:lnum)[c-1 : -1],'^\s*\zs.\{-\}\ze\s*$') +  return filter(s:allsteps(),'s:stepmatch(v:val[3],step)') +endfunction + +function! s:stepmatch(receiver,target) +  if a:receiver =~ '^[''"].*[''"]$' +    let pattern = '^'.escape(substitute(a:receiver[1:-2],'$\w\+','(.*)','g'),'/').'$' +  elseif a:receiver =~ '^/.*/$' +    let pattern = a:receiver[1:-2] +  elseif a:receiver =~ '^%r..*.$' +    let pattern = escape(a:receiver[3:-2],'/') +  else +    return 0 +  endif +  try +    let vimpattern = substitute(substitute(pattern,'\\\@<!(?:','%(','g'),'\\\@<!\*?','{-}','g') +    if a:target =~# '\v'.vimpattern +      return 1 +    endif +  catch +  endtry +  if has("ruby") && pattern !~ '\\\@<!#{' +    ruby VIM.command("return #{if (begin; Kernel.eval('/'+VIM.evaluate('pattern')+'/'); rescue SyntaxError; end) === VIM.evaluate('a:target') then 1 else 0 end}") +  else +    return 0 +  endif +endfunction + +function! s:bsub(target,pattern,replacement) +  return  substitute(a:target,'\C\\\@<!'.a:pattern,a:replacement,'g') +endfunction + +function! CucumberComplete(findstart,base) abort +  let indent = indent('.') +  let group = synIDattr(synID(line('.'),indent+1,1),'name') +  let type = matchstr(group,'\Ccucumber\zs\%(Given\|When\|Then\)') +  let e = matchend(getline('.'),'^\s*\S\+\s') +  if type == '' || col('.') < col('$') || e < 0 +    return -1 +  endif +  if a:findstart +    return e +  endif +  let steps = [] +  for step in s:allsteps() +    if step[2] ==# type +      if step[3] =~ '^[''"]' +        let steps += [step[3][1:-2]] +      elseif step[3] =~ '^/\^.*\$/$' +        let pattern = step[3][2:-3] +        let pattern = substitute(pattern,'\C^(?:|I )','I ','') +        let pattern = s:bsub(pattern,'\\[Sw]','w') +        let pattern = s:bsub(pattern,'\\d','1') +        let pattern = s:bsub(pattern,'\\[sWD]',' ') +        let pattern = s:bsub(pattern,'\[\^\\\="\]','_') +        let pattern = s:bsub(pattern,'[[:alnum:]. _-][?*]?\=','') +        let pattern = s:bsub(pattern,'\[\([^^]\).\{-\}\]','\1') +        let pattern = s:bsub(pattern,'+?\=','') +        let pattern = s:bsub(pattern,'(\([[:alnum:]. -]\{-\}\))','\1') +        let pattern = s:bsub(pattern,'\\\([[:punct:]]\)','\1') +        if pattern !~ '[\\()*?]' +          let steps += [pattern] +        endif +      endif +    endif +  endfor +  call filter(steps,'strpart(v:val,0,strlen(a:base)) ==# a:base') +  return sort(steps) +endfunction + +" vim:set sts=2 sw=2: diff --git a/ftplugin/eruby.vim b/ftplugin/eruby.vim new file mode 100644 index 00000000..9bb8e86f --- /dev/null +++ b/ftplugin/eruby.vim @@ -0,0 +1,102 @@ +" Vim filetype plugin +" Language:		eRuby +" Maintainer:		Tim Pope <vimNOSPAM@tpope.org> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +" 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 = "" + +if !exists("g:eruby_default_subtype") +  let g:eruby_default_subtype = "html" +endif + +if &filetype =~ '^eruby\.' +  let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') +elseif !exists("b:eruby_subtype") +  let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") +  let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') +  if b:eruby_subtype == '' +    let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+$') +  endif +  if b:eruby_subtype == 'rhtml' +    let b:eruby_subtype = 'html' +  elseif b:eruby_subtype == 'rb' +    let b:eruby_subtype = 'ruby' +  elseif b:eruby_subtype == 'yml' +    let b:eruby_subtype = 'yaml' +  elseif b:eruby_subtype == 'js' +    let b:eruby_subtype = 'javascript' +  elseif b:eruby_subtype == 'txt' +    " Conventional; not a real file type +    let b:eruby_subtype = 'text' +  elseif b:eruby_subtype == '' +    let b:eruby_subtype = g:eruby_default_subtype +  endif +endif + +if exists("b:eruby_subtype") && b:eruby_subtype != '' +  exe "runtime! ftplugin/".b:eruby_subtype.".vim ftplugin/".b:eruby_subtype."_*.vim ftplugin/".b:eruby_subtype."/*.vim" +else +  runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim +endif +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 + +runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim +let b:did_ftplugin = 1 + +" Combine the new set of values with those previously included. +if exists("b:undo_ftplugin") +  let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin +endif +if exists ("b:browsefilter") +  let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter +endif +if exists("b:match_words") +  let s:match_words = b:match_words . ',' . s:match_words +endif + +" Change the browse dialog on Win32 to show mainly eRuby-related files +if has("gui_win32") +  let b:browsefilter="eRuby Files (*.erb, *.rhtml)\t*.erb;*.rhtml\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 + +" TODO: comments= +setlocal commentstring=<%#%s%> + +let b:undo_ftplugin = "setl cms< " +      \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/ftplugin/haml.vim b/ftplugin/haml.vim new file mode 100644 index 00000000..8c693fa0 --- /dev/null +++ b/ftplugin/haml.vim @@ -0,0 +1,68 @@ +" Vim filetype plugin +" Language:	Haml +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 May 21 + +" 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 +set matchpairs-=<:> + +" 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 + +runtime! ftplugin/ruby.vim ftplugin/ruby_*.vim ftplugin/ruby/*.vim +let b:did_ftplugin = 1 + +" Combine the new set of values with those previously included. +if exists("b:undo_ftplugin") +  let s:undo_ftplugin = b:undo_ftplugin . " | " . s:undo_ftplugin +endif +if exists ("b:browsefilter") +  let s:browsefilter = substitute(b:browsefilter,'\cAll Files (\*\.\*)\t\*\.\*\n','','') . s:browsefilter +endif +if exists("b:match_words") +  let s:match_words = b:match_words . ',' . s:match_words +endif + +" Change the browse dialog on Win32 to show mainly Haml-related files +if has("gui_win32") +  let b:browsefilter="Haml Files (*.haml)\t*.haml\nSass Files (*.sass)\t*.sass\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: diff --git a/ftplugin/haskell.vim b/ftplugin/haskell.vim new file mode 100644 index 00000000..9025b0e0 --- /dev/null +++ b/ftplugin/haskell.vim @@ -0,0 +1,13 @@ +" +" general Haskell source settings +" (shared functions are in autoload/haskellmode.vim) +" +" (Claus Reinke, last modified: 28/04/2009) +" +" part of haskell plugins: http://projects.haskell.org/haskellmode-vim +" please send patches to <claus.reinke@talk21.com> + +" try gf on import line, or ctrl-x ctrl-i, or [I, [i, .. +setlocal include=^import\\s*\\(qualified\\)\\?\\s* +setlocal includeexpr=substitute(v:fname,'\\.','/','g').'.' +setlocal suffixesadd=hs,lhs,hsc
\ No newline at end of file diff --git a/ftplugin/less.vim b/ftplugin/less.vim new file mode 100644 index 00000000..b6eaf6a3 --- /dev/null +++ b/ftplugin/less.vim @@ -0,0 +1,25 @@ +" Vim filetype plugin +" Language:	    LessCSS +" Author:	    Tim Pope <vimNOSPAM@tpope.org> +" Maintainer:   Leonard Ehrenfried <leonard.ehrenfried@web.de> +" Last Change:  2011 Sep 30 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") +  finish +endif +let b:did_ftplugin = 1 + +let b:undo_ftplugin = "setl cms< def< inc< inex< ofu< sua<" + +setlocal iskeyword+=- +setlocal commentstring=//\ %s +setlocal define=^\\s*\\%(@mixin\\\|=\\) +setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','') +setlocal omnifunc=csscomplete#CompleteCSS +setlocal suffixesadd=.less +setlocal comments=s1:/*,mb:*,ex:*/ + +let &l:include = '^\s*@import\s\+\%(url(\)\=["'']\=' + +" vim:set sw=2: diff --git a/ftplugin/ocaml.vim b/ftplugin/ocaml.vim new file mode 100644 index 00000000..2b39d27c --- /dev/null +++ b/ftplugin/ocaml.vim @@ -0,0 +1,505 @@ +" Language:    OCaml +" Maintainer:  David Baelde        <firstname.name@ens-lyon.org> +"              Mike Leary          <leary@nwlink.com> +"              Markus Mottl        <markus.mottl@gmail.com> +"              Stefano Zacchiroli  <zack@bononia.it> +" URL:         http://www.ocaml.info/vim/ftplugin/ocaml.vim +" Last Change: 2009 Nov 10 - Improved .annot support +"                            (MM for <radugrigore@gmail.com>) +"              2009 Nov 10 - Added support for looking up definitions +"                            (MM for <ygrek@autistici.org>) +" +if exists("b:did_ftplugin") +  finish +endif +let b:did_ftplugin=1 + +" Error handling -- helps moving where the compiler wants you to go +let s:cposet=&cpoptions +set cpo-=C +setlocal efm= +      \%EFile\ \"%f\"\\,\ line\ %l\\,\ characters\ %c-%*\\d:, +      \%EFile\ \"%f\"\\,\ line\ %l\\,\ character\ %c:%m, +      \%+EReference\ to\ unbound\ regexp\ name\ %m, +      \%Eocamlyacc:\ e\ -\ line\ %l\ of\ \"%f\"\\,\ %m, +      \%Wocamlyacc:\ w\ -\ %m, +      \%-Zmake%.%#, +      \%C%m, +      \%D%*\\a[%*\\d]:\ Entering\ directory\ `%f', +      \%X%*\\a[%*\\d]:\ Leaving\ directory\ `%f', +      \%D%*\\a:\ Entering\ directory\ `%f', +      \%X%*\\a:\ Leaving\ directory\ `%f', +      \%DMaking\ %*\\a\ in\ %f + +" Add mappings, unless the user didn't want this. +if !exists("no_plugin_maps") && !exists("no_ocaml_maps") +  " (un)commenting +  if !hasmapto('<Plug>Comment') +    nmap <buffer> <LocalLeader>c <Plug>LUncomOn +    vmap <buffer> <LocalLeader>c <Plug>BUncomOn +    nmap <buffer> <LocalLeader>C <Plug>LUncomOff +    vmap <buffer> <LocalLeader>C <Plug>BUncomOff +  endif + +  nnoremap <buffer> <Plug>LUncomOn mz0i(* <ESC>$A *)<ESC>`z +  nnoremap <buffer> <Plug>LUncomOff :s/^(\* \(.*\) \*)/\1/<CR>:noh<CR> +  vnoremap <buffer> <Plug>BUncomOn <ESC>:'<,'><CR>`<O<ESC>0i(*<ESC>`>o<ESC>0i*)<ESC>`< +  vnoremap <buffer> <Plug>BUncomOff <ESC>:'<,'><CR>`<dd`>dd`< + +  if !hasmapto('<Plug>Abbrev') +    iabbrev <buffer> ASF (assert false (* XXX *)) +    iabbrev <buffer> ASS (assert (0=1) (* XXX *)) +  endif +endif + +" Let % jump between structure elements (due to Issac Trotts) +let b:mw = '' +let b:mw = b:mw . ',\<let\>:\<and\>:\(\<in\>\|;;\)' +let b:mw = b:mw . ',\<if\>:\<then\>:\<else\>' +let b:mw = b:mw . ',\<\(for\|while\)\>:\<do\>:\<done\>,' +let b:mw = b:mw . ',\<\(object\|sig\|struct\|begin\)\>:\<end\>' +let b:mw = b:mw . ',\<\(match\|try\)\>:\<with\>' +let b:match_words = b:mw + +let b:match_ignorecase=0 + +" switching between interfaces (.mli) and implementations (.ml) +if !exists("g:did_ocaml_switch") +  let g:did_ocaml_switch = 1 +  map <LocalLeader>s :call OCaml_switch(0)<CR> +  map <LocalLeader>S :call OCaml_switch(1)<CR> +  fun OCaml_switch(newwin) +    if (match(bufname(""), "\\.mli$") >= 0) +      let fname = substitute(bufname(""), "\\.mli$", ".ml", "") +      if (a:newwin == 1) +        exec "new " . fname +      else +        exec "arge " . fname +      endif +    elseif (match(bufname(""), "\\.ml$") >= 0) +      let fname = bufname("") . "i" +      if (a:newwin == 1) +        exec "new " . fname +      else +        exec "arge " . fname +      endif +    endif +  endfun +endif + +" Folding support + +" Get the modeline because folding depends on indentation +let s:s = line2byte(line('.'))+col('.')-1 +if search('^\s*(\*:o\?caml:') +  let s:modeline = getline(".") +else +  let s:modeline = "" +endif +if s:s > 0 +  exe 'goto' s:s +endif + +" Get the indentation params +let s:m = matchstr(s:modeline,'default\s*=\s*\d\+') +if s:m != "" +  let s:idef = matchstr(s:m,'\d\+') +elseif exists("g:omlet_indent") +  let s:idef = g:omlet_indent +else +  let s:idef = 2 +endif +let s:m = matchstr(s:modeline,'struct\s*=\s*\d\+') +if s:m != "" +  let s:i = matchstr(s:m,'\d\+') +elseif exists("g:omlet_indent_struct") +  let s:i = g:omlet_indent_struct +else +  let s:i = s:idef +endif + +" Set the folding method +if exists("g:ocaml_folding") +  setlocal foldmethod=expr +  setlocal foldexpr=OMLetFoldLevel(v:lnum) +endif + +" - Only definitions below, executed once ------------------------------------- + +if exists("*OMLetFoldLevel") +  finish +endif + +function s:topindent(lnum) +  let l = a:lnum +  while l > 0 +    if getline(l) =~ '\s*\%(\<struct\>\|\<sig\>\|\<object\>\)' +      return indent(l) +    endif +    let l = l-1 +  endwhile +  return -s:i +endfunction + +function OMLetFoldLevel(l) + +  " This is for not merging blank lines around folds to them +  if getline(a:l) !~ '\S' +    return -1 +  endif + +  " We start folds for modules, classes, and every toplevel definition +  if getline(a:l) =~ '^\s*\%(\<val\>\|\<module\>\|\<class\>\|\<type\>\|\<method\>\|\<initializer\>\|\<inherit\>\|\<exception\>\|\<external\>\)' +    exe 'return ">' (indent(a:l)/s:i)+1 '"' +  endif + +  " Toplevel let are detected thanks to the indentation +  if getline(a:l) =~ '^\s*let\>' && indent(a:l) == s:i+s:topindent(a:l) +    exe 'return ">' (indent(a:l)/s:i)+1 '"' +  endif + +  " We close fold on end which are associated to struct, sig or object. +  " We use syntax information to do that. +  if getline(a:l) =~ '^\s*end\>' && synIDattr(synID(a:l, indent(a:l)+1, 0), "name") != "ocamlKeyword" +    return (indent(a:l)/s:i)+1 +  endif + +  " Folds end on ;; +  if getline(a:l) =~ '^\s*;;' +    exe 'return "<' (indent(a:l)/s:i)+1 '"' +  endif + +  " Comments around folds aren't merged to them. +  if synIDattr(synID(a:l, indent(a:l)+1, 0), "name") == "ocamlComment" +    return -1 +  endif + +  return '=' +endfunction + +" Vim support for OCaml .annot files (requires Vim with python support) +" +" Executing OCamlPrintType(<mode>) function will display in the Vim bottom +" line(s) the type of an ocaml value getting it from the corresponding .annot +" file (if any).  If Vim is in visual mode, <mode> should be "visual" and the +" selected ocaml value correspond to the highlighted text, otherwise (<mode> +" can be anything else) it corresponds to the literal found at the current +" cursor position. +" +" .annot files are parsed lazily the first time OCamlPrintType is invoked; is +" also possible to force the parsing using the OCamlParseAnnot() function. +" +" Typing '<LocalLeader>t' (usually ',t') will cause OCamlPrintType function  +" to be invoked with the right argument depending on the current mode (visual  +" or not). +" +" Copyright (C) <2003-2004> Stefano Zacchiroli <zack@bononia.it> +" +" Created:        Wed, 01 Oct 2003 18:16:22 +0200 zack +" LastModified:   Wed, 25 Aug 2004 18:28:39 +0200 zack + +" '<LocalLeader>d' will find the definition of the name under the cursor +" and position cursor on it (only for current file) or print fully qualified name +" (for external definitions). (ocaml >= 3.11) +" +" Additionally '<LocalLeader>t' will show whether function call is tail call +" or not. Current implementation requires selecting the whole function call +" expression (in visual mode) to work. (ocaml >= 3.11) +" +" Copyright (C) 2009 <ygrek@autistici.org> + +if !has("python") +  finish +endif + +python << EOF + +import re +import os +import os.path +import string +import time +import vim + +debug = False + +class AnnExc(Exception): +    def __init__(self, reason): +        self.reason = reason + +no_annotations = AnnExc("No annotations (.annot) file found") +annotation_not_found = AnnExc("No type annotation found for the given text") +definition_not_found = AnnExc("No definition found for the given text") +def malformed_annotations(lineno, reason): +    return AnnExc("Malformed .annot file (line = %d, reason = %s)" % (lineno,reason)) + +class Annotations: +    """ +      .annot ocaml file representation + +      File format (copied verbatim from caml-types.el) + +      file ::= block * +      block ::= position <SP> position <LF> annotation * +      position ::= filename <SP> num <SP> num <SP> num +      annotation ::= keyword open-paren <LF> <SP> <SP> data <LF> close-paren + +      <SP> is a space character (ASCII 0x20) +      <LF> is a line-feed character (ASCII 0x0A) +      num is a sequence of decimal digits +      filename is a string with the lexical conventions of O'Caml +      open-paren is an open parenthesis (ASCII 0x28) +      close-paren is a closed parenthesis (ASCII 0x29) +      data is any sequence of characters where <LF> is always followed by +           at least two space characters. + +      - in each block, the two positions are respectively the start and the +        end of the range described by the block. +      - in a position, the filename is the name of the file, the first num +        is the line number, the second num is the offset of the beginning +        of the line, the third num is the offset of the position itself. +      - the char number within the line is the difference between the third +        and second nums. + +      Possible keywords are \"type\", \"ident\" and \"call\". +    """ + +    def __init__(self): +        self.__filename = None  # last .annot parsed file +        self.__ml_filename = None # as above but s/.annot/.ml/ +        self.__timestamp = None # last parse action timestamp +        self.__annot = {} +        self.__refs = {} +        self.__calls = {} +        self.__re = re.compile( +          '^"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)\s+"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)$') +        self.__re_int_ref = re.compile('^int_ref\s+(\w+)\s"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)') +        self.__re_def_full = re.compile( +          '^def\s+(\w+)\s+"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)\s+"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)$') +        self.__re_def = re.compile('^def\s+(\w+)\s"[^"]*"\s+(\d+)\s+(\d+)\s+(\d+)\s+') +        self.__re_ext_ref = re.compile('^ext_ref\s+(\S+)') +        self.__re_kw = re.compile('^(\w+)\($') + +    def __parse(self, fname): +        try: +            f = open(fname) +            self.__annot = {} # erase internal mappings when file is reparsed +            self.__refs = {} +            self.__calls = {} +            line = f.readline() # position line +            lineno = 1 +            while (line != ""): +                m = self.__re.search(line) +                if (not m): +                    raise malformed_annotations(lineno,"re doesn't match") +                line1 = int(m.group(1)) +                col1 = int(m.group(3)) - int(m.group(2)) +                line2 = int(m.group(4)) +                col2 = int(m.group(6)) - int(m.group(5)) +                while 1: +                    line = f.readline() # keyword or position line +                    lineno += 1 +                    m = self.__re_kw.search(line) +                    if (not m): +                        break +                    desc = [] +                    line = f.readline() # description +                    lineno += 1 +                    if (line == ""): raise malformed_annotations(lineno,"no content") +                    while line != ")\n": +                        desc.append(string.strip(line)) +                        line = f.readline() +                        lineno += 1 +                        if (line == ""): raise malformed_annotations(lineno,"bad content") +                    desc = string.join(desc, "\n") +                    key = ((line1, col1), (line2, col2)) +                    if (m.group(1) == "type"): +                        if not self.__annot.has_key(key): +                            self.__annot[key] = desc +                    if (m.group(1) == "call"): # region, accessible only in visual mode +                        if not self.__calls.has_key(key): +                            self.__calls[key] = desc +                    if (m.group(1) == "ident"): +                        m = self.__re_int_ref.search(desc) +                        if m: +                          line = int(m.group(2)) +                          col = int(m.group(4)) - int(m.group(3)) +                          name = m.group(1) +                        else: +                          line = -1 +                          col = -1 +                          m = self.__re_ext_ref.search(desc) +                          if m: +                            name = m.group(1) +                          else: +                            line = -2 +                            col = -2 +                            name = desc +                        if not self.__refs.has_key(key): +                          self.__refs[key] = (line,col,name) +            f.close() +            self.__filename = fname +            self.__ml_filename = vim.current.buffer.name +            self.__timestamp = int(time.time()) +        except IOError: +            raise no_annotations + +    def parse(self): +        annot_file = os.path.splitext(vim.current.buffer.name)[0] + ".annot" +        previous_head, head, tail = '***', annot_file, '' +        while not os.path.isfile(annot_file) and head != previous_head: +            previous_head = head +            head, x = os.path.split(head) +            if tail == '': +              tail = x +            else: +              os.path.join(x, tail) +            annot_file = os.path.join(head, '_build', tail) +        self.__parse(annot_file) + +    def check_file(self): +        if vim.current.buffer.name == None: +            raise no_annotations +        if vim.current.buffer.name != self.__ml_filename or  \ +          os.stat(self.__filename).st_mtime > self.__timestamp: +            self.parse() + +    def get_type(self, (line1, col1), (line2, col2)): +        if debug: +            print line1, col1, line2, col2 +        self.check_file() +        try: +            try: +              extra = self.__calls[(line1, col1), (line2, col2)] +              if extra == "tail": +                extra = " (* tail call *)" +              else: +                extra = " (* function call *)" +            except KeyError: +              extra = "" +            return self.__annot[(line1, col1), (line2, col2)] + extra +        except KeyError: +            raise annotation_not_found + +    def get_ident(self, (line1, col1), (line2, col2)): +        if debug: +            print line1, col1, line2, col2 +        self.check_file() +        try: +            (line,col,name) = self.__refs[(line1, col1), (line2, col2)] +            if line >= 0 and col >= 0: +              vim.command("normal "+str(line)+"gg"+str(col+1)+"|") +              #current.window.cursor = (line,col) +            if line == -2: +              m = self.__re_def_full.search(name) +              if m: +                l2 = int(m.group(5)) +                c2 = int(m.group(7)) - int(m.group(6)) +                name = m.group(1) +              else: +                m = self.__re_def.search(name) +                if m: +                  l2 = int(m.group(2)) +                  c2 = int(m.group(4)) - int(m.group(3)) +                  name = m.group(1) +                else: +                  l2 = -1 +              if False and l2 >= 0: +                # select region +                if c2 == 0 and l2 > 0: +                  vim.command("normal v"+str(l2-1)+"gg"+"$") +                else: +                  vim.command("normal v"+str(l2)+"gg"+str(c2)+"|") +            return name +        except KeyError: +            raise definition_not_found + +word_char_RE = re.compile("^[\w.]$") + +  # TODO this function should recognize ocaml literals, actually it's just an +  # hack that recognize continuous sequences of word_char_RE above +def findBoundaries(line, col): +    """ given a cursor position (as returned by vim.current.window.cursor) +    return two integers identify the beggining and end column of the word at +    cursor position, if any. If no word is at the cursor position return the +    column cursor position twice """ +    left, right = col, col +    line = line - 1 # mismatch vim/python line indexes +    (begin_col, end_col) = (0, len(vim.current.buffer[line]) - 1) +    try: +        while word_char_RE.search(vim.current.buffer[line][left - 1]): +            left = left - 1 +    except IndexError: +        pass +    try: +        while word_char_RE.search(vim.current.buffer[line][right + 1]): +            right = right + 1 +    except IndexError: +        pass +    return (left, right) + +annot = Annotations() # global annotation object + +def get_marks(mode): +    if mode == "visual":  # visual mode: lookup highlighted text +        (line1, col1) = vim.current.buffer.mark("<") +        (line2, col2) = vim.current.buffer.mark(">") +    else: # any other mode: lookup word at cursor position +        (line, col) = vim.current.window.cursor +        (col1, col2) = findBoundaries(line, col) +        (line1, line2) = (line, line) +    begin_mark = (line1, col1) +    end_mark = (line2, col2 + 1) +    return (begin_mark,end_mark) + +def printOCamlType(mode): +    try: +        (begin_mark,end_mark) = get_marks(mode) +        print annot.get_type(begin_mark, end_mark) +    except AnnExc, exc: +        print exc.reason + +def gotoOCamlDefinition(mode): +    try: +        (begin_mark,end_mark) = get_marks(mode) +        print annot.get_ident(begin_mark, end_mark) +    except AnnExc, exc: +        print exc.reason + +def parseOCamlAnnot(): +    try: +        annot.parse() +    except AnnExc, exc: +        print exc.reason + +EOF + +fun! OCamlPrintType(current_mode) +  if (a:current_mode == "visual") +    python printOCamlType("visual") +  else +    python printOCamlType("normal") +  endif +endfun + +fun! OCamlGotoDefinition(current_mode) +  if (a:current_mode == "visual") +    python gotoOCamlDefinition("visual") +  else +    python gotoOCamlDefinition("normal") +  endif +endfun + +fun! OCamlParseAnnot() +  python parseOCamlAnnot() +endfun + +map <LocalLeader>t :call OCamlPrintType("normal")<RETURN> +vmap <LocalLeader>t :call OCamlPrintType("visual")<RETURN> +map <LocalLeader>d :call OCamlGotoDefinition("normal")<RETURN> +vmap <LocalLeader>d :call OCamlGotoDefinition("visual")<RETURN> + +let &cpoptions=s:cposet +unlet s:cposet + +" vim:sw=2 diff --git a/ftplugin/ruby.vim b/ftplugin/ruby.vim new file mode 100644 index 00000000..9630a940 --- /dev/null +++ b/ftplugin/ruby.vim @@ -0,0 +1,395 @@ +" Vim filetype plugin +" Language:		Ruby +" Maintainer:		Tim Pope <vimNOSPAM@tpope.org> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:  Doug Kearns <dougkearns@gmail.com> +" ---------------------------------------------------------------------------- + +if (exists("b:did_ftplugin")) +  finish +endif +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + +if has("gui_running") && !has("gui_win32") +  setlocal keywordprg=ri\ -T\ -f\ bs +else +  setlocal keywordprg=ri +endif + +" Matchit support +if exists("loaded_matchit") && !exists("b:match_words") +  let b:match_ignorecase = 0 + +  let b:match_words = +	\ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' . +	\ ':' . +	\ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' . +	\ ':' . +	\ '\<end\>' . +	\ ',{:},\[:\],(:)' + +  let b:match_skip = +	\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" . +	\ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" . +	\ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" . +	\ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" . +	\ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" . +	\ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'" +endif + +setlocal formatoptions-=t formatoptions+=croql + +setlocal include=^\\s*\\<\\(load\\>\\\|require\\>\\\|autoload\\s*:\\=[\"']\\=\\h\\w*[\"']\\=,\\) +setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.rb','') +setlocal suffixesadd=.rb + +if exists("&ofu") && has("ruby") +  setlocal omnifunc=rubycomplete#Complete +endif + +" To activate, :set ballooneval +if has('balloon_eval') && exists('+balloonexpr') +  setlocal balloonexpr=RubyBalloonexpr() +endif + + +" TODO: +"setlocal define=^\\s*def + +setlocal comments=:# +setlocal commentstring=#\ %s + +if !exists('g:ruby_version_paths') +  let g:ruby_version_paths = {} +endif + +function! s:query_path(root) +  let code = "print $:.join %q{,}" +  if &shell =~# 'sh' && $PATH !~# '\s' +    let prefix = 'env PATH='.$PATH.' ' +  else +    let prefix = '' +  endif +  if &shellxquote == "'" +    let path_check = prefix.'ruby -e "' . code . '"' +  else +    let path_check = prefix."ruby -e '" . code . "'" +  endif + +  let cd = haslocaldir() ? 'lcd' : 'cd' +  let cwd = getcwd() +  try +    exe cd fnameescape(a:root) +    let path = split(system(path_check),',') +    exe cd fnameescape(cwd) +    return path +  finally +    exe cd fnameescape(cwd) +  endtry +endfunction + +function! s:build_path(path) +  let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',') +  if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$' +    let path = substitute(&g:path,',,$',',','') . ',' . path +  endif +  return path +endfunction + +if !exists('b:ruby_version') && !exists('g:ruby_path') && isdirectory(expand('%:p:h')) +  let s:version_file = findfile('.ruby-version', '.;') +  if !empty(s:version_file) +    let b:ruby_version = get(readfile(s:version_file, '', 1), '') +    if !has_key(g:ruby_version_paths, b:ruby_version) +      let g:ruby_version_paths[b:ruby_version] = s:query_path(fnamemodify(s:version_file, ':p:h')) +    endif +  endif +endif + +if exists("g:ruby_path") +  let s:ruby_path = type(g:ruby_path) == type([]) ? join(g:ruby_path, ',') : g:ruby_path +elseif has_key(g:ruby_version_paths, get(b:, 'ruby_version', '')) +  let s:ruby_paths = g:ruby_version_paths[b:ruby_version] +  let s:ruby_path = s:build_path(s:ruby_paths) +else +  if !exists('g:ruby_default_path') +    if has("ruby") && has("win32") +      ruby ::VIM::command( 'let g:ruby_default_path = split("%s",",")' % $:.join(%q{,}) ) +    elseif executable('ruby') +      let g:ruby_default_path = s:query_path($HOME) +    else +      let g:ruby_default_path = map(split($RUBYLIB,':'), 'v:val ==# "." ? "" : v:val') +    endif +  endif +  let s:ruby_paths = g:ruby_default_path +  let s:ruby_path = s:build_path(s:ruby_paths) +endif + +if stridx(&l:path, s:ruby_path) == -1 +  let &l:path = s:ruby_path +endif +if exists('s:ruby_paths') && stridx(&l:tags, join(map(copy(s:ruby_paths),'v:val."/tags"'),',')) == -1 +  let &l:tags = &tags . ',' . join(map(copy(s:ruby_paths),'v:val."/tags"'),',') +endif + +if has("gui_win32") && !exists("b:browsefilter") +  let b:browsefilter = "Ruby Source Files (*.rb)\t*.rb\n" . +                     \ "All Files (*.*)\t*.*\n" +endif + +let b:undo_ftplugin = "setl fo< inc< inex< sua< def< com< cms< path< tags< kp<" +      \."| unlet! b:browsefilter b:match_ignorecase b:match_words b:match_skip" +      \."| if exists('&ofu') && has('ruby') | setl ofu< | endif" +      \."| if has('balloon_eval') && exists('+bexpr') | setl bexpr< | endif" + +if !exists("g:no_plugin_maps") && !exists("g:no_ruby_maps") +  nnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','n')<CR> +  nnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','n')<CR> +  nnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','n')<CR> +  nnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','n')<CR> +  xnoremap <silent> <buffer> [m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','b','v')<CR> +  xnoremap <silent> <buffer> ]m :<C-U>call <SID>searchsyn('\<def\>','rubyDefine','','v')<CR> +  xnoremap <silent> <buffer> [M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','b','v')<CR> +  xnoremap <silent> <buffer> ]M :<C-U>call <SID>searchsyn('\<end\>','rubyDefine','','v')<CR> + +  nnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','n')<CR> +  nnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','n')<CR> +  nnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','n')<CR> +  nnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','n')<CR> +  xnoremap <silent> <buffer> [[ :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','b','v')<CR> +  xnoremap <silent> <buffer> ]] :<C-U>call <SID>searchsyn('\<\%(class\<Bar>module\)\>','rubyModule\<Bar>rubyClass','','v')<CR> +  xnoremap <silent> <buffer> [] :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','b','v')<CR> +  xnoremap <silent> <buffer> ][ :<C-U>call <SID>searchsyn('\<end\>','rubyModule\<Bar>rubyClass','','v')<CR> + +  let b:undo_ftplugin = b:undo_ftplugin +        \."| sil! exe 'unmap <buffer> [[' | sil! exe 'unmap <buffer> ]]' | sil! exe 'unmap <buffer> []' | sil! exe 'unmap <buffer> ]['" +        \."| sil! exe 'unmap <buffer> [m' | sil! exe 'unmap <buffer> ]m' | sil! exe 'unmap <buffer> [M' | sil! exe 'unmap <buffer> ]M'" + +  if maparg('im','n') == '' +    onoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR> +    onoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR> +    xnoremap <silent> <buffer> im :<C-U>call <SID>wrap_i('[m',']M')<CR> +    xnoremap <silent> <buffer> am :<C-U>call <SID>wrap_a('[m',']M')<CR> +    let b:undo_ftplugin = b:undo_ftplugin +          \."| sil! exe 'ounmap <buffer> im' | sil! exe 'ounmap <buffer> am'" +          \."| sil! exe 'xunmap <buffer> im' | sil! exe 'xunmap <buffer> am'" +  endif + +  if maparg('iM','n') == '' +    onoremap <silent> <buffer> iM :<C-U>call <SID>wrap_i('[[','][')<CR> +    onoremap <silent> <buffer> aM :<C-U>call <SID>wrap_a('[[','][')<CR> +    xnoremap <silent> <buffer> iM :<C-U>call <SID>wrap_i('[[','][')<CR> +    xnoremap <silent> <buffer> aM :<C-U>call <SID>wrap_a('[[','][')<CR> +    let b:undo_ftplugin = b:undo_ftplugin +          \."| sil! exe 'ounmap <buffer> iM' | sil! exe 'ounmap <buffer> aM'" +          \."| sil! exe 'xunmap <buffer> iM' | sil! exe 'xunmap <buffer> aM'" +  endif + +  if maparg("\<C-]>",'n') == '' +    nnoremap <silent> <buffer> <C-]>       :<C-U>exe  v:count1."tag <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> g<C-]>      :<C-U>exe         "tjump <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> g]          :<C-U>exe       "tselect <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> <C-W>]      :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> <C-W><C-]>  :<C-U>exe v:count1."stag <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> <C-W>g<C-]> :<C-U>exe        "stjump <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> <C-W>g]     :<C-U>exe      "stselect <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> <C-W>}      :<C-U>exe          "ptag <C-R>=RubyCursorIdentifier()<CR>"<CR> +    nnoremap <silent> <buffer> <C-W>g}     :<C-U>exe        "ptjump <C-R>=RubyCursorIdentifier()<CR>"<CR> +    let b:undo_ftplugin = b:undo_ftplugin +          \."| sil! exe 'nunmap <buffer> <C-]>'| sil! exe 'nunmap <buffer> g<C-]>'| sil! exe 'nunmap <buffer> g]'" +          \."| sil! exe 'nunmap <buffer> <C-W>]'| sil! exe 'nunmap <buffer> <C-W><C-]>'" +          \."| sil! exe 'nunmap <buffer> <C-W>g<C-]>'| sil! exe 'nunmap <buffer> <C-W>g]'" +          \."| sil! exe 'nunmap <buffer> <C-W>}'| sil! exe 'nunmap <buffer> <C-W>g}'" +  endif + +  if maparg("gf",'n') == '' +    " By using findfile() rather than gf's normal behavior, we prevent +    " erroneously editing a directory. +    nnoremap <silent> <buffer> gf         :<C-U>exe <SID>gf(v:count1,"gf",'edit')<CR> +    nnoremap <silent> <buffer> <C-W>f     :<C-U>exe <SID>gf(v:count1,"\<Lt>C-W>f",'split')<CR> +    nnoremap <silent> <buffer> <C-W><C-F> :<C-U>exe <SID>gf(v:count1,"\<Lt>C-W>\<Lt>C-F>",'split')<CR> +    nnoremap <silent> <buffer> <C-W>gf    :<C-U>exe <SID>gf(v:count1,"\<Lt>C-W>gf",'tabedit')<CR> +    let b:undo_ftplugin = b:undo_ftplugin +          \."| sil! exe 'nunmap <buffer> gf' | sil! exe 'nunmap <buffer> <C-W>f' | sil! exe 'nunmap <buffer> <C-W><C-F>' | sil! exe 'nunmap <buffer> <C-W>gf'" +  endif +endif + +let &cpo = s:cpo_save +unlet s:cpo_save + +if exists("g:did_ruby_ftplugin_functions") +  finish +endif +let g:did_ruby_ftplugin_functions = 1 + +function! RubyBalloonexpr() +  if !exists('s:ri_found') +    let s:ri_found = executable('ri') +  endif +  if s:ri_found +    let line = getline(v:beval_lnum) +    let b = matchstr(strpart(line,0,v:beval_col),'\%(\w\|[:.]\)*$') +    let a = substitute(matchstr(strpart(line,v:beval_col),'^\w*\%([?!]\|\s*=\)\?'),'\s\+','','g') +    let str = b.a +    let before = strpart(line,0,v:beval_col-strlen(b)) +    let after  = strpart(line,v:beval_col+strlen(a)) +    if str =~ '^\.' +      let str = substitute(str,'^\.','#','g') +      if before =~ '\]\s*$' +        let str = 'Array'.str +      elseif before =~ '}\s*$' +        " False positives from blocks here +        let str = 'Hash'.str +      elseif before =~ "[\"'`]\\s*$" || before =~ '\$\d\+\s*$' +        let str = 'String'.str +      elseif before =~ '\$\d\+\.\d\+\s*$' +        let str = 'Float'.str +      elseif before =~ '\$\d\+\s*$' +        let str = 'Integer'.str +      elseif before =~ '/\s*$' +        let str = 'Regexp'.str +      else +        let str = substitute(str,'^#','.','') +      endif +    endif +    let str = substitute(str,'.*\.\s*to_f\s*\.\s*','Float#','') +    let str = substitute(str,'.*\.\s*to_i\%(nt\)\=\s*\.\s*','Integer#','') +    let str = substitute(str,'.*\.\s*to_s\%(tr\)\=\s*\.\s*','String#','') +    let str = substitute(str,'.*\.\s*to_sym\s*\.\s*','Symbol#','') +    let str = substitute(str,'.*\.\s*to_a\%(ry\)\=\s*\.\s*','Array#','') +    let str = substitute(str,'.*\.\s*to_proc\s*\.\s*','Proc#','') +    if str !~ '^\w' +      return '' +    endif +    silent! let res = substitute(system("ri -f rdoc -T \"".str.'"'),'\n$','','') +    if res =~ '^Nothing known about' || res =~ '^Bad argument:' || res =~ '^More than one method' +      return '' +    endif +    return res +  else +    return "" +  endif +endfunction + +function! s:searchsyn(pattern,syn,flags,mode) +  norm! m' +  if a:mode ==# 'v' +    norm! gv +  endif +  let i = 0 +  let cnt = v:count ? v:count : 1 +  while i < cnt +    let i = i + 1 +    let line = line('.') +    let col  = col('.') +    let pos = search(a:pattern,'W'.a:flags) +    while pos != 0 && s:synname() !~# a:syn +      let pos = search(a:pattern,'W'.a:flags) +    endwhile +    if pos == 0 +      call cursor(line,col) +      return +    endif +  endwhile +endfunction + +function! s:synname() +  return synIDattr(synID(line('.'),col('.'),0),'name') +endfunction + +function! s:wrap_i(back,forward) +  execute 'norm k'.a:forward +  let line = line('.') +  execute 'norm '.a:back +  if line('.') == line - 1 +    return s:wrap_a(a:back,a:forward) +  endif +  execute 'norm jV'.a:forward.'k' +endfunction + +function! s:wrap_a(back,forward) +  execute 'norm '.a:forward +  if line('.') < line('$') && getline(line('.')+1) ==# '' +    let after = 1 +  endif +  execute 'norm '.a:back +  while getline(line('.')-1) =~# '^\s*#' && line('.') +    - +  endwhile +  if exists('after') +    execute 'norm V'.a:forward.'j' +  elseif line('.') > 1 && getline(line('.')-1) =~# '^\s*$' +    execute 'norm kV'.a:forward +  else +    execute 'norm V'.a:forward +  endif +endfunction + +function! RubyCursorIdentifier() +  let asciicode    = '\%(\w\|[]})\"'."'".']\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)' +  let number       = '\%(\%(\w\|[]})\"'."'".']\s*\)\@<!-\)\=\%(\<[[:digit:]_]\+\%(\.[[:digit:]_]\+\)\=\%([Ee][[:digit:]_]\+\)\=\>\|\<0[xXbBoOdD][[:xdigit:]_]\+\>\)\|'.asciicode +  let operator     = '\%(\[\]\|<<\|<=>\|[!<>]=\=\|===\=\|[!=]\~\|>>\|\*\*\|\.\.\.\=\|=>\|[~^&|*/%+-]\)' +  let method       = '\%(\<[_a-zA-Z]\w*\>\%([?!]\|\s*=>\@!\)\=\)' +  let global       = '$\%([!$&"'."'".'*+,./:;<=>?@\`~]\|-\=\w\+\>\)' +  let symbolizable = '\%(\%(@@\=\)\w\+\>\|'.global.'\|'.method.'\|'.operator.'\)' +  let pattern      = '\C\s*\%('.number.'\|\%(:\@<!:\)\='.symbolizable.'\)' +  let [lnum, col]  = searchpos(pattern,'bcn',line('.')) +  let raw          = matchstr(getline('.')[col-1 : ],pattern) +  let stripped     = substitute(substitute(raw,'\s\+=$','=',''),'^\s*:\=','','') +  return stripped == '' ? expand("<cword>") : stripped +endfunction + +function! s:gf(count,map,edit) abort +  if getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$' +    let target = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') +    return a:edit.' %:h/'.target.'.rb' +  elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$' +    let target = matchstr(getline('.'),'\(["'']\)\.\./\zs.\{-\}\ze\1') +    return a:edit.' %:h/'.target.'.rb' +  elseif getline('.') =~# '^\s*\%(require \|load \|autoload :\w\+,\)\s*\(["'']\).*\1\s*$' +    let target = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') +  else +    let target = expand('<cfile>') +  endif +  let found = findfile(target, &path, a:count) +  if found ==# '' +    return 'norm! '.a:count.a:map +  else +    return a:edit.' '.fnameescape(found) +  endif +endfunction + +" +" Instructions for enabling "matchit" support: +" +" 1. Look for the latest "matchit" plugin at +" +"         http://www.vim.org/scripts/script.php?script_id=39 +" +"    It is also packaged with Vim, in the $VIMRUNTIME/macros directory. +" +" 2. Copy "matchit.txt" into a "doc" directory (e.g. $HOME/.vim/doc). +" +" 3. Copy "matchit.vim" into a "plugin" directory (e.g. $HOME/.vim/plugin). +" +" 4. Ensure this file (ftplugin/ruby.vim) is installed. +" +" 5. Ensure you have this line in your $HOME/.vimrc: +"         filetype plugin on +" +" 6. Restart Vim and create the matchit documentation: +" +"         :helptags ~/.vim/doc +" +"    Now you can do ":help matchit", and you should be able to use "%" on Ruby +"    keywords.  Try ":echo b:match_words" to be sure. +" +" Thanks to Mark J. Reed for the instructions.  See ":help vimrc" for the +" locations of plugin directories, etc., as there are several options, and it +" differs on Windows.  Email gsinclair@soyabean.com.au if you need help. +" + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/ftplugin/sass.vim b/ftplugin/sass.vim new file mode 100644 index 00000000..64232a08 --- /dev/null +++ b/ftplugin/sass.vim @@ -0,0 +1,22 @@ +" Vim filetype plugin +" Language:	Sass +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 Jul 26 + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") +  finish +endif +let b:did_ftplugin = 1 + +let b:undo_ftplugin = "setl cms< def< inc< inex< ofu< sua<" + +setlocal commentstring=//\ %s +setlocal define=^\\s*\\%(@mixin\\\|=\\) +setlocal includeexpr=substitute(v:fname,'\\%(.*/\\\|^\\)\\zs','_','') +setlocal omnifunc=csscomplete#CompleteCSS +setlocal suffixesadd=.sass,.scss,.css + +let &l:include = '^\s*@import\s\+\%(url(\)\=["'']\=' + +" vim:set sw=2: diff --git a/ftplugin/scss.vim b/ftplugin/scss.vim new file mode 100644 index 00000000..981fb1b8 --- /dev/null +++ b/ftplugin/scss.vim @@ -0,0 +1,12 @@ +" Vim filetype plugin +" Language:	SCSS +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 Jul 26 + +if exists("b:did_ftplugin") +  finish +endif + +runtime! ftplugin/sass.vim + +" vim:set sw=2: diff --git a/ftplugin/stylus.vim b/ftplugin/stylus.vim new file mode 100644 index 00000000..17386596 --- /dev/null +++ b/ftplugin/stylus.vim @@ -0,0 +1,61 @@ +" 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 + +" Add '-' and '#' to the what makes up a keyword. +" This means that 'e' and 'w' work properly now, for properties +" and valid variable names. +setl iskeyword+=#,- + +let b:undo_ftplugin = "setl cms< com< " +      \ " | unlet! b:browsefilter b:match_words | " . s:undo_ftplugin + +let &cpo = s:save_cpo + +" Add a Stylus command (to see if it's valid) +command! Stylus !clear; cat % | stylus + +" vim:set sw=2: diff --git a/ftplugin/textile.vim b/ftplugin/textile.vim new file mode 100644 index 00000000..a840e600 --- /dev/null +++ b/ftplugin/textile.vim @@ -0,0 +1,59 @@ +" textile.vim +" +" Tim Harper (tim.theenchanter.com) + +command! -nargs=0 TextileRenderFile call TextileRenderBufferToFile() +command! -nargs=0 TextileRenderTab call TextileRenderBufferToTab() +command! -nargs=0 TextilePreview call TextileRenderBufferToPreview() +noremap <buffer> <Leader>rp :TextilePreview<CR> +noremap <buffer> <Leader>rf :TextileRenderFile<CR> +noremap <buffer> <Leader>rt :TextileRenderTab<CR> +setlocal ignorecase +setlocal wrap +setlocal lbr + +function! TextileRender(lines) +  if (system('which ruby') == "") +    throw "Could not find ruby!" +  end + +  let text = join(a:lines, "\n") +  let html = system("ruby -e \"def e(msg); puts msg; exit 1; end; begin; require 'rubygems'; rescue LoadError; e('rubygems not found'); end; begin; require 'redcloth'; rescue LoadError; e('RedCloth gem not installed.  Run this from the terminal: sudo gem install RedCloth'); end; puts(RedCloth.new(\\$stdin.read).to_html(:textile))\"", text) +  return html +endfunction + +function! TextileRenderFile(lines, filename) +  let html = TextileRender(getbufline(bufname("%"), 1, '$')) +  let html = "<html><head><title>" . bufname("%") . "</title></head><body>\n" . html . "\n</body></html>" +  return writefile(split(html, "\n"), a:filename) +endfunction + +function! TextileRenderBufferToPreview() +  let filename = "/tmp/textile-preview.html" +  call TextileRenderFile(getbufline(bufname("%"), 1, '$'), filename) +  " Verify if browser was set +  if !exists("g:TextileBrowser") +    let g:TextileBrowser='Safari' +  endif +  " call configured browser according OS +  if !exists("g:TextileOS") || g:TextileOS == 'mac' +    call system("open -a \"".g:TextileBrowser."\" ".filename) +  else +    echo g:TextileBrowser." ".filename +    call system(g:TextileBrowser." ".filename) +  endif +endfunction + +function! TextileRenderBufferToFile() +  let filename = input("Filename:", substitute(bufname("%"), "textile$", "html", ""), "file") +  call TextileRenderFile(getbufline(bufname("%"), 1, '$'), filename) +  echo "Rendered to '" . filename . "'" +endfunction + +function! TextileRenderBufferToTab() +  let html = TextileRender(getbufline(bufname("%"), 1, '$')) +  tabnew +  call append("^", split(html, "\n")) +  set syntax=html +endfunction + diff --git a/indent/coffee.vim b/indent/coffee.vim new file mode 100644 index 00000000..49953151 --- /dev/null +++ b/indent/coffee.vim @@ -0,0 +1,418 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +if exists('b:did_indent') +  finish +endif + +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetCoffeeIndent(v:lnum) +" Make sure GetCoffeeIndent is run when these are typed so they can be +" indented or outdented. +setlocal indentkeys+=0],0),0.,=else,=when,=catch,=finally + +" If no indenting or outdenting is needed, either keep the indent of the cursor +" (use autoindent) or match the indent of the previous line. +if exists('g:coffee_indent_keep_current') +  let s:DEFAULT_LEVEL = '-1' +else +  let s:DEFAULT_LEVEL = 'indent(prevnlnum)' +endif + +" Only define the function once. +if exists('*GetCoffeeIndent') +  finish +endif + +" Keywords that begin a block +let s:BEGIN_BLOCK_KEYWORD = '\C^\%(if\|unless\|else\|for\|while\|until\|' +\                         . 'loop\|switch\|when\|try\|catch\|finally\|' +\                         . 'class\)\>\%(\s*:\)\@!' + +" An expression that uses the result of a statement +let s:COMPOUND_EXPRESSION = '\C\%([^-]-\|[^+]+\|[^/]/\|[:=*%&|^<>]\)\s*' +\                         . '\%(if\|unless\|for\|while\|until\|loop\|switch\|' +\                         . 'try\|class\)\>' + +" Combine the two above +let s:BEGIN_BLOCK = s:BEGIN_BLOCK_KEYWORD . '\|' . s:COMPOUND_EXPRESSION + +" Operators that begin a block but also count as a continuation +let s:BEGIN_BLOCK_OP = '[([{:=]$' + +" Begins a function block +let s:FUNCTION = '[-=]>$' + +" Operators that continue a line onto the next line +let s:CONTINUATION_OP = '\C\%(\<\%(is\|isnt\|and\|or\)\>\|' +\                     . '[^-]-\|[^+]+\|[^-=]>\|[^.]\.\|[<*/%&|^,]\)$' + +" Ancestor operators that prevent continuation indenting +let s:CONTINUATION = s:CONTINUATION_OP . '\|' . s:BEGIN_BLOCK_OP + +" A closing bracket by itself on a line followed by a continuation +let s:BRACKET_CONTINUATION = '^\s*[}\])]\s*' . s:CONTINUATION_OP + +" A continuation dot access +let s:DOT_ACCESS = '^\.' + +" Keywords that break out of a block +let s:BREAK_BLOCK_OP = '\C^\%(return\|break\|continue\|throw\)\>' + +" A condition attached to the end of a statement +let s:POSTFIX_CONDITION = '\C\S\s\+\zs\<\%(if\|unless\|when\|while\|until\)\>' + +" A then contained in brackets +let s:CONTAINED_THEN = '\C[(\[].\{-}\<then\>.\{-\}[)\]]' + +" An else with a condition attached +let s:ELSE_COND = '\C^\s*else\s\+\<\%(if\|unless\)\>' + +" A single-line else statement (without a condition attached) +let s:SINGLE_LINE_ELSE = '\C^else\s\+\%(\<\%(if\|unless\)\>\)\@!' + +" Pairs of starting and ending keywords, with an initial pattern to match +let s:KEYWORD_PAIRS = [ +\  ['\C^else\>', '\C\<\%(if\|unless\|when\|else\s\+\%(if\|unless\)\)\>', +\   '\C\<else\>'], +\  ['\C^catch\>', '\C\<try\>', '\C\<catch\>'], +\  ['\C^finally\>', '\C\<try\>', '\C\<finally\>'] +\] + +" Pairs of starting and ending brackets +let s:BRACKET_PAIRS = {']': '\[', '}': '{', ')': '('} + +" Max lines to look back for a match +let s:MAX_LOOKBACK = 50 + +" Syntax names for strings +let s:SYNTAX_STRING = 'coffee\%(String\|AssignString\|Embed\|Regex\|Heregex\|' +\                   . 'Heredoc\)' + +" Syntax names for comments +let s:SYNTAX_COMMENT = 'coffee\%(Comment\|BlockComment\|HeregexComment\)' + +" Syntax names for strings and comments +let s:SYNTAX_STRING_COMMENT = s:SYNTAX_STRING . '\|' . s:SYNTAX_COMMENT + +" Get the linked syntax name of a character. +function! s:SyntaxName(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') +endfunction + +" Check if a character is in a comment. +function! s:IsComment(lnum, col) +  return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_COMMENT +endfunction + +" Check if a character is in a string. +function! s:IsString(lnum, col) +  return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING +endfunction + +" Check if a character is in a comment or string. +function! s:IsCommentOrString(lnum, col) +  return s:SyntaxName(a:lnum, a:col) =~ s:SYNTAX_STRING_COMMENT +endfunction + +" Search a line for a regex until one is found outside a string or comment. +function! s:SearchCode(lnum, regex) +  " Start at the first column and look for an initial match (including at the +  " cursor.) +  call cursor(a:lnum, 1) +  let pos = search(a:regex, 'c', a:lnum) + +  while pos +    if !s:IsCommentOrString(a:lnum, col('.')) +      return 1 +    endif + +    " Move to the match and continue searching (don't accept matches at the +    " cursor.) +    let pos = search(a:regex, '', a:lnum) +  endwhile + +  return 0 +endfunction + +" Search for the nearest previous line that isn't a comment. +function! s:GetPrevNormalLine(startlnum) +  let curlnum = a:startlnum + +  while curlnum +    let curlnum = prevnonblank(curlnum - 1) + +    " Return the line if the first non-whitespace character isn't a comment. +    if !s:IsComment(curlnum, indent(curlnum) + 1) +      return curlnum +    endif +  endwhile + +  return 0 +endfunction + +function! s:SearchPair(startlnum, lookback, skip, open, close) +  " Go to the first column so a:close will be matched even if it's at the +  " beginning of the line. +  call cursor(a:startlnum, 1) +  return searchpair(a:open, '', a:close, 'bnW', a:skip, max([1, a:lookback])) +endfunction + +" Skip if a match +"  - is in a string or comment +"  - is a single-line statement that isn't immediately +"    adjacent +"  - has a postfix condition and isn't an else statement or compound +"    expression +function! s:ShouldSkip(startlnum, lnum, col) +  return s:IsCommentOrString(a:lnum, a:col) || +  \      s:SearchCode(a:lnum, '\C\<then\>') && a:startlnum - a:lnum > 1 || +  \      s:SearchCode(a:lnum, s:POSTFIX_CONDITION) && +  \      getline(a:lnum) !~ s:ELSE_COND && +  \     !s:SearchCode(a:lnum, s:COMPOUND_EXPRESSION) +endfunction + +" Search for the nearest and farthest match for a keyword pair. +function! s:SearchMatchingKeyword(startlnum, open, close) +  let skip = 's:ShouldSkip(' . a:startlnum . ", line('.'), line('.'))" + +  " Search for the nearest match. +  let nearestlnum = s:SearchPair(a:startlnum, a:startlnum - s:MAX_LOOKBACK, +  \                              skip, a:open, a:close) + +  if !nearestlnum +    return [] +  endif + +  " Find the nearest previous line with indent less than or equal to startlnum. +  let ind = indent(a:startlnum) +  let lookback = s:GetPrevNormalLine(a:startlnum) + +  while lookback && indent(lookback) > ind +    let lookback = s:GetPrevNormalLine(lookback) +  endwhile + +  " Search for the farthest match. If there are no other matches, then the +  " nearest match is also the farthest one. +  let matchlnum = nearestlnum + +  while matchlnum +    let lnum = matchlnum +    let matchlnum = s:SearchPair(matchlnum, lookback, skip, a:open, a:close) +  endwhile + +  return [nearestlnum, lnum] +endfunction + +" Strip a line of a trailing comment and surrounding whitespace. +function! s:GetTrimmedLine(lnum) +  " Try to find a comment starting at the first column. +  call cursor(a:lnum, 1) +  let pos = search('#', 'c', a:lnum) + +  " Keep searching until a comment is found or search returns 0. +  while pos +    if s:IsComment(a:lnum, col('.')) +      break +    endif + +    let pos = search('#', '', a:lnum) +  endwhile + +  if !pos +    " No comment was found so use the whole line. +    let line = getline(a:lnum) +  else +    " Subtract 1 to get to the column before the comment and another 1 for +    " column indexing -> zero-based indexing. +    let line = getline(a:lnum)[:col('.') - 2] +  endif + +  return substitute(substitute(line, '^\s\+', '', ''), +  \                                  '\s\+$', '', '') +endfunction + +" Get the indent policy when no special rules are used. +function! s:GetDefaultPolicy(curlnum) +  " Check whether equalprg is being ran on existing lines. +  if strlen(getline(a:curlnum)) == indent(a:curlnum) +    " If not indenting an existing line, use the default policy. +    return s:DEFAULT_LEVEL +  else +    " Otherwise let autoindent determine what to do with an existing line. +    return '-1' +  endif +endfunction + +function! GetCoffeeIndent(curlnum) +  " Get the previous non-blank line (may be a comment.) +  let prevlnum = prevnonblank(a:curlnum - 1) + +  " Bail if there's no code before. +  if !prevlnum +    return -1 +  endif + +  " Bail if inside a multiline string. +  if s:IsString(a:curlnum, 1) +    let prevnlnum = prevlnum +    exec 'return' s:GetDefaultPolicy(a:curlnum) +  endif + +  " Get the code part of the current line. +  let curline = s:GetTrimmedLine(a:curlnum) +  " Get the previous non-comment line. +  let prevnlnum = s:GetPrevNormalLine(a:curlnum) + +  " Check if the current line is the closing bracket in a bracket pair. +  if has_key(s:BRACKET_PAIRS, curline[0]) +    " Search for a matching opening bracket. +    let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, +    \                            "s:IsCommentOrString(line('.'), col('.'))", +    \                            s:BRACKET_PAIRS[curline[0]], curline[0]) + +    if matchlnum +      " Match the indent of the opening bracket. +      return indent(matchlnum) +    else +      " No opening bracket found (bad syntax), so bail. +      exec 'return' s:GetDefaultPolicy(a:curlnum) +    endif +  endif + +  " Check if the current line is the closing keyword in a keyword pair. +  for pair in s:KEYWORD_PAIRS +    if curline =~ pair[0] +      " Find the nearest and farthest matches within the same indent level. +      let matches = s:SearchMatchingKeyword(a:curlnum, pair[1], pair[2]) + +      if len(matches) +        " Don't force indenting/outdenting as long as line is already lined up +        " with a valid match +        return max([min([indent(a:curlnum), indent(matches[0])]), +        \           indent(matches[1])]) +      else +        " No starting keyword found (bad syntax), so bail. +        exec 'return' s:GetDefaultPolicy(a:curlnum) +      endif +    endif +  endfor + +  " Check if the current line is a `when` and not the first in a switch block. +  if curline =~ '\C^when\>' && !s:SearchCode(prevnlnum, '\C\<switch\>') +    " Look back for a `when`. +    while prevnlnum +      if getline(prevnlnum) =~ '\C^\s*when\>' +        " Indent to match the found `when`, but don't force indenting (for when +        " indenting nested switch blocks.) +        return min([indent(a:curlnum), indent(prevnlnum)]) +      endif + +      let prevnlnum = s:GetPrevNormalLine(prevnlnum) +    endwhile + +    " No matching `when` found (bad syntax), so bail. +    exec 'return' s:GetDefaultPolicy(a:curlnum) +  endif + +  " If the previous line is a comment, use its indentation, but don't force +  " indenting. +  if prevlnum != prevnlnum +    return min([indent(a:curlnum), indent(prevlnum)]) +  endif + +  let prevline = s:GetTrimmedLine(prevnlnum) + +  " Always indent after these operators. +  if prevline =~ s:BEGIN_BLOCK_OP +    return indent(prevnlnum) + shiftwidth() +  endif + +  " Indent if the previous line starts a function block, but don't force +  " indenting if the line is non-blank (for empty function bodies.) +  if prevline =~ s:FUNCTION +    if strlen(getline(a:curlnum)) > indent(a:curlnum) +      return min([indent(prevnlnum) + shiftwidth(), indent(a:curlnum)]) +    else +      return indent(prevnlnum) + shiftwidth() +    endif +  endif + +  " Check if continuation indenting is needed. If the line ends in a slash, make +  " sure it isn't a regex. +  if prevline =~ s:CONTINUATION_OP && +  \  !(prevline =~ '/$' && s:IsString(prevnlnum, col([prevnlnum, '$']) - 1)) +    " Don't indent if the continuation follows a closing bracket. +    if prevline =~ s:BRACKET_CONTINUATION +      exec 'return' s:GetDefaultPolicy(a:curlnum) +    endif + +    let prevprevnlnum = s:GetPrevNormalLine(prevnlnum) + +    " Don't indent if not the first continuation. +    if prevprevnlnum && s:GetTrimmedLine(prevprevnlnum) =~ s:CONTINUATION +      exec 'return' s:GetDefaultPolicy(a:curlnum) +    endif + +    " Continuation indenting seems to vary between programmers, so if the line +    " is non-blank, don't override the indentation +    if strlen(getline(a:curlnum)) > indent(a:curlnum) +      exec 'return' s:GetDefaultPolicy(a:curlnum) +    endif + +    " Otherwise indent a level. +    return indent(prevnlnum) + shiftwidth() +  endif + +  " Check if the previous line starts with a keyword that begins a block. +  if prevline =~ s:BEGIN_BLOCK +    " Indent if the current line doesn't start with `then` and the previous line +    " isn't a single-line statement. +    if curline !~ '\C^\<then\>' && !s:SearchCode(prevnlnum, '\C\<then\>') && +    \  prevline !~ s:SINGLE_LINE_ELSE +      return indent(prevnlnum) + shiftwidth() +    else +      exec 'return' s:GetDefaultPolicy(a:curlnum) +    endif +  endif + +  " Indent a dot access if it's the first. +  if curline =~ s:DOT_ACCESS +    if prevline !~ s:DOT_ACCESS +      return indent(prevnlnum) + shiftwidth() +    else +      exec 'return' s:GetDefaultPolicy(a:curlnum) +    endif +  endif + +  " Outdent if a keyword breaks out of a block as long as it doesn't have a +  " postfix condition (and the postfix condition isn't a single-line statement.) +  if prevline =~ s:BREAK_BLOCK_OP +    if !s:SearchCode(prevnlnum, s:POSTFIX_CONDITION) || +    \   s:SearchCode(prevnlnum, '\C\<then\>') && +    \  !s:SearchCode(prevnlnum, s:CONTAINED_THEN) +      " Don't force indenting. +      return min([indent(a:curlnum), indent(prevnlnum) - shiftwidth()]) +    else +      exec 'return' s:GetDefaultPolicy(a:curlnum) +    endif +  endif + +  " Check if inside brackets. +  let matchlnum = s:SearchPair(a:curlnum, a:curlnum - s:MAX_LOOKBACK, +  \                            "s:IsCommentOrString(line('.'), col('.'))", +  \                            '\[\|(\|{', '\]\|)\|}') + +  " If inside brackets, indent relative to the brackets, but don't outdent an +  " already indented line. +  if matchlnum +    return max([indent(a:curlnum), indent(matchlnum) + shiftwidth()]) +  endif + +  " No special rules applied, so use the default policy. +  exec 'return' s:GetDefaultPolicy(a:curlnum) +endfunction diff --git a/indent/cucumber.vim b/indent/cucumber.vim new file mode 100644 index 00000000..802d2243 --- /dev/null +++ b/indent/cucumber.vim @@ -0,0 +1,74 @@ +" Vim indent file +" Language:	Cucumber +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 May 21 + +if exists("b:did_indent") +  finish +endif +let b:did_indent = 1 + +setlocal autoindent +setlocal indentexpr=GetCucumberIndent() +setlocal indentkeys=o,O,*<Return>,<:>,0<Bar>,0#,=,!^F + +let b:undo_indent = 'setl ai< inde< indk<' + +" Only define the function once. +if exists("*GetCucumberIndent") +  finish +endif + +function! s:syn(lnum) +  return synIDattr(synID(a:lnum,1+indent(a:lnum),1),'name') +endfunction + +function! GetCucumberIndent() +  let line  = getline(prevnonblank(v:lnum-1)) +  let cline = getline(v:lnum) +  let nline = getline(nextnonblank(v:lnum+1)) +  let syn = s:syn(prevnonblank(v:lnum-1)) +  let csyn = s:syn(v:lnum) +  let nsyn = s:syn(nextnonblank(v:lnum+1)) +  if csyn ==# 'cucumberFeature' || cline =~# '^\s*Feature:' +    " feature heading +    return 0 +  elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):' +    " examples heading +    return 2 * &sw +  elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' +    " background, scenario or outline heading +    return &sw +  elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:' +    " line after feature heading +    return &sw +  elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):' +    " line after examples heading +    return 3 * &sw +  elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' +    " line after background, scenario or outline heading +    return 2 * &sw +  elseif cline =~# '^\s*[@#]' && (nsyn == 'cucumberFeature' || nline =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0) +    " tag or comment before a feature heading +    return 0 +  elseif cline =~# '^\s*@' +    " other tags +    return &sw +  elseif cline =~# '^\s*[#|]' && line =~# '^\s*|' +    " mid-table +    " preserve indent +    return indent(prevnonblank(v:lnum-1)) +  elseif cline =~# '^\s*|' && line =~# '^\s*[^|]' +    " first line of a table, relative indent +    return indent(prevnonblank(v:lnum-1)) + &sw +  elseif cline =~# '^\s*[^|]' && line =~# '^\s*|' +    " line after a table, relative unindent +    return indent(prevnonblank(v:lnum-1)) - &sw +  elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && (nsyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || nline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):') +    " comments on scenarios +    return &sw +  endif +  return indent(prevnonblank(v:lnum-1)) +endfunction + +" vim:set sts=2 sw=2: diff --git a/indent/eruby.vim b/indent/eruby.vim new file mode 100644 index 00000000..19109ceb --- /dev/null +++ b/indent/eruby.vim @@ -0,0 +1,91 @@ +" Vim indent file +" Language:		eRuby +" Maintainer:		Tim Pope <vimNOSPAM@tpope.org> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +if exists("b:did_indent") +  finish +endif + +runtime! indent/ruby.vim +unlet! b:did_indent +setlocal indentexpr= + +if exists("b:eruby_subtype") +  exe "runtime! indent/".b:eruby_subtype.".vim" +else +  runtime! indent/html.vim +endif +unlet! b:did_indent + +if &l:indentexpr == '' +  if &l:cindent +    let &l:indentexpr = 'cindent(v:lnum)' +  else +    let &l:indentexpr = 'indent(prevnonblank(v:lnum-1))' +  endif +endif +let b:eruby_subtype_indentexpr = &l:indentexpr + +let b:did_indent = 1 + +setlocal indentexpr=GetErubyIndent() +setlocal indentkeys=o,O,*<Return>,<>>,{,},0),0],o,O,!^F,=end,=else,=elsif,=rescue,=ensure,=when + +" Only define the function once. +if exists("*GetErubyIndent") +  finish +endif + +function! GetErubyIndent(...) +  if a:0 && a:1 == '.' +    let v:lnum = line('.') +  elseif a:0 && a:1 =~ '^\d' +    let v:lnum = a:1 +  endif +  let vcol = col('.') +  call cursor(v:lnum,1) +  let inruby = searchpair('<%','','%>','W') +  call cursor(v:lnum,vcol) +  if inruby && getline(v:lnum) !~ '^<%\|^\s*[-=]\=%>' +    let ind = GetRubyIndent(v:lnum) +  else +    exe "let ind = ".b:eruby_subtype_indentexpr + +    " Workaround for Andy Wokula's HTML indent +    if b:eruby_subtype_indentexpr =~# '^HtmlIndent(' +	  \ && exists('b:indent') +	  \ && type(b:indent) == type({}) +	  \ && has_key(b:indent, 'lnum') +      " Force HTML indent to not keep state +      let b:indent.lnum = -1 +    endif +  endif +  let lnum = prevnonblank(v:lnum-1) +  let line = getline(lnum) +  let cline = getline(v:lnum) +  if cline =~# '^\s*<%[-=]\=\s*\%(}\|end\|else\|\%(ensure\|rescue\|elsif\|when\).\{-\}\)\s*\%([-=]\=%>\|$\)' +    let ind = ind - &sw +  endif +  if line =~# '\S\s*<%[-=]\=\s*\%(}\|end\).\{-\}\s*\%([-=]\=%>\|$\)' +    let ind = ind - &sw +  endif +  if line =~# '\%({\|\<do\)\%(\s*|[^|]*|\)\=\s*[-=]\=%>' +    let ind = ind + &sw +  elseif line =~# '<%[-=]\=\s*\%(module\|class\|def\|if\|for\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure\|rescue\)\>.*%>' +    let ind = ind + &sw +  endif +  if line =~# '^\s*<%[=#-]\=\s*$' && cline !~# '^\s*end\>' +    let ind = ind + &sw +  endif +  if line !~# '^\s*<%' && line =~# '%>\s*$' +    let ind = ind - &sw +  endif +  if cline =~# '^\s*[-=]\=%>\s*$' +    let ind = ind - &sw +  endif +  return ind +endfunction + +" vim:set sw=2 sts=2 ts=8 noet: diff --git a/indent/haml.vim b/indent/haml.vim new file mode 100644 index 00000000..710aefc0 --- /dev/null +++ b/indent/haml.vim @@ -0,0 +1,73 @@ +" Vim indent file +" Language:	Haml +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 May 21 + +if exists("b:did_indent") +  finish +endif +runtime! indent/ruby.vim +unlet! b:did_indent +let b:did_indent = 1 + +setlocal autoindent sw=2 et +setlocal indentexpr=GetHamlIndent() +setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when + +" Only define the function once. +if exists("*GetHamlIndent") +  finish +endif + +let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)' +let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' + +if !exists('g:haml_self_closing_tags') +  let g:haml_self_closing_tags = 'base|link|meta|br|hr|img|input' +endif + +function! GetHamlIndent() +  let lnum = prevnonblank(v:lnum-1) +  if lnum == 0 +    return 0 +  endif +  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 cline =~# '\v^-\s*%(elsif|else|when)>' +    let indent = cindent < indent ? cindent : indent - &sw +  endif +  let increase = indent + &sw +  if indent == indent(lnum) +    let indent = cindent <= indent ? -1 : increase +  endif + +  let group = synIDattr(synID(lnum,lastcol,1),'name') + +  if line =~ '^!!!' +    return indent +  elseif line =~ '^/\%(\[[^]]*\]\)\=$' +    return increase +  elseif group == 'hamlFilter' +    return increase +  elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)' +    return increase +  elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$' +    return increase +  elseif line == '-#' +    return increase +  elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^%\v%('.g:haml_self_closing_tags.')>' +    return indent +  elseif group =~? '\v^%(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$' +    return increase +  elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter' +    return GetRubyIndent() +  else +    return indent +  endif +endfunction + +" vim:set sw=2: diff --git a/indent/haskell.vim b/indent/haskell.vim new file mode 100644 index 00000000..4e6a1eff --- /dev/null +++ b/indent/haskell.vim @@ -0,0 +1,85 @@ +" Vim indent file +" Language:     Haskell +" Author:       motemen <motemen@gmail.com> +" Version:      0.1 +" Last Change:  2007-07-25 +" +" Modify g:haskell_indent_if and g:haskell_indent_case to +" change indentation for `if'(default 3) and `case'(default 5). +" Example (in .vimrc): +" > let g:haskell_indent_if = 2 + +if exists('b:did_indent') +    finish +endif + +let b:did_indent = 1 + +if !exists('g:haskell_indent_if') +    " if bool +    " >>>then ... +    " >>>else ... +    let g:haskell_indent_if = 2 +endif + +if !exists('g:haskell_indent_case') +    " case xs of +    " >>>>>[] -> ... +    " >>>>>(y:ys) -> ... +    let g:haskell_indent_case = 2 +endif + +setlocal indentexpr=GetHaskellIndent() +setlocal indentkeys=!^F,o,O + +function! GetHaskellIndent() +    let line = substitute(getline(getpos('.')[1] - 1), '\t', repeat(' ', &tabstop), 'g') + +    if line =~ '[!#$%&*+./<=>?@\\^|~-]$\|\<do$' +        return match(line, '\s*where \zs\|\S') + &shiftwidth +    endif + +    if line =~ '{$' +        return match(line, '\s*where \zs\|\S') + &shiftwidth +    endif + +    if line =~ '^\(instance\|class\).*\&.*where$' +        return &shiftwidth +    endif + +    if line =~ ')$' +        let pos = getpos('.') +        normal k$ +        let paren_end   = getpos('.') +        normal % +        let paren_begin = getpos('.') +        call setpos('.', pos) +        if paren_begin[1] != paren_end[1] +            return paren_begin[2] - 1 +        endif +    endif + +    if line !~ '\<else\>' +        let s = match(line, '\<if\>.*\&.*\zs\<then\>') +        if s > 0 +            return s +        endif + +        let s = match(line, '\<if\>') +        if s > 0 +            return s + g:haskell_indent_if +        endif +    endif + +    let s = match(line, '\<do\s\+\zs[^{]\|\<where\s\+\zs\w\|\<let\s\+\zs\S\|^\s*\zs|\s') +    if s > 0 +        return s +    endif + +    let s = match(line, '\<case\>') +    if s > 0 +        return s + g:haskell_indent_case +    endif + +    return match(line, '\S') +endfunction
\ No newline at end of file diff --git a/indent/javascript.vim b/indent/javascript.vim new file mode 100644 index 00000000..29fba2ba --- /dev/null +++ b/indent/javascript.vim @@ -0,0 +1,439 @@ +" Vim indent file +" Language: Javascript +" Acknowledgement: Based off of vim-ruby maintained by Nikolai Weibull http://vim-ruby.rubyforge.org + +" 0. Initialization {{{1 +" ================= + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") +  finish +endif +let b:did_indent = 1 + +setlocal nosmartindent + +" Now, set up our indentation expression and keys that trigger it. +setlocal indentexpr=GetJavascriptIndent() +setlocal indentkeys=0{,0},0),0],0\,,!^F,o,O,e + +" Only define the function once. +if exists("*GetJavascriptIndent") +  finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" 1. Variables {{{1 +" ============ + +let s:js_keywords = '^\s*\(break\|case\|catch\|continue\|debugger\|default\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)' + +" Regex of syntax group names that are or delimit string or are comments. +let s:syng_strcom = 'string\|regex\|comment\c' + +" Regex of syntax group names that are strings. +let s:syng_string = 'regex\c' + +" Regex of syntax group names that are strings or documentation. +let s:syng_multiline = 'comment\c' + +" Regex of syntax group names that are line comment. +let s:syng_linecom = 'linecomment\c' + +" Expression used to check whether we should skip a match with searchpair(). +let s:skip_expr = "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" + +let s:line_term = '\s*\%(\%(\/\/\).*\)\=$' + +" Regex that defines continuation lines, not including (, {, or [. +let s:continuation_regex = '\%([\\*+/.:]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)' . s:line_term + +" Regex that defines continuation lines. +" TODO: this needs to deal with if ...: and so on +let s:msl_regex = '\%([\\*+/.:([]\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)' . s:line_term + +let s:one_line_scope_regex = '\<\%(if\|else\|for\|while\)\>[^{;]*' . s:line_term + +" Regex that defines blocks. +let s:block_regex = '\%([{[]\)\s*\%(|\%([*@]\=\h\w*,\=\s*\)\%(,\s*[*@]\=\h\w*\)*|\)\=' . s:line_term + +let s:var_stmt = '^\s*var' + +let s:comma_first = '^\s*,' +let s:comma_last = ',\s*$' + +let s:ternary = '^\s\+[?|:]' +let s:ternary_q = '^\s\+?' + +" 2. Auxiliary Functions {{{1 +" ====================== + +" Check if the character at lnum:col is inside a string, comment, or is ascii. +function s:IsInStringOrComment(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom +endfunction + +" Check if the character at lnum:col is inside a string. +function s:IsInString(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string +endfunction + +" Check if the character at lnum:col is inside a multi-line comment. +function s:IsInMultilineComment(lnum, col) +  return !s:IsLineComment(a:lnum, a:col) && synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_multiline +endfunction + +" Check if the character at lnum:col is a line comment. +function s:IsLineComment(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_linecom +endfunction + +" Find line above 'lnum' that isn't empty, in a comment, or in a string. +function s:PrevNonBlankNonString(lnum) +  let in_block = 0 +  let lnum = prevnonblank(a:lnum) +  while lnum > 0 +    " Go in and out of blocks comments as necessary. +    " If the line isn't empty (with opt. comment) or in a string, end search. +    let line = getline(lnum) +    if line =~ '/\*' +      if in_block +        let in_block = 0 +      else +        break +      endif +    elseif !in_block && line =~ '\*/' +      let in_block = 1 +    elseif !in_block && line !~ '^\s*\%(//\).*$' && !(s:IsInStringOrComment(lnum, 1) && s:IsInStringOrComment(lnum, strlen(line))) +      break +    endif +    let lnum = prevnonblank(lnum - 1) +  endwhile +  return lnum +endfunction + +" Find line above 'lnum' that started the continuation 'lnum' may be part of. +function s:GetMSL(lnum, in_one_line_scope) +  " Start on the line we're at and use its indent. +  let msl = a:lnum +  let lnum = s:PrevNonBlankNonString(a:lnum - 1) +  while lnum > 0 +    " If we have a continuation line, or we're in a string, use line as MSL. +    " Otherwise, terminate search as we have found our MSL already. +    let line = getline(lnum) +    let col = match(line, s:msl_regex) + 1 +    if (col > 0 && !s:IsInStringOrComment(lnum, col)) || s:IsInString(lnum, strlen(line)) +      let msl = lnum +    else +      " Don't use lines that are part of a one line scope as msl unless the +      " flag in_one_line_scope is set to 1 +      " +      if a:in_one_line_scope +        break +      end +      let msl_one_line = s:Match(lnum, s:one_line_scope_regex) +      if msl_one_line == 0 +        break +      endif +    endif +    let lnum = s:PrevNonBlankNonString(lnum - 1) +  endwhile +  return msl +endfunction + +function s:RemoveTrailingComments(content) +  let single = '\/\/\(.*\)\s*$' +  let multi = '\/\*\(.*\)\*\/\s*$' +  return substitute(substitute(a:content, single, '', ''), multi, '', '') +endfunction + +" Find if the string is inside var statement (but not the first string) +function s:InMultiVarStatement(lnum) +  let lnum = s:PrevNonBlankNonString(a:lnum - 1) + +"  let type = synIDattr(synID(lnum, indent(lnum) + 1, 0), 'name') + +  " loop through previous expressions to find a var statement +  while lnum > 0 +    let line = getline(lnum) + +    " if the line is a js keyword +    if (line =~ s:js_keywords) +      " check if the line is a var stmt +      " if the line has a comma first or comma last then we can assume that we +      " are in a multiple var statement +      if (line =~ s:var_stmt) +        return lnum +      endif + +      " other js keywords, not a var +      return 0 +    endif + +    let lnum = s:PrevNonBlankNonString(lnum - 1) +  endwhile + +  " beginning of program, not a var +  return 0 +endfunction + +" Find line above with beginning of the var statement or returns 0 if it's not +" this statement +function s:GetVarIndent(lnum) +  let lvar = s:InMultiVarStatement(a:lnum) +  let prev_lnum = s:PrevNonBlankNonString(a:lnum - 1) + +  if lvar +    let line = s:RemoveTrailingComments(getline(prev_lnum)) + +    " if the previous line doesn't end in a comma, return to regular indent +    if (line !~ s:comma_last) +      return indent(prev_lnum) - &sw +    else +      return indent(lvar) + &sw +    endif +  endif + +  return -1 +endfunction + + +" Check if line 'lnum' has more opening brackets than closing ones. +function s:LineHasOpeningBrackets(lnum) +  let open_0 = 0 +  let open_2 = 0 +  let open_4 = 0 +  let line = getline(a:lnum) +  let pos = match(line, '[][(){}]', 0) +  while pos != -1 +    if !s:IsInStringOrComment(a:lnum, pos + 1) +      let idx = stridx('(){}[]', line[pos]) +      if idx % 2 == 0 +        let open_{idx} = open_{idx} + 1 +      else +        let open_{idx - 1} = open_{idx - 1} - 1 +      endif +    endif +    let pos = match(line, '[][(){}]', pos + 1) +  endwhile +  return (open_0 > 0) . (open_2 > 0) . (open_4 > 0) +endfunction + +function s:Match(lnum, regex) +  let col = match(getline(a:lnum), a:regex) + 1 +  return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0 +endfunction + +function s:IndentWithContinuation(lnum, ind, width) +  " Set up variables to use and search for MSL to the previous line. +  let p_lnum = a:lnum +  let lnum = s:GetMSL(a:lnum, 1) +  let line = getline(lnum) + +  " If the previous line wasn't a MSL and is continuation return its indent. +  " TODO: the || s:IsInString() thing worries me a bit. +  if p_lnum != lnum +    if s:Match(p_lnum,s:continuation_regex)||s:IsInString(p_lnum,strlen(line)) +      return a:ind +    endif +  endif + +  " Set up more variables now that we know we aren't continuation bound. +  let msl_ind = indent(lnum) + +  " If the previous line ended with [*+/.-=], start a continuation that +  " indents an extra level. +  if s:Match(lnum, s:continuation_regex) +    if lnum == p_lnum +      return msl_ind + a:width +    else +      return msl_ind +    endif +  endif + +  return a:ind +endfunction + +function s:InOneLineScope(lnum) +  let msl = s:GetMSL(a:lnum, 1) +  if msl > 0 && s:Match(msl, s:one_line_scope_regex) +    return msl +  endif +  return 0 +endfunction + +function s:ExitingOneLineScope(lnum) +  let msl = s:GetMSL(a:lnum, 1) +  if msl > 0 +    " if the current line is in a one line scope .. +    if s:Match(msl, s:one_line_scope_regex) +      return 0 +    else +      let prev_msl = s:GetMSL(msl - 1, 1) +      if s:Match(prev_msl, s:one_line_scope_regex) +        return prev_msl +      endif +    endif +  endif +  return 0 +endfunction + +" 3. GetJavascriptIndent Function {{{1 +" ========================= + +function GetJavascriptIndent() +  " 3.1. Setup {{{2 +  " ---------- + +  " Set up variables for restoring position in file.  Could use v:lnum here. +  let vcol = col('.') + +  " 3.2. Work on the current line {{{2 +  " ----------------------------- + +  let ind = -1 +  " Get the current line. +  let line = getline(v:lnum) +  " previous nonblank line number +  let prevline = prevnonblank(v:lnum - 1) + +  " If we got a closing bracket on an empty line, find its match and indent +  " according to it.  For parentheses we indent to its column - 1, for the +  " others we indent to the containing line's MSL's level.  Return -1 if fail. +  let col = matchend(line, '^\s*[],})]') +  if col > 0 && !s:IsInStringOrComment(v:lnum, col) +    call cursor(v:lnum, col) + +    let lvar = s:InMultiVarStatement(v:lnum) +    if lvar +      let prevline_contents = s:RemoveTrailingComments(getline(prevline)) + +      " check for comma first +      if (line[col - 1] =~ ',') +        " if the previous line ends in comma or semicolon don't indent +        if (prevline_contents =~ '[;,]\s*$') +          return indent(s:GetMSL(line('.'), 0)) +        " get previous line indent, if it's comma first return prevline indent +        elseif (prevline_contents =~ s:comma_first) +          return indent(prevline) +        " otherwise we indent 1 level +        else +          return indent(lvar) + &sw +        endif +      endif +    endif + + +    let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2) +    if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0 +      if line[col-1]==')' && col('.') != col('$') - 1 +        let ind = virtcol('.')-1 +      else +        let ind = indent(s:GetMSL(line('.'), 0)) +      endif +    endif +    return ind +  endif + +  " If the line is comma first, dedent 1 level +  if (getline(prevline) =~ s:comma_first) +    return indent(prevline) - &sw +  endif + +  if (line =~ s:ternary) +    if (getline(prevline) =~ s:ternary_q) +      return indent(prevline) +    else +      return indent(prevline) + &sw +    endif +  endif + +  " If we are in a multi-line comment, cindent does the right thing. +  if s:IsInMultilineComment(v:lnum, 1) && !s:IsLineComment(v:lnum, 1) +    return cindent(v:lnum) +  endif + +  " Check for multiple var assignments +"  let var_indent = s:GetVarIndent(v:lnum) +"  if var_indent >= 0 +"    return var_indent +"  endif + +  " 3.3. Work on the previous line. {{{2 +  " ------------------------------- + +  " If the line is empty and the previous nonblank line was a multi-line +  " comment, use that comment's indent. Deduct one char to account for the +  " space in ' */'. +  if line =~ '^\s*$' && s:IsInMultilineComment(prevline, 1) +    return indent(prevline) - 1 +  endif + +  " Find a non-blank, non-multi-line string line above the current line. +  let lnum = s:PrevNonBlankNonString(v:lnum - 1) + +  " If the line is empty and inside a string, use the previous line. +  if line =~ '^\s*$' && lnum != prevline +    return indent(prevnonblank(v:lnum)) +  endif + +  " At the start of the file use zero indent. +  if lnum == 0 +    return 0 +  endif + +  " Set up variables for current line. +  let line = getline(lnum) +  let ind = indent(lnum) + +  " If the previous line ended with a block opening, add a level of indent. +  if s:Match(lnum, s:block_regex) +    return indent(s:GetMSL(lnum, 0)) + &sw +  endif + +  " If the previous line contained an opening bracket, and we are still in it, +  " add indent depending on the bracket type. +  if line =~ '[[({]' +    let counts = s:LineHasOpeningBrackets(lnum) +    if counts[0] == '1' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 +      if col('.') + 1 == col('$') +        return ind + &sw +      else +        return virtcol('.') +      endif +    elseif counts[1] == '1' || counts[2] == '1' +      return ind + &sw +    else +      call cursor(v:lnum, vcol) +    end +  endif + +  " 3.4. Work on the MSL line. {{{2 +  " -------------------------- + +  let ind_con = ind +  let ind = s:IndentWithContinuation(lnum, ind_con, &sw) + +  " }}}2 +  " +  " +  let ols = s:InOneLineScope(lnum) +  if ols > 0 +    let ind = ind + &sw +  else +    let ols = s:ExitingOneLineScope(lnum) +    while ols > 0 && ind > 0 +      let ind = ind - &sw +      let ols = s:InOneLineScope(ols - 1) +    endwhile +  endif + +  return ind +endfunction + +" }}}1 + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/indent/less.vim b/indent/less.vim new file mode 100644 index 00000000..fea8846d --- /dev/null +++ b/indent/less.vim @@ -0,0 +1,11 @@ +" Vim indent file +" Language:	    LessCSS +" Maintainer:	Leonard Ehrenfried <leonard.ehrenfried@web.de> +" Last Change:	2011 Sep 26 + +if exists("b:did_indent") +  finish +endif + +runtime! indent/css.vim + diff --git a/indent/ocaml.vim b/indent/ocaml.vim new file mode 100644 index 00000000..a84c992e --- /dev/null +++ b/indent/ocaml.vim @@ -0,0 +1,267 @@ +" Vim indent file +" Language:     OCaml +" Maintainers:  Jean-Francois Yuen   <jfyuen@happycoders.org> +"               Mike Leary           <leary@nwlink.com> +"               Markus Mottl         <markus.mottl@gmail.com> +" URL:          http://www.ocaml.info/vim/indent/ocaml.vim +" Last Change:  2010 Sep 04 - Added an indentation improvement by Mark Weber +"               2005 Jun 25 - Fixed multiple bugs due to 'else\nreturn ind' working +"               2005 May 09 - Added an option to not indent OCaml-indents specially (MM) + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal expandtab +setlocal indentexpr=GetOCamlIndent() +setlocal indentkeys+=0=and,0=class,0=constraint,0=done,0=else,0=end,0=exception,0=external,0=if,0=in,0=include,0=inherit,0=initializer,0=let,0=method,0=open,0=then,0=type,0=val,0=with,0;;,0>\],0\|\],0>},0\|,0},0\],0) +setlocal nolisp +setlocal nosmartindent +setlocal textwidth=80 + +" Comment formatting +if !exists("no_ocaml_comments") + if (has("comments")) +   setlocal comments=sr:(*,mb:*,ex:*) +   setlocal fo=cqort + endif +endif + +" Only define the function once. +if exists("*GetOCamlIndent") + finish +endif + +" Define some patterns: +let s:beflet = '^\s*\(initializer\|method\|try\)\|\(\<\(begin\|do\|else\|in\|then\|try\)\|->\|<-\|=\|;\|(\)\s*$' +let s:letpat = '^\s*\(let\|type\|module\|class\|open\|exception\|val\|include\|external\)\>' +let s:letlim = '\(\<\(sig\|struct\)\|;;\)\s*$' +let s:lim = '^\s*\(exception\|external\|include\|let\|module\|open\|type\|val\)\>' +let s:module = '\<\%(begin\|sig\|struct\|object\)\>' +let s:obj = '^\s*\(constraint\|inherit\|initializer\|method\|val\)\>\|\<\(object\|object\s*(.*)\)\s*$' +let s:type = '^\s*\%(class\|let\|type\)\>.*=' + +" Skipping pattern, for comments +function! s:GetLineWithoutFullComment(lnum) + let lnum = prevnonblank(a:lnum - 1) + let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') + while lline =~ '^\s*$' && lnum > 0 +   let lnum = prevnonblank(lnum - 1) +   let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') + endwhile + return lnum +endfunction + +" Indent for ';;' to match multiple 'let' +function! s:GetInd(lnum, pat, lim) + let llet = search(a:pat, 'bW') + let old = indent(a:lnum) + while llet > 0 +   let old = indent(llet) +   let nb = s:GetLineWithoutFullComment(llet) +   if getline(nb) =~ a:lim +     return old +   endif +   let llet = search(a:pat, 'bW') + endwhile + return old +endfunction + +" Indent pairs +function! s:FindPair(pstart, pmid, pend) + call search(a:pend, 'bW') + return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment"')) +endfunction + +" Indent 'let' +function! s:FindLet(pstart, pmid, pend) + call search(a:pend, 'bW') + return indent(searchpair(a:pstart, a:pmid, a:pend, 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") =~ "^\\s*let\\>.*=.*\\<in\\s*$" || getline(prevnonblank(".") - 1) =~ s:beflet')) +endfunction + +function! GetOCamlIndent() + " Find a non-commented line above the current line. + let lnum = s:GetLineWithoutFullComment(v:lnum) + + " At the start of the file use zero indent. + if lnum == 0 +   return 0 + endif + + let ind = indent(lnum) + let lline = substitute(getline(lnum), '(\*.*\*)\s*$', '', '') + + " Return double 'shiftwidth' after lines matching: + if lline =~ '^\s*|.*->\s*$' +   return ind + &sw + &sw + endif + + let line = getline(v:lnum) + + " Indent if current line begins with 'end': + if line =~ '^\s*end\>' +   return s:FindPair(s:module, '','\<end\>') + + " Indent if current line begins with 'done' for 'do': + elseif line =~ '^\s*done\>' +   return s:FindPair('\<do\>', '','\<done\>') + + " Indent if current line begins with '}' or '>}': + elseif line =~ '^\s*\(\|>\)}' +   return s:FindPair('{', '','}') + + " Indent if current line begins with ']', '|]' or '>]': + elseif line =~ '^\s*\(\||\|>\)\]' +   return s:FindPair('\[', '','\]') + + " Indent if current line begins with ')': + elseif line =~ '^\s*)' +   return s:FindPair('(', '',')') + + " Indent if current line begins with 'let': + elseif line =~ '^\s*let\>' +   if lline !~ s:lim . '\|' . s:letlim . '\|' . s:beflet +     return s:FindLet(s:type, '','\<let\s*$') +   endif + + " Indent if current line begins with 'class' or 'type': + elseif line =~ '^\s*\(class\|type\)\>' +   if lline !~ s:lim . '\|\<and\s*$\|' . s:letlim +     return s:FindLet(s:type, '','\<\(class\|type\)\s*$') +   endif + + " Indent for pattern matching: + elseif line =~ '^\s*|' +   if lline !~ '^\s*\(|[^\]]\|\(match\|type\|with\)\>\)\|\<\(function\|parser\|private\|with\)\s*$' +     call search('|', 'bW') +     return indent(searchpair('^\s*\(match\|type\)\>\|\<\(function\|parser\|private\|with\)\s*$', '', '^\s*|', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|comment" || getline(".") !~ "^\\s*|.*->"')) +   endif + + " Indent if current line begins with ';;': + elseif line =~ '^\s*;;' +   if lline !~ ';;\s*$' +     return s:GetInd(v:lnum, s:letpat, s:letlim) +   endif + + " Indent if current line begins with 'in': + elseif line =~ '^\s*in\>' +   if lline !~ '^\s*\(let\|and\)\>' +     return s:FindPair('\<let\>', '', '\<in\>') +   endif + + " Indent if current line begins with 'else': + elseif line =~ '^\s*else\>' +   if lline !~ '^\s*\(if\|then\)\>' +     return s:FindPair('\<if\>', '', '\<else\>') +   endif + + " Indent if current line begins with 'then': + elseif line =~ '^\s*then\>' +   if lline !~ '^\s*\(if\|else\)\>' +     return s:FindPair('\<if\>', '', '\<then\>') +   endif + + " Indent if current line begins with 'and': + elseif line =~ '^\s*and\>' +   if lline !~ '^\s*\(and\|let\|type\)\>\|\<end\s*$' +     return ind - &sw +   endif + + " Indent if current line begins with 'with': + elseif line =~ '^\s*with\>' +   if lline !~ '^\s*\(match\|try\)\>' +     return s:FindPair('\<\%(match\|try\)\>', '','\<with\>') +   endif + + " Indent if current line begins with 'exception', 'external', 'include' or + " 'open': + elseif line =~ '^\s*\(exception\|external\|include\|open\)\>' +   if lline !~ s:lim . '\|' . s:letlim +     call search(line) +     return indent(search('^\s*\(\(exception\|external\|include\|open\|type\)\>\|val\>.*:\)', 'bW')) +   endif + + " Indent if current line begins with 'val': + elseif line =~ '^\s*val\>' +   if lline !~ '^\s*\(exception\|external\|include\|open\)\>\|' . s:obj . '\|' . s:letlim +     return indent(search('^\s*\(\(exception\|include\|initializer\|method\|open\|type\|val\)\>\|external\>.*:\)', 'bW')) +   endif + + " Indent if current line begins with 'constraint', 'inherit', 'initializer' + " or 'method': + elseif line =~ '^\s*\(constraint\|inherit\|initializer\|method\)\>' +   if lline !~ s:obj +     return indent(search('\<\(object\|object\s*(.*)\)\s*$', 'bW')) + &sw +   endif + + endif + + " Add a 'shiftwidth' after lines ending with: + if lline =~ '\(:\|=\|->\|<-\|(\|\[\|{\|{<\|\[|\|\[<\|\<\(begin\|do\|else\|fun\|function\|functor\|if\|initializer\|object\|parser\|private\|sig\|struct\|then\|try\)\|\<object\s*(.*)\)\s*$' +   let ind = ind + &sw + + " Back to normal indent after lines ending with ';;': + elseif lline =~ ';;\s*$' && lline !~ '^\s*;;' +   let ind = s:GetInd(v:lnum, s:letpat, s:letlim) + + " Back to normal indent after lines ending with 'end': + elseif lline =~ '\<end\s*$' +   let ind = s:FindPair(s:module, '','\<end\>') + + " Back to normal indent after lines ending with 'in': + elseif lline =~ '\<in\s*$' && lline !~ '^\s*in\>' +   let ind = s:FindPair('\<let\>', '', '\<in\>') + + " Back to normal indent after lines ending with 'done': + elseif lline =~ '\<done\s*$' +   let ind = s:FindPair('\<do\>', '','\<done\>') + + " Back to normal indent after lines ending with '}' or '>}': + elseif lline =~ '\(\|>\)}\s*$' +   let ind = s:FindPair('{', '','}') + + " Back to normal indent after lines ending with ']', '|]' or '>]': + elseif lline =~ '\(\||\|>\)\]\s*$' +   let ind = s:FindPair('\[', '','\]') + + " Back to normal indent after comments: + elseif lline =~ '\*)\s*$' +   call search('\*)', 'bW') +   let ind = indent(searchpair('(\*', '', '\*)', 'bWn', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string"')) + + " Back to normal indent after lines ending with ')': + elseif lline =~ ')\s*$' +   let ind = s:FindPair('(', '',')') + + " If this is a multiline comment then align '*': + elseif lline =~ '^\s*(\*' && line =~ '^\s*\*' +   let ind = ind + 1 + + else + " Don't change indentation of this line + " for new lines (indent==0) use indentation of previous line + + " This is for preventing removing indentation of these args: + "   let f x = + "     let y = x + 1 in + "     Printf.printf + "       "o"           << here + "       "oeuth"       << don't touch indentation + +   let i = indent(v:lnum) +   return i == 0 ? ind : i + + endif + + " Subtract a 'shiftwidth' after lines matching 'match ... with parser': + if lline =~ '\<match\>.*\<with\>\s*\<parser\s*$' +   let ind = ind - &sw + endif + + return ind + +endfunction + +" vim:sw=2 diff --git a/indent/ruby.vim b/indent/ruby.vim new file mode 100644 index 00000000..095b3a43 --- /dev/null +++ b/indent/ruby.vim @@ -0,0 +1,537 @@ +" Vim indent file +" Language:		Ruby +" Maintainer:		Nikolai Weibull <now at bitwi.se> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +" 0. Initialization {{{1 +" ================= + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") +  finish +endif +let b:did_indent = 1 + +setlocal nosmartindent + +" Now, set up our indentation expression and keys that trigger it. +setlocal indentexpr=GetRubyIndent(v:lnum) +setlocal indentkeys=0{,0},0),0],!^F,o,O,e +setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue,==begin,==end + +" Only define the function once. +if exists("*GetRubyIndent") +  finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" 1. Variables {{{1 +" ============ + +" Regex of syntax group names that are or delimit strings/symbols or are comments. +let s:syng_strcom = '\<ruby\%(Regexp\|RegexpDelimiter\|RegexpEscape' . +      \ '\|Symbol\|String\|StringDelimiter\|StringEscape\|ASCIICode' . +      \ '\|Interpolation\|NoInterpolation\|Comment\|Documentation\)\>' + +" Regex of syntax group names that are strings. +let s:syng_string = +      \ '\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\)\>' + +" Regex of syntax group names that are strings or documentation. +let s:syng_stringdoc = +      \'\<ruby\%(String\|Interpolation\|NoInterpolation\|StringEscape\|Documentation\)\>' + +" Expression used to check whether we should skip a match with searchpair(). +let s:skip_expr = +      \ "synIDattr(synID(line('.'),col('.'),1),'name') =~ '".s:syng_strcom."'" + +" Regex used for words that, at the start of a line, add a level of indent. +let s:ruby_indent_keywords = '^\s*\zs\<\%(module\|class\|def\|if\|for' . +      \ '\|while\|until\|else\|elsif\|case\|when\|unless\|begin\|ensure' . +      \ '\|rescue\):\@!\>' . +      \ '\|\%([=,*/%+-]\|<<\|>>\|:\s\)\s*\zs' . +      \    '\<\%(if\|for\|while\|until\|case\|unless\|begin\):\@!\>' + +" Regex used for words that, at the start of a line, remove a level of indent. +let s:ruby_deindent_keywords = +      \ '^\s*\zs\<\%(ensure\|else\|rescue\|elsif\|when\|end\):\@!\>' + +" Regex that defines the start-match for the 'end' keyword. +"let s:end_start_regex = '\%(^\|[^.]\)\<\%(module\|class\|def\|if\|for\|while\|until\|case\|unless\|begin\|do\)\>' +" TODO: the do here should be restricted somewhat (only at end of line)? +let s:end_start_regex = +      \ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' . +      \ '\<\%(module\|class\|def\|if\|for\|while\|until\|case\|unless\|begin\):\@!\>' . +      \ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>' + +" Regex that defines the middle-match for the 'end' keyword. +let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>\|when\|elsif\):\@!\>' + +" Regex that defines the end-match for the 'end' keyword. +let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>' + +" Expression used for searchpair() call for finding match for 'end' keyword. +let s:end_skip_expr = s:skip_expr . +      \ ' || (expand("<cword>") == "do"' . +      \ ' && getline(".") =~ "^\\s*\\<\\(while\\|until\\|for\\):\\@!\\>")' + +" Regex that defines continuation lines, not including (, {, or [. +let s:non_bracket_continuation_regex = '\%([\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' + +" Regex that defines continuation lines. +" TODO: this needs to deal with if ...: and so on +let s:continuation_regex = +      \ '\%(%\@<![({[\\.,:*/%+]\|\<and\|\<or\|\%(<%\)\@<![=-]\|\W[|&?]\|||\|&&\)\s*\%(#.*\)\=$' + +" Regex that defines bracket continuations +let s:bracket_continuation_regex = '%\@<!\%([({[]\)\s*\%(#.*\)\=$' + +" Regex that defines the first part of a splat pattern +let s:splat_regex = '[[,(]\s*\*\s*\%(#.*\)\=$' + +" Regex that defines blocks. +" +" Note that there's a slight problem with this regex and s:continuation_regex. +" Code like this will be matched by both: +" +"   method_call do |(a, b)| +" +" The reason is that the pipe matches a hanging "|" operator. +" +let s:block_regex = +      \ '\%(\<do:\@!\>\|%\@<!{\)\s*\%(|\s*(*\s*\%([*@&]\=\h\w*,\=\s*\)\%(,\s*(*\s*[*@&]\=\h\w*\s*)*\s*\)*|\)\=\s*\%(#.*\)\=$' + +let s:block_continuation_regex = '^\s*[^])}\t ].*'.s:block_regex + +" 2. Auxiliary Functions {{{1 +" ====================== + +" Check if the character at lnum:col is inside a string, comment, or is ascii. +function s:IsInStringOrComment(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_strcom +endfunction + +" Check if the character at lnum:col is inside a string. +function s:IsInString(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_string +endfunction + +" Check if the character at lnum:col is inside a string or documentation. +function s:IsInStringOrDocumentation(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') =~ s:syng_stringdoc +endfunction + +" Check if the character at lnum:col is inside a string delimiter +function s:IsInStringDelimiter(lnum, col) +  return synIDattr(synID(a:lnum, a:col, 1), 'name') == 'rubyStringDelimiter' +endfunction + +" Find line above 'lnum' that isn't empty, in a comment, or in a string. +function s:PrevNonBlankNonString(lnum) +  let in_block = 0 +  let lnum = prevnonblank(a:lnum) +  while lnum > 0 +    " Go in and out of blocks comments as necessary. +    " If the line isn't empty (with opt. comment) or in a string, end search. +    let line = getline(lnum) +    if line =~ '^=begin' +      if in_block +        let in_block = 0 +      else +        break +      endif +    elseif !in_block && line =~ '^=end' +      let in_block = 1 +    elseif !in_block && line !~ '^\s*#.*$' && !(s:IsInStringOrComment(lnum, 1) +          \ && s:IsInStringOrComment(lnum, strlen(line))) +      break +    endif +    let lnum = prevnonblank(lnum - 1) +  endwhile +  return lnum +endfunction + +" Find line above 'lnum' that started the continuation 'lnum' may be part of. +function s:GetMSL(lnum) +  " Start on the line we're at and use its indent. +  let msl = a:lnum +  let msl_body = getline(msl) +  let lnum = s:PrevNonBlankNonString(a:lnum - 1) +  while lnum > 0 +    " If we have a continuation line, or we're in a string, use line as MSL. +    " Otherwise, terminate search as we have found our MSL already. +    let line = getline(lnum) + +    if s:Match(lnum, s:splat_regex) +      " If the above line looks like the "*" of a splat, use the current one's +      " indentation. +      " +      " Example: +      "   Hash[* +      "     method_call do +      "       something +      " +      return msl +    elseif s:Match(line, s:non_bracket_continuation_regex) && +          \ s:Match(msl, s:non_bracket_continuation_regex) +      " If the current line is a non-bracket continuation and so is the +      " previous one, keep its indent and continue looking for an MSL. +      " +      " Example: +      "   method_call one, +      "     two, +      "     three +      " +      let msl = lnum +    elseif s:Match(lnum, s:non_bracket_continuation_regex) && +          \ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex)) +      " If the current line is a bracket continuation or a block-starter, but +      " the previous is a non-bracket one, respect the previous' indentation, +      " and stop here. +      " +      " Example: +      "   method_call one, +      "     two { +      "     three +      " +      return lnum +    elseif s:Match(lnum, s:bracket_continuation_regex) && +          \ (s:Match(msl, s:bracket_continuation_regex) || s:Match(msl, s:block_continuation_regex)) +      " If both lines are bracket continuations (the current may also be a +      " block-starter), use the current one's and stop here +      " +      " Example: +      "   method_call( +      "     other_method_call( +      "       foo +      return msl +    elseif s:Match(lnum, s:block_regex) && +          \ !s:Match(msl, s:continuation_regex) && +          \ !s:Match(msl, s:block_continuation_regex) +      " If the previous line is a block-starter and the current one is +      " mostly ordinary, use the current one as the MSL. +      " +      " Example: +      "   method_call do +      "     something +      "     something_else +      return msl +    else +      let col = match(line, s:continuation_regex) + 1 +      if (col > 0 && !s:IsInStringOrComment(lnum, col)) +            \ || s:IsInString(lnum, strlen(line)) +        let msl = lnum +      else +        break +      endif +    endif + +    let msl_body = getline(msl) +    let lnum = s:PrevNonBlankNonString(lnum - 1) +  endwhile +  return msl +endfunction + +" Check if line 'lnum' has more opening brackets than closing ones. +function s:ExtraBrackets(lnum) +  let opening = {'parentheses': [], 'braces': [], 'brackets': []} +  let closing = {'parentheses': [], 'braces': [], 'brackets': []} + +  let line = getline(a:lnum) +  let pos  = match(line, '[][(){}]', 0) + +  " Save any encountered opening brackets, and remove them once a matching +  " closing one has been found. If a closing bracket shows up that doesn't +  " close anything, save it for later. +  while pos != -1 +    if !s:IsInStringOrComment(a:lnum, pos + 1) +      if line[pos] == '(' +        call add(opening.parentheses, {'type': '(', 'pos': pos}) +      elseif line[pos] == ')' +        if empty(opening.parentheses) +          call add(closing.parentheses, {'type': ')', 'pos': pos}) +        else +          let opening.parentheses = opening.parentheses[0:-2] +        endif +      elseif line[pos] == '{' +        call add(opening.braces, {'type': '{', 'pos': pos}) +      elseif line[pos] == '}' +        if empty(opening.braces) +          call add(closing.braces, {'type': '}', 'pos': pos}) +        else +          let opening.braces = opening.braces[0:-2] +        endif +      elseif line[pos] == '[' +        call add(opening.brackets, {'type': '[', 'pos': pos}) +      elseif line[pos] == ']' +        if empty(opening.brackets) +          call add(closing.brackets, {'type': ']', 'pos': pos}) +        else +          let opening.brackets = opening.brackets[0:-2] +        endif +      endif +    endif + +    let pos = match(line, '[][(){}]', pos + 1) +  endwhile + +  " Find the rightmost brackets, since they're the ones that are important in +  " both opening and closing cases +  let rightmost_opening = {'type': '(', 'pos': -1} +  let rightmost_closing = {'type': ')', 'pos': -1} + +  for opening in opening.parentheses + opening.braces + opening.brackets +    if opening.pos > rightmost_opening.pos +      let rightmost_opening = opening +    endif +  endfor + +  for closing in closing.parentheses + closing.braces + closing.brackets +    if closing.pos > rightmost_closing.pos +      let rightmost_closing = closing +    endif +  endfor + +  return [rightmost_opening, rightmost_closing] +endfunction + +function s:Match(lnum, regex) +  let col = match(getline(a:lnum), '\C'.a:regex) + 1 +  return col > 0 && !s:IsInStringOrComment(a:lnum, col) ? col : 0 +endfunction + +function s:MatchLast(lnum, regex) +  let line = getline(a:lnum) +  let col = match(line, '.*\zs' . a:regex) +  while col != -1 && s:IsInStringOrComment(a:lnum, col) +    let line = strpart(line, 0, col) +    let col = match(line, '.*' . a:regex) +  endwhile +  return col + 1 +endfunction + +" 3. GetRubyIndent Function {{{1 +" ========================= + +function GetRubyIndent(...) +  " 3.1. Setup {{{2 +  " ---------- + +  " For the current line, use the first argument if given, else v:lnum +  let clnum = a:0 ? a:1 : v:lnum + +  " Set up variables for restoring position in file.  Could use clnum here. +  let vcol = col('.') + +  " 3.2. Work on the current line {{{2 +  " ----------------------------- + +  " Get the current line. +  let line = getline(clnum) +  let ind = -1 + +  " If we got a closing bracket on an empty line, find its match and indent +  " according to it.  For parentheses we indent to its column - 1, for the +  " others we indent to the containing line's MSL's level.  Return -1 if fail. +  let col = matchend(line, '^\s*[]})]') +  if col > 0 && !s:IsInStringOrComment(clnum, col) +    call cursor(clnum, col) +    let bs = strpart('(){}[]', stridx(')}]', line[col - 1]) * 2, 2) +    if searchpair(escape(bs[0], '\['), '', bs[1], 'bW', s:skip_expr) > 0 +      if line[col-1]==')' && col('.') != col('$') - 1 +        let ind = virtcol('.') - 1 +      else +        let ind = indent(s:GetMSL(line('.'))) +      endif +    endif +    return ind +  endif + +  " If we have a =begin or =end set indent to first column. +  if match(line, '^\s*\%(=begin\|=end\)$') != -1 +    return 0 +  endif + +  " If we have a deindenting keyword, find its match and indent to its level. +  " TODO: this is messy +  if s:Match(clnum, s:ruby_deindent_keywords) +    call cursor(clnum, 1) +    if searchpair(s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'bW', +          \ s:end_skip_expr) > 0 +      let msl  = s:GetMSL(line('.')) +      let line = getline(line('.')) + +      if strpart(line, 0, col('.') - 1) =~ '=\s*$' && +            \ strpart(line, col('.') - 1, 2) !~ 'do' +        let ind = virtcol('.') - 1 +      elseif getline(msl) =~ '=\s*\(#.*\)\=$' +        let ind = indent(line('.')) +      else +        let ind = indent(msl) +      endif +    endif +    return ind +  endif + +  " If we are in a multi-line string or line-comment, don't do anything to it. +  if s:IsInStringOrDocumentation(clnum, matchend(line, '^\s*') + 1) +    return indent('.') +  endif + +  " If we are at the closing delimiter of a "<<" heredoc-style string, set the +  " indent to 0. +  if line =~ '^\k\+\s*$' +        \ && s:IsInStringDelimiter(clnum, 1) +        \ && search('\V<<'.line, 'nbW') > 0 +    return 0 +  endif + +  " 3.3. Work on the previous line. {{{2 +  " ------------------------------- + +  " Find a non-blank, non-multi-line string line above the current line. +  let lnum = s:PrevNonBlankNonString(clnum - 1) + +  " If the line is empty and inside a string, use the previous line. +  if line =~ '^\s*$' && lnum != prevnonblank(clnum - 1) +    return indent(prevnonblank(clnum)) +  endif + +  " At the start of the file use zero indent. +  if lnum == 0 +    return 0 +  endif + +  " Set up variables for the previous line. +  let line = getline(lnum) +  let ind = indent(lnum) + +  " If the previous line ended with a block opening, add a level of indent. +  if s:Match(lnum, s:block_regex) +    return indent(s:GetMSL(lnum)) + &sw +  endif + +  " If the previous line ended with the "*" of a splat, add a level of indent +  if line =~ s:splat_regex +    return indent(lnum) + &sw +  endif + +  " If the previous line contained unclosed opening brackets and we are still +  " in them, find the rightmost one and add indent depending on the bracket +  " type. +  " +  " If it contained hanging closing brackets, find the rightmost one, find its +  " match and indent according to that. +  if line =~ '[[({]' || line =~ '[])}]\s*\%(#.*\)\=$' +    let [opening, closing] = s:ExtraBrackets(lnum) + +    if opening.pos != -1 +      if opening.type == '(' && searchpair('(', '', ')', 'bW', s:skip_expr) > 0 +        if col('.') + 1 == col('$') +          return ind + &sw +        else +          return virtcol('.') +        endif +      else +        let nonspace = matchend(line, '\S', opening.pos + 1) - 1 +        return nonspace > 0 ? nonspace : ind + &sw +      endif +    elseif closing.pos != -1 +      call cursor(lnum, closing.pos + 1) +      normal! % + +      if s:Match(line('.'), s:ruby_indent_keywords) +        return indent('.') + &sw +      else +        return indent('.') +      endif +    else +      call cursor(clnum, vcol) +    end +  endif + +  " If the previous line ended with an "end", match that "end"s beginning's +  " indent. +  let col = s:Match(lnum, '\%(^\|[^.:@$]\)\<end\>\s*\%(#.*\)\=$') +  if col > 0 +    call cursor(lnum, col) +    if searchpair(s:end_start_regex, '', s:end_end_regex, 'bW', +          \ s:end_skip_expr) > 0 +      let n = line('.') +      let ind = indent('.') +      let msl = s:GetMSL(n) +      if msl != n +        let ind = indent(msl) +      end +      return ind +    endif +  end + +  let col = s:Match(lnum, s:ruby_indent_keywords) +  if col > 0 +    call cursor(lnum, col) +    let ind = virtcol('.') - 1 + &sw +    " TODO: make this better (we need to count them) (or, if a searchpair +    " fails, we know that something is lacking an end and thus we indent a +    " level +    if s:Match(lnum, s:end_end_regex) +      let ind = indent('.') +    endif +    return ind +  endif + +  " 3.4. Work on the MSL line. {{{2 +  " -------------------------- + +  " Set up variables to use and search for MSL to the previous line. +  let p_lnum = lnum +  let lnum = s:GetMSL(lnum) + +  " If the previous line wasn't a MSL and is continuation return its indent. +  " TODO: the || s:IsInString() thing worries me a bit. +  if p_lnum != lnum +    if s:Match(p_lnum, s:non_bracket_continuation_regex) || s:IsInString(p_lnum,strlen(line)) +      return ind +    endif +  endif + +  " Set up more variables, now that we know we wasn't continuation bound. +  let line = getline(lnum) +  let msl_ind = indent(lnum) + +  " If the MSL line had an indenting keyword in it, add a level of indent. +  " TODO: this does not take into account contrived things such as +  " module Foo; class Bar; end +  if s:Match(lnum, s:ruby_indent_keywords) +    let ind = msl_ind + &sw +    if s:Match(lnum, s:end_end_regex) +      let ind = ind - &sw +    endif +    return ind +  endif + +  " If the previous line ended with [*+/.,-=], but wasn't a block ending or a +  " closing bracket, indent one extra level. +  if s:Match(lnum, s:non_bracket_continuation_regex) && !s:Match(lnum, '^\s*\([\])}]\|end\)') +    if lnum == p_lnum +      let ind = msl_ind + &sw +    else +      let ind = msl_ind +    endif +    return ind +  endif + +  " }}}2 + +  return ind +endfunction + +" }}}1 + +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim:set sw=2 sts=2 ts=8 et: diff --git a/indent/sass.vim b/indent/sass.vim new file mode 100644 index 00000000..1da83193 --- /dev/null +++ b/indent/sass.vim @@ -0,0 +1,40 @@ +" Vim indent file +" Language:	Sass +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 May 21 + +if exists("b:did_indent") +  finish +endif +let b:did_indent = 1 + +setlocal autoindent sw=2 et +setlocal indentexpr=GetSassIndent() +setlocal indentkeys=o,O,*<Return>,<:>,!^F + +" Only define the function once. +if exists("*GetSassIndent") +  finish +endif + +let s:property = '^\s*:\|^\s*[[:alnum:]#{}-]\+\%(:\|\s*=\)' +let s:extend = '^\s*\%(@extend\|@include\|+\)' + +function! GetSassIndent() +  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:property && line !~ s:extend && cline =~ s:property +    return indent + &sw +  "elseif line =~ s:property && cline !~ s:property +    "return indent - &sw +  else +    return -1 +  endif +endfunction + +" vim:set sw=2: diff --git a/indent/scss.vim b/indent/scss.vim new file mode 100644 index 00000000..82bba492 --- /dev/null +++ b/indent/scss.vim @@ -0,0 +1,12 @@ +" Vim indent file +" Language:	SCSS +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Last Change:	2010 Jul 26 + +if exists("b:did_indent") +  finish +endif + +runtime! indent/css.vim + +" vim:set sw=2: diff --git a/indent/slim.vim b/indent/slim.vim new file mode 100644 index 00000000..5b843bfb --- /dev/null +++ b/indent/slim.vim @@ -0,0 +1,75 @@ +" Vim indent file +" Language:	Slim + +if exists("b:did_indent") +  finish +endif +runtime! indent/ruby.vim +unlet! b:did_indent +let b:did_indent = 1 + +setlocal autoindent sw=2 et +setlocal indentexpr=GetSlimIndent() +setlocal indentkeys=o,O,*<Return>,},],0),!^F,=end,=else,=elsif,=rescue,=ensure,=when + +" Only define the function once. +if exists("*GetSlimIndent") +  finish +endif + +let s:attributes = '\%({.\{-\}}\|\[.\{-\}\]\)' +let s:tag = '\%([%.#][[:alnum:]_-]\+\|'.s:attributes.'\)*[<>]*' + +if !exists('g:haml_self_closing_tags') +  let g:haml_self_closing_tags = 'meta|link|img|hr|br' +endif + +function! GetSlimIndent() +  let lnum = prevnonblank(v:lnum-1) +  if lnum == 0 +    return 0 +  endif +  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 cline =~# '\v^-\s*%(elsif|else|when)>' +    let indent = cindent < indent ? cindent : indent - &sw +  endif +  let increase = indent + &sw +  if indent == indent(lnum) +    let indent = cindent <= indent ? -1 : increase +  endif + +  let group = synIDattr(synID(lnum,lastcol,1),'name') + +  if line =~ '^doctype' +    return indent +  elseif line =~ '^/\%(\[[^]]*\]\)\=$' +    return increase +  elseif line =~ '^[\.#]' +    return increase +  elseif line =~? '^div' +    return increase +  elseif group == 'hamlFilter' +    return increase +  elseif line =~ '^'.s:tag.'[&!]\=[=~-]\s*\%(\%(if\|else\|elsif\|unless\|case\|when\|while\|until\|for\|begin\|module\|class\|def\)\>\%(.*\<end\>\)\@!\|.*do\%(\s*|[^|]*|\)\=\s*$\)' +    return increase +  elseif line =~ '^'.s:tag.'[&!]\=[=~-].*,\s*$' +    return increase +  elseif line == '-#' +    return increase +  elseif group =~? '\v^(hamlSelfCloser)$' || line =~? '^\v('.g:haml_self_closing_tags.')>' +    return indent +  elseif group =~? '\v^(hamlTag|hamlAttributesDelimiter|hamlObjectDelimiter|hamlClass|hamlId|htmlTagName|htmlSpecialTagName)$' +    return increase +  elseif synIDattr(synID(v:lnum,1,1),'name') ==? 'hamlRubyFilter' +    return GetRubyIndent() +  else +    return indent +  endif +endfunction + +" vim:set sw=2: diff --git a/indent/stylus.vim b/indent/stylus.vim new file mode 100644 index 00000000..8707e619 --- /dev/null +++ b/indent/stylus.vim @@ -0,0 +1,129 @@ +" Vim indent file +" Language: Stylus +" Maintainer: Marc Harter +" Last Change: 2010 May 21 +" Based On: sass.vim from Tim Pope +" +if exists("b:did_indent") +  finish +endif +unlet! b:did_indent +let b:did_indent = 1 + +setlocal indentexpr=GetStylusIndent() +setlocal indentkeys=o,O,*<Return>,},],0),!^F +setlocal formatoptions+=r + +if exists("*GetStylusIndent")  " only define once +  finish +endif + +function s:prevnonblanknoncomment(lnum) +  let lnum = a:lnum +  while lnum > 1 +    let lnum = prevnonblank(lnum) +    let line = getline(lnum) +    if line =~ '\*/' +      while lnum > 1 && line !~ '/\*' +        let lnum -= 1 +      endwhile +      if line =~ '^\s*/\*' +        let lnum -= 1 +      else +        break +      endif +    else +      break +    endif +  endwhile +  return lnum +endfunction + +function s:count_braces(lnum, count_open) +  let n_open = 0 +  let n_close = 0 +  let line = getline(a:lnum) +  let pattern = '[{}]' +  let i = match(line, pattern) +  while i != -1 +    if synIDattr(synID(a:lnum, i + 1, 0), 'name') !~ 'css\%(Comment\|StringQ\{1,2}\)' +      if line[i] == '{' +        let n_open += 1 +      elseif line[i] == '}' +        if n_open > 0 +          let n_open -= 1 +        else +          let n_close += 1 +        endif +      endif +    endif +    let i = match(line, pattern, i + 1) +  endwhile +  return a:count_open ? n_open : n_close +endfunction + +" function CheckCSSIndent() +"   let line = getline(v:lnum) +"   if line =~ '^\s*\*' +"     return cindent(v:lnum) +"   endif +"  +"   let pnum = s:prevnonblanknoncomment(v:lnum - 1) +"   if pnum == 0 +"     return 0 +"   endif +"  +"   return indent(pnum) + s:count_braces(pnum, 1) * &sw +"         \ - s:count_braces(v:lnum, 0) * &sw +" endfunction + +function! GetStylusIndent() +  let line = getline(v:lnum) +  if line =~ '^\s*\*' +    return cindent(v:lnum) +  endif + +  let pnum = s:prevnonblanknoncomment(v:lnum - 1) +  if pnum == 0 +    return 0 +  endif + +  let lnum     = prevnonblank(v:lnum-1) +  if lnum == 0 +    return 0 +  endif + +  let pline = getline(pnum) + +  if pline =~ '[}{]' +    return indent(pnum) + s:count_braces(pnum, 1) * &sw - s:count_braces(v:lnum, 0) * &sw +  endif + +  let line     = substitute(getline(lnum),'[\s()]\+$','','')  " get last line strip ending whitespace +  let cline    = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')  " get current line, trimmed +  let lastcol  = strlen(line)  " get last col in prev line +  let line     = substitute(line,'^\s\+','','')  " then remove preceeding whitespace +  let indent   = indent(lnum)  " get indent on prev line +  let cindent  = indent(v:lnum)  " get indent on current line +  let increase = indent + &sw  " increase indent by the shift width +  if indent   == indent(lnum) +    let indent = cindent <= indent ? indent : increase +  endif + +  let group = synIDattr(synID(lnum,lastcol,1),'name') + +  " for debugging only +  echo group + +  " if group !~? 'css.*' && line =~? ')\s*$' " match user functions +  "   return increase +  if group =~? '\v^%(cssTagName|cssClassName|cssIdentifier|cssSelectorOp|cssSelectorOp2|cssBraces|cssAttributeSelector|cssPseudoClass|cssPseudoClassId|stylusId|stylusClass)$' +    return increase +  elseif (group == 'stylusUserFunction') && (indent(lnum) == '0') " mixin definition +    return increase +  else +    return indent +  endif +endfunction + +" vim:set sw=2; diff --git a/syntax/coffee.vim b/syntax/coffee.vim new file mode 100755 index 00000000..eea50840 --- /dev/null +++ b/syntax/coffee.vim @@ -0,0 +1,223 @@ +" Language:    CoffeeScript +" Maintainer:  Mick Koch <kchmck@gmail.com> +" URL:         http://github.com/kchmck/vim-coffee-script +" License:     WTFPL + +" Bail if our syntax is already loaded. +if exists('b:current_syntax') && b:current_syntax == 'coffee' +  finish +endif + +" Include JavaScript for coffeeEmbed. +syn include @coffeeJS syntax/javascript.vim +silent! unlet b:current_syntax + +" Highlight long strings. +syntax sync fromstart + +" CoffeeScript identifiers can have dollar signs. +setlocal isident+=$ + +" These are `matches` instead of `keywords` because vim's highlighting +" priority for keywords is higher than matches. This causes keywords to be +" highlighted inside matches, even if a match says it shouldn't contain them -- +" like with coffeeAssign and coffeeDot. +syn match coffeeStatement /\<\%(return\|break\|continue\|throw\)\>/ display +hi def link coffeeStatement Statement + +syn match coffeeRepeat /\<\%(for\|while\|until\|loop\)\>/ display +hi def link coffeeRepeat Repeat + +syn match coffeeConditional /\<\%(if\|else\|unless\|switch\|when\|then\)\>/ +\                           display +hi def link coffeeConditional Conditional + +syn match coffeeException /\<\%(try\|catch\|finally\)\>/ display +hi def link coffeeException Exception + +syn match coffeeKeyword /\<\%(new\|in\|of\|by\|and\|or\|not\|is\|isnt\|class\|extends\|super\|do\)\>/ +\                       display +" The `own` keyword is only a keyword after `for`. +syn match coffeeKeyword /\<for\s\+own\>/ contained containedin=coffeeRepeat +\                       display +hi def link coffeeKeyword Keyword + +syn match coffeeOperator /\<\%(instanceof\|typeof\|delete\)\>/ display +hi def link coffeeOperator Operator + +" The first case matches symbol operators only if they have an operand before. +syn match coffeeExtendedOp /\%(\S\s*\)\@<=[+\-*/%&|\^=!<>?.]\{-1,}\|[-=]>\|--\|++\|:/ +\                          display +syn match coffeeExtendedOp /\<\%(and\|or\)=/ display +hi def link coffeeExtendedOp coffeeOperator + +" This is separate from `coffeeExtendedOp` to help differentiate commas from +" dots. +syn match coffeeSpecialOp /[,;]/ display +hi def link coffeeSpecialOp SpecialChar + +syn match coffeeBoolean /\<\%(true\|on\|yes\|false\|off\|no\)\>/ display +hi def link coffeeBoolean Boolean + +syn match coffeeGlobal /\<\%(null\|undefined\)\>/ display +hi def link coffeeGlobal Type + +" A special variable +syn match coffeeSpecialVar /\<\%(this\|prototype\|arguments\)\>/ display +hi def link coffeeSpecialVar Special + +" An @-variable +syn match coffeeSpecialIdent /@\%(\I\i*\)\?/ display +hi def link coffeeSpecialIdent Identifier + +" A class-like name that starts with a capital letter +syn match coffeeObject /\<\u\w*\>/ display +hi def link coffeeObject Structure + +" A constant-like name in SCREAMING_CAPS +syn match coffeeConstant /\<\u[A-Z0-9_]\+\>/ display +hi def link coffeeConstant Constant + +" A variable name +syn cluster coffeeIdentifier contains=coffeeSpecialVar,coffeeSpecialIdent, +\                                     coffeeObject,coffeeConstant + +" A non-interpolated string +syn cluster coffeeBasicString contains=@Spell,coffeeEscape +" An interpolated string +syn cluster coffeeInterpString contains=@coffeeBasicString,coffeeInterp + +" Regular strings +syn region coffeeString start=/"/ skip=/\\\\\|\\"/ end=/"/ +\                       contains=@coffeeInterpString +syn region coffeeString start=/'/ skip=/\\\\\|\\'/ end=/'/ +\                       contains=@coffeeBasicString +hi def link coffeeString String + +" A integer, including a leading plus or minus +syn match coffeeNumber /\i\@<![-+]\?\d\+\%([eE][+-]\?\d\+\)\?/ display +" A hex, binary, or octal number +syn match coffeeNumber /\<0[xX]\x\+\>/ display +syn match coffeeNumber /\<0[bB][01]\+\>/ display +syn match coffeeNumber /\<0[oO][0-7]\+\>/ display +hi def link coffeeNumber Number + +" A floating-point number, including a leading plus or minus +syn match coffeeFloat /\i\@<![-+]\?\d*\.\@<!\.\d\+\%([eE][+-]\?\d\+\)\?/ +\                     display +hi def link coffeeFloat Float + +" An error for reserved keywords, taken from the RESERVED array: +" http://coffeescript.org/documentation/docs/lexer.html#section-67 +syn match coffeeReservedError /\<\%(case\|default\|function\|var\|void\|with\|const\|let\|enum\|export\|import\|native\|__hasProp\|__extends\|__slice\|__bind\|__indexOf\|implements\|interface\|package\|private\|protected\|public\|static\|yield\)\>/ +\                             display +hi def link coffeeReservedError Error + +" A normal object assignment +syn match coffeeObjAssign /@\?\I\i*\s*\ze::\@!/ contains=@coffeeIdentifier display +hi def link coffeeObjAssign Identifier + +syn keyword coffeeTodo TODO FIXME XXX contained +hi def link coffeeTodo Todo + +syn match coffeeComment /#.*/ contains=@Spell,coffeeTodo +hi def link coffeeComment Comment + +syn region coffeeBlockComment start=/####\@!/ end=/###/ +\                             contains=@Spell,coffeeTodo +hi def link coffeeBlockComment coffeeComment + +" A comment in a heregex +syn region coffeeHeregexComment start=/#/ end=/\ze\/\/\/\|$/ contained +\                               contains=@Spell,coffeeTodo +hi def link coffeeHeregexComment coffeeComment + +" Embedded JavaScript +syn region coffeeEmbed matchgroup=coffeeEmbedDelim +\                      start=/`/ skip=/\\\\\|\\`/ end=/`/ keepend +\                      contains=@coffeeJS +hi def link coffeeEmbedDelim Delimiter + +syn region coffeeInterp matchgroup=coffeeInterpDelim start=/#{/ end=/}/ contained +\                       contains=@coffeeAll +hi def link coffeeInterpDelim PreProc + +" A string escape sequence +syn match coffeeEscape /\\\d\d\d\|\\x\x\{2\}\|\\u\x\{4\}\|\\./ contained display +hi def link coffeeEscape SpecialChar + +" A regex -- must not follow a parenthesis, number, or identifier, and must not +" be followed by a number +syn region coffeeRegex start=#\%(\%()\|\i\@<!\d\)\s*\|\i\)\@<!/=\@!\s\@!# +\                      end=#/[gimy]\{,4}\d\@!# +\                      oneline contains=@coffeeBasicString,coffeeRegexCharSet +syn region coffeeRegexCharSet start=/\[/ end=/]/ contained +\                             contains=@coffeeBasicString +hi def link coffeeRegex String +hi def link coffeeRegexCharSet coffeeRegex + +" A heregex +syn region coffeeHeregex start=#///# end=#///[gimy]\{,4}# +\                        contains=@coffeeInterpString,coffeeHeregexComment, +\                                  coffeeHeregexCharSet +\                        fold +syn region coffeeHeregexCharSet start=/\[/ end=/]/ contained +\                               contains=@coffeeInterpString +hi def link coffeeHeregex coffeeRegex +hi def link coffeeHeregexCharSet coffeeHeregex + +" Heredoc strings +syn region coffeeHeredoc start=/"""/ end=/"""/ contains=@coffeeInterpString +\                        fold +syn region coffeeHeredoc start=/'''/ end=/'''/ contains=@coffeeBasicString +\                        fold +hi def link coffeeHeredoc String + +" An error for trailing whitespace, as long as the line isn't just whitespace +syn match coffeeSpaceError /\S\@<=\s\+$/ display +hi def link coffeeSpaceError Error + +" An error for trailing semicolons, for help transitioning from JavaScript +syn match coffeeSemicolonError /;$/ display +hi def link coffeeSemicolonError Error + +" Ignore reserved words in dot accesses. +syn match coffeeDotAccess /\.\@<!\.\s*\I\i*/he=s+1 contains=@coffeeIdentifier +hi def link coffeeDotAccess coffeeExtendedOp + +" Ignore reserved words in prototype accesses. +syn match coffeeProtoAccess /::\s*\I\i*/he=s+2 contains=@coffeeIdentifier +hi def link coffeeProtoAccess coffeeExtendedOp + +" This is required for interpolations to work. +syn region coffeeCurlies matchgroup=coffeeCurly start=/{/ end=/}/ +\                        contains=@coffeeAll +syn region coffeeBrackets matchgroup=coffeeBracket start=/\[/ end=/\]/ +\                         contains=@coffeeAll +syn region coffeeParens matchgroup=coffeeParen start=/(/ end=/)/ +\                       contains=@coffeeAll + +" These are highlighted the same as commas since they tend to go together. +hi def link coffeeBlock coffeeSpecialOp +hi def link coffeeBracket coffeeBlock +hi def link coffeeCurly coffeeBlock +hi def link coffeeParen coffeeBlock + +" This is used instead of TOP to keep things coffee-specific for good +" embedding. `contained` groups aren't included. +syn cluster coffeeAll contains=coffeeStatement,coffeeRepeat,coffeeConditional, +\                              coffeeException,coffeeKeyword,coffeeOperator, +\                              coffeeExtendedOp,coffeeSpecialOp,coffeeBoolean, +\                              coffeeGlobal,coffeeSpecialVar,coffeeSpecialIdent, +\                              coffeeObject,coffeeConstant,coffeeString, +\                              coffeeNumber,coffeeFloat,coffeeReservedError, +\                              coffeeObjAssign,coffeeComment,coffeeBlockComment, +\                              coffeeEmbed,coffeeRegex,coffeeHeregex, +\                              coffeeHeredoc,coffeeSpaceError, +\                              coffeeSemicolonError,coffeeDotAccess, +\                              coffeeProtoAccess,coffeeCurlies,coffeeBrackets, +\                              coffeeParens + +if !exists('b:current_syntax') +  let b:current_syntax = 'coffee' +endif diff --git a/syntax/cucumber.vim b/syntax/cucumber.vim new file mode 100644 index 00000000..c5bde9e5 --- /dev/null +++ b/syntax/cucumber.vim @@ -0,0 +1,136 @@ +" Vim syntax file +" Language:     Cucumber +" Maintainer:   Tim Pope <vimNOSPAM@tpope.org> +" Filenames:    *.feature +" Last Change:	2010 May 21 + +if exists("b:current_syntax") +    finish +endif +syn case match +syn sync minlines=20 + +let g:cucumber_languages = { +      \"en": {"and": "And\\>", "background": "Background\\>", "but": "But\\>", "examples": "Scenarios\\>\\|Examples\\>", "feature": "Business Need\\>\\|Feature\\>\\|Ability\\>", "given": "Given\\>", "scenario": "Scenario\\>", "scenario_outline": "Scenario Template\\>\\|Scenario Outline\\>", "then": "Then\\>", "when": "When\\>"}, +      \"ar": {"and": "\\%u0648\\>", "background": "\\%u0627\\%u0644\\%u062e\\%u0644\\%u0641\\%u064a\\%u0629\\>", "but": "\\%u0644\\%u0643\\%u0646\\>", "examples": "\\%u0627\\%u0645\\%u062b\\%u0644\\%u0629\\>", "feature": "\\%u062e\\%u0627\\%u0635\\%u064a\\%u0629\\>", "given": "\\%u0628\\%u0641\\%u0631\\%u0636\\>", "scenario": "\\%u0633\\%u064a\\%u0646\\%u0627\\%u0631\\%u064a\\%u0648\\>", "scenario_outline": "\\%u0633\\%u064a\\%u0646\\%u0627\\%u0631\\%u064a\\%u0648 \\%u0645\\%u062e\\%u0637\\%u0637\\>", "then": "\\%u0627\\%u0630\\%u0627\\%u064b\\>\\|\\%u062b\\%u0645\\>", "when": "\\%u0639\\%u0646\\%u062f\\%u0645\\%u0627\\>\\|\\%u0645\\%u062a\\%u0649\\>"}, +      \"bg": {"and": "\\%u0418\\>", "background": "\\%u041f\\%u0440\\%u0435\\%u0434\\%u0438\\%u0441\\%u0442\\%u043e\\%u0440\\%u0438\\%u044f\\>", "but": "\\%u041d\\%u043e\\>", "examples": "\\%u041f\\%u0440\\%u0438\\%u043c\\%u0435\\%u0440\\%u0438\\>", "feature": "\\%u0424\\%u0443\\%u043d\\%u043a\\%u0446\\%u0438\\%u043e\\%u043d\\%u0430\\%u043b\\%u043d\\%u043e\\%u0441\\%u0442\\>", "given": "\\%u0414\\%u0430\\%u0434\\%u0435\\%u043d\\%u043e\\>", "scenario": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0439\\>", "scenario_outline": "\\%u0420\\%u0430\\%u043c\\%u043a\\%u0430 \\%u043d\\%u0430 \\%u0441\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0439\\>", "then": "\\%u0422\\%u043e\\>", "when": "\\%u041a\\%u043e\\%u0433\\%u0430\\%u0442\\%u043e\\>"}, +      \"bm": {"and": "Dan\\>", "background": "Latar Belakang\\>", "but": "Tetapi\\>", "examples": "Contoh \\>", "feature": "Fungsi\\>", "given": "Bagi\\>", "scenario": "Senario\\>", "scenario_outline": "Menggariskan Senario \\>", "then": "Kemudian\\>", "when": "Apabila\\>"}, +      \"ca": {"and": "I\\>", "background": "Antecedents\\>\\|Rerefons\\>", "but": "Per\\%u00f2\\>", "examples": "Exemples\\>", "feature": "Caracter\\%u00edstica\\>\\|Funcionalitat\\>", "given": "At\\%u00e8s\\>\\|Donada\\>\\|Donat\\>\\|Atesa\\>", "scenario": "Escenari\\>", "scenario_outline": "Esquema de l'escenari\\>", "then": "Aleshores\\>\\|Cal\\>", "when": "Quan\\>"}, +      \"cs": {"and": "A tak\\%u00e9\\>\\|A\\>", "background": "Pozad\\%u00ed\\>\\|Kontext\\>", "but": "Ale\\>", "examples": "P\\%u0159\\%u00edklady\\>", "feature": "Po\\%u017eadavek\\>", "given": "Za p\\%u0159edpokladu\\>\\|Pokud\\>", "scenario": "Sc\\%u00e9n\\%u00e1\\%u0159\\>", "scenario_outline": "N\\%u00e1\\%u010drt Sc\\%u00e9n\\%u00e1\\%u0159e\\>\\|Osnova sc\\%u00e9n\\%u00e1\\%u0159e\\>", "then": "Pak\\>", "when": "Kdy\\%u017e\\>"}, +      \"cy-GB": {"and": "A\\>", "background": "Cefndir\\>", "but": "Ond\\>", "examples": "Enghreifftiau\\>", "feature": "Arwedd\\>", "given": "Anrhegedig a\\>", "scenario": "Scenario\\>", "scenario_outline": "Scenario Amlinellol\\>", "then": "Yna\\>", "when": "Pryd\\>"}, +      \"da": {"and": "Og\\>", "background": "Baggrund\\>", "but": "Men\\>", "examples": "Eksempler\\>", "feature": "Egenskab\\>", "given": "Givet\\>", "scenario": "Scenarie\\>", "scenario_outline": "Abstrakt Scenario\\>", "then": "S\\%u00e5\\>", "when": "N\\%u00e5r\\>"}, +      \"de": {"and": "Und\\>", "background": "Grundlage\\>", "but": "Aber\\>", "examples": "Beispiele\\>", "feature": "Funktionalit\\%u00e4t\\>", "given": "Gegeben sei\\>\\|Angenommen\\>", "scenario": "Szenario\\>", "scenario_outline": "Szenariogrundriss\\>", "then": "Dann\\>", "when": "Wenn\\>"}, +      \"el": {"and": "\\%u039a\\%u03b1\\%u03b9\\>", "background": "\\%u03a5\\%u03c0\\%u03cc\\%u03b2\\%u03b1\\%u03b8\\%u03c1\\%u03bf\\>", "but": "\\%u0391\\%u03bb\\%u03bb\\%u03ac\\>", "examples": "\\%u03a0\\%u03b1\\%u03c1\\%u03b1\\%u03b4\\%u03b5\\%u03af\\%u03b3\\%u03bc\\%u03b1\\%u03c4\\%u03b1\\>\\|\\%u03a3\\%u03b5\\%u03bd\\%u03ac\\%u03c1\\%u03b9\\%u03b1\\>", "feature": "\\%u0394\\%u03c5\\%u03bd\\%u03b1\\%u03c4\\%u03cc\\%u03c4\\%u03b7\\%u03c4\\%u03b1\\>\\|\\%u039b\\%u03b5\\%u03b9\\%u03c4\\%u03bf\\%u03c5\\%u03c1\\%u03b3\\%u03af\\%u03b1\\>", "given": "\\%u0394\\%u03b5\\%u03b4\\%u03bf\\%u03bc\\%u03ad\\%u03bd\\%u03bf\\%u03c5 \\%u03cc\\%u03c4\\%u03b9\\>\\|\\%u0394\\%u03b5\\%u03b4\\%u03bf\\%u03bc\\%u03ad\\%u03bd\\%u03bf\\%u03c5\\>", "scenario": "\\%u03a3\\%u03b5\\%u03bd\\%u03ac\\%u03c1\\%u03b9\\%u03bf\\>", "scenario_outline": "\\%u03a0\\%u03b5\\%u03c1\\%u03b9\\%u03b3\\%u03c1\\%u03b1\\%u03c6\\%u03ae \\%u03a3\\%u03b5\\%u03bd\\%u03b1\\%u03c1\\%u03af\\%u03bf\\%u03c5\\>", "then": "\\%u03a4\\%u03cc\\%u03c4\\%u03b5\\>", "when": "\\%u038c\\%u03c4\\%u03b1\\%u03bd\\>"}, +      \"en-Scouse": {"and": "An\\>", "background": "Dis is what went down\\>", "but": "Buh\\>", "examples": "Examples\\>", "feature": "Feature\\>", "given": "Youse know when youse got\\>\\|Givun\\>", "scenario": "The thing of it is\\>", "scenario_outline": "Wharrimean is\\>", "then": "Den youse gotta\\>\\|Dun\\>", "when": "Youse know like when\\>\\|Wun\\>"}, +      \"en-au": {"and": "Too right\\>", "background": "First off\\>", "but": "Yeah nah\\>", "examples": "You'll wanna\\>", "feature": "Pretty much\\>", "given": "Y'know\\>", "scenario": "Awww, look mate\\>", "scenario_outline": "Reckon it's like\\>", "then": "But at the end of the day I reckon\\>", "when": "It's just unbelievable\\>"}, +      \"en-lol": {"and": "AN\\>", "background": "B4\\>", "but": "BUT\\>", "examples": "EXAMPLZ\\>", "feature": "OH HAI\\>", "given": "I CAN HAZ\\>", "scenario": "MISHUN\\>", "scenario_outline": "MISHUN SRSLY\\>", "then": "DEN\\>", "when": "WEN\\>"}, +      \"en-old": {"and": "Ond\\>\\|7\\>", "background": "\\%u00c6r\\>\\|Aer\\>", "but": "Ac\\>", "examples": "Se \\%u00f0e\\>\\|Se \\%u00fee\\>\\|Se the\\>", "feature": "Hw\\%u00e6t\\>\\|Hwaet\\>", "given": "\\%u00d0urh\\>\\|\\%u00deurh\\>\\|Thurh\\>", "scenario": "Swa\\>", "scenario_outline": "Swa hw\\%u00e6r swa\\>\\|Swa hwaer swa\\>", "then": "\\%u00d0a \\%u00f0e\\>\\|\\%u00dea \\%u00fee\\>\\|\\%u00dea\\>\\|\\%u00d0a\\>\\|Tha the\\>\\|Tha\\>", "when": "\\%u00d0a\\>\\|\\%u00dea\\>\\|Tha\\>"}, +      \"en-pirate": {"and": "Aye\\>", "background": "Yo-ho-ho\\>", "but": "Avast!\\>", "examples": "Dead men tell no tales\\>", "feature": "Ahoy matey!\\>", "given": "Gangway!\\>", "scenario": "Heave to\\>", "scenario_outline": "Shiver me timbers\\>", "then": "Let go and haul\\>", "when": "Blimey!\\>"}, +      \"en-tx": {"and": "And y'all\\>", "background": "Background\\>", "but": "But y'all\\>", "examples": "Examples\\>", "feature": "Feature\\>", "given": "Given y'all\\>", "scenario": "Scenario\\>", "scenario_outline": "All y'all\\>", "then": "Then y'all\\>", "when": "When y'all\\>"}, +      \"eo": {"and": "Kaj\\>", "background": "Fono\\>", "but": "Sed\\>", "examples": "Ekzemploj\\>", "feature": "Trajto\\>", "given": "Donita\\%u0135o\\>", "scenario": "Scenaro\\>", "scenario_outline": "Konturo de la scenaro\\>", "then": "Do\\>", "when": "Se\\>"}, +      \"es": {"and": "Y\\>", "background": "Antecedentes\\>", "but": "Pero\\>", "examples": "Ejemplos\\>", "feature": "Caracter\\%u00edstica\\>", "given": "Dadas\\>\\|Dados\\>\\|Dada\\>\\|Dado\\>", "scenario": "Escenario\\>", "scenario_outline": "Esquema del escenario\\>", "then": "Entonces\\>", "when": "Cuando\\>"}, +      \"et": {"and": "Ja\\>", "background": "Taust\\>", "but": "Kuid\\>", "examples": "Juhtumid\\>", "feature": "Omadus\\>", "given": "Eeldades\\>", "scenario": "Stsenaarium\\>", "scenario_outline": "Raamstsenaarium\\>", "then": "Siis\\>", "when": "Kui\\>"}, +      \"fa": {"and": "\\%u0648\\>", "background": "\\%u0632\\%u0645\\%u06cc\\%u0646\\%u0647\\>", "but": "\\%u0627\\%u0645\\%u0627\\>", "examples": "\\%u0646\\%u0645\\%u0648\\%u0646\\%u0647 \\%u0647\\%u0627\\>", "feature": "\\%u0648\\%u0650\\%u06cc\\%u0698\\%u06af\\%u06cc\\>", "given": "\\%u0628\\%u0627 \\%u0641\\%u0631\\%u0636\\>", "scenario": "\\%u0633\\%u0646\\%u0627\\%u0631\\%u06cc\\%u0648\\>", "scenario_outline": "\\%u0627\\%u0644\\%u06af\\%u0648\\%u06cc \\%u0633\\%u0646\\%u0627\\%u0631\\%u06cc\\%u0648\\>", "then": "\\%u0622\\%u0646\\%u06af\\%u0627\\%u0647\\>", "when": "\\%u0647\\%u0646\\%u06af\\%u0627\\%u0645\\%u06cc\\>"}, +      \"fi": {"and": "Ja\\>", "background": "Tausta\\>", "but": "Mutta\\>", "examples": "Tapaukset\\>", "feature": "Ominaisuus\\>", "given": "Oletetaan\\>", "scenario": "Tapaus\\>", "scenario_outline": "Tapausaihio\\>", "then": "Niin\\>", "when": "Kun\\>"}, +      \"fr": {"and": "Et\\>", "background": "Contexte\\>", "but": "Mais\\>", "examples": "Exemples\\>", "feature": "Fonctionnalit\\%u00e9\\>", "given": "\\%u00c9tant donn\\%u00e9es\\>\\|\\%u00c9tant donn\\%u00e9s\\>\\|\\%u00c9tant donn\\%u00e9e\\>\\|\\%u00c9tant donn\\%u00e9\\>\\|Etant donn\\%u00e9es\\>\\|Etant donn\\%u00e9s\\>\\|Etant donn\\%u00e9e\\>\\|Etant donn\\%u00e9\\>\\|Soit\\>", "scenario": "Sc\\%u00e9nario\\>", "scenario_outline": "Plan du sc\\%u00e9nario\\>\\|Plan du Sc\\%u00e9nario\\>", "then": "Alors\\>", "when": "Lorsqu'\\|Lorsque\\>\\|Quand\\>"}, +      \"gl": {"and": "E\\>", "background": "Contexto\\>", "but": "Mais\\>\\|Pero\\>", "examples": "Exemplos\\>", "feature": "Caracter\\%u00edstica\\>", "given": "Dadas\\>\\|Dados\\>\\|Dada\\>\\|Dado\\>", "scenario": "Escenario\\>", "scenario_outline": "Esbozo do escenario\\>", "then": "Ent\\%u00f3n\\>\\|Logo\\>", "when": "Cando\\>"}, +      \"he": {"and": "\\%u05d5\\%u05d2\\%u05dd\\>", "background": "\\%u05e8\\%u05e7\\%u05e2\\>", "but": "\\%u05d0\\%u05d1\\%u05dc\\>", "examples": "\\%u05d3\\%u05d5\\%u05d2\\%u05de\\%u05d0\\%u05d5\\%u05ea\\>", "feature": "\\%u05ea\\%u05db\\%u05d5\\%u05e0\\%u05d4\\>", "given": "\\%u05d1\\%u05d4\\%u05d9\\%u05e0\\%u05ea\\%u05df\\>", "scenario": "\\%u05ea\\%u05e8\\%u05d7\\%u05d9\\%u05e9\\>", "scenario_outline": "\\%u05ea\\%u05d1\\%u05e0\\%u05d9\\%u05ea \\%u05ea\\%u05e8\\%u05d7\\%u05d9\\%u05e9\\>", "then": "\\%u05d0\\%u05d6\\%u05d9\\>\\|\\%u05d0\\%u05d6\\>", "when": "\\%u05db\\%u05d0\\%u05e9\\%u05e8\\>"}, +      \"hi": {"and": "\\%u0924\\%u0925\\%u093e\\>\\|\\%u0914\\%u0930\\>", "background": "\\%u092a\\%u0943\\%u0937\\%u094d\\%u0920\\%u092d\\%u0942\\%u092e\\%u093f\\>", "but": "\\%u092a\\%u0930\\>", "examples": "\\%u0909\\%u0926\\%u093e\\%u0939\\%u0930\\%u0923\\>", "feature": "\\%u0930\\%u0942\\%u092a \\%u0932\\%u0947\\%u0916\\>", "given": "\\%u091a\\%u0942\\%u0902\\%u0915\\%u093f\\>\\|\\%u092f\\%u0926\\%u093f\\>\\|\\%u0905\\%u0917\\%u0930\\>", "scenario": "\\%u092a\\%u0930\\%u093f\\%u0926\\%u0943\\%u0936\\%u094d\\%u092f\\>", "scenario_outline": "\\%u092a\\%u0930\\%u093f\\%u0926\\%u0943\\%u0936\\%u094d\\%u092f \\%u0930\\%u0942\\%u092a\\%u0930\\%u0947\\%u0916\\%u093e\\>", "then": "\\%u0924\\%u092c\\>", "when": "\\%u091c\\%u092c\\>"}, +      \"hr": {"and": "I\\>", "background": "Pozadina\\>", "but": "Ali\\>", "examples": "Scenariji\\>\\|Primjeri\\>", "feature": "Mogu\\%u0107nost\\>\\|Mogucnost\\>\\|Osobina\\>", "given": "Zadano\\>\\|Zadani\\>\\|Zadan\\>", "scenario": "Scenarij\\>", "scenario_outline": "Koncept\\>\\|Skica\\>", "then": "Onda\\>", "when": "Kada\\>\\|Kad\\>"}, +      \"hu": {"and": "\\%u00c9s\\>", "background": "H\\%u00e1tt\\%u00e9r\\>", "but": "De\\>", "examples": "P\\%u00e9ld\\%u00e1k\\>", "feature": "Jellemz\\%u0151\\>", "given": "Amennyiben\\>\\|Adott\\>", "scenario": "Forgat\\%u00f3k\\%u00f6nyv\\>", "scenario_outline": "Forgat\\%u00f3k\\%u00f6nyv v\\%u00e1zlat\\>", "then": "Akkor\\>", "when": "Amikor\\>\\|Majd\\>\\|Ha\\>"}, +      \"id": {"and": "Dan\\>", "background": "Dasar\\>", "but": "Tapi\\>", "examples": "Contoh\\>", "feature": "Fitur\\>", "given": "Dengan\\>", "scenario": "Skenario\\>", "scenario_outline": "Skenario konsep\\>", "then": "Maka\\>", "when": "Ketika\\>"}, +      \"is": {"and": "Og\\>", "background": "Bakgrunnur\\>", "but": "En\\>", "examples": "Atbur\\%u00f0ar\\%u00e1sir\\>\\|D\\%u00e6mi\\>", "feature": "Eiginleiki\\>", "given": "Ef\\>", "scenario": "Atbur\\%u00f0ar\\%u00e1s\\>", "scenario_outline": "L\\%u00fdsing Atbur\\%u00f0ar\\%u00e1sar\\>\\|L\\%u00fdsing D\\%u00e6ma\\>", "then": "\\%u00de\\%u00e1\\>", "when": "\\%u00deegar\\>"}, +      \"it": {"and": "E\\>", "background": "Contesto\\>", "but": "Ma\\>", "examples": "Esempi\\>", "feature": "Funzionalit\\%u00e0\\>", "given": "Dato\\>\\|Data\\>\\|Dati\\>\\|Date\\>", "scenario": "Scenario\\>", "scenario_outline": "Schema dello scenario\\>", "then": "Allora\\>", "when": "Quando\\>"}, +      \"ja": {"and": "\\%u304b\\%u3064", "background": "\\%u80cc\\%u666f\\>", "but": "\\%u3057\\%u304b\\%u3057\\|\\%u305f\\%u3060\\%u3057\\|\\%u4f46\\%u3057", "examples": "\\%u30b5\\%u30f3\\%u30d7\\%u30eb\\>\\|\\%u4f8b\\>", "feature": "\\%u30d5\\%u30a3\\%u30fc\\%u30c1\\%u30e3\\>\\|\\%u6a5f\\%u80fd\\>", "given": "\\%u524d\\%u63d0", "scenario": "\\%u30b7\\%u30ca\\%u30ea\\%u30aa\\>", "scenario_outline": "\\%u30b7\\%u30ca\\%u30ea\\%u30aa\\%u30a2\\%u30a6\\%u30c8\\%u30e9\\%u30a4\\%u30f3\\>\\|\\%u30b7\\%u30ca\\%u30ea\\%u30aa\\%u30c6\\%u30f3\\%u30d7\\%u30ec\\%u30fc\\%u30c8\\>\\|\\%u30b7\\%u30ca\\%u30ea\\%u30aa\\%u30c6\\%u30f3\\%u30d7\\%u30ec\\>\\|\\%u30c6\\%u30f3\\%u30d7\\%u30ec\\>", "then": "\\%u306a\\%u3089\\%u3070", "when": "\\%u3082\\%u3057"}, +      \"ko": {"and": "\\%uadf8\\%ub9ac\\%uace0", "background": "\\%ubc30\\%uacbd\\>", "but": "\\%ud558\\%uc9c0\\%ub9cc\\|\\%ub2e8", "examples": "\\%uc608\\>", "feature": "\\%uae30\\%ub2a5\\>", "given": "\\%uc870\\%uac74\\|\\%uba3c\\%uc800", "scenario": "\\%uc2dc\\%ub098\\%ub9ac\\%uc624\\>", "scenario_outline": "\\%uc2dc\\%ub098\\%ub9ac\\%uc624 \\%uac1c\\%uc694\\>", "then": "\\%uadf8\\%ub7ec\\%uba74", "when": "\\%ub9cc\\%uc77c\\|\\%ub9cc\\%uc57d"}, +      \"lt": {"and": "Ir\\>", "background": "Kontekstas\\>", "but": "Bet\\>", "examples": "Pavyzd\\%u017eiai\\>\\|Scenarijai\\>\\|Variantai\\>", "feature": "Savyb\\%u0117\\>", "given": "Duota\\>", "scenario": "Scenarijus\\>", "scenario_outline": "Scenarijaus \\%u0161ablonas\\>", "then": "Tada\\>", "when": "Kai\\>"}, +      \"lu": {"and": "an\\>\\|a\\>", "background": "Hannergrond\\>", "but": "m\\%u00e4\\>\\|awer\\>", "examples": "Beispiller\\>", "feature": "Funktionalit\\%u00e9it\\>", "given": "ugeholl\\>", "scenario": "Szenario\\>", "scenario_outline": "Plang vum Szenario\\>", "then": "dann\\>", "when": "wann\\>"}, +      \"lv": {"and": "Un\\>", "background": "Situ\\%u0101cija\\>\\|Konteksts\\>", "but": "Bet\\>", "examples": "Piem\\%u0113ri\\>\\|Paraugs\\>", "feature": "Funkcionalit\\%u0101te\\>\\|F\\%u012b\\%u010da\\>", "given": "Kad\\>", "scenario": "Scen\\%u0101rijs\\>", "scenario_outline": "Scen\\%u0101rijs p\\%u0113c parauga\\>", "then": "Tad\\>", "when": "Ja\\>"}, +      \"nl": {"and": "En\\>", "background": "Achtergrond\\>", "but": "Maar\\>", "examples": "Voorbeelden\\>", "feature": "Functionaliteit\\>", "given": "Gegeven\\>\\|Stel\\>", "scenario": "Scenario\\>", "scenario_outline": "Abstract Scenario\\>", "then": "Dan\\>", "when": "Als\\>"}, +      \"no": {"and": "Og\\>", "background": "Bakgrunn\\>", "but": "Men\\>", "examples": "Eksempler\\>", "feature": "Egenskap\\>", "given": "Gitt\\>", "scenario": "Scenario\\>", "scenario_outline": "Abstrakt Scenario\\>\\|Scenariomal\\>", "then": "S\\%u00e5\\>", "when": "N\\%u00e5r\\>"}, +      \"pl": {"and": "Oraz\\>\\|I\\>", "background": "Za\\%u0142o\\%u017cenia\\>", "but": "Ale\\>", "examples": "Przyk\\%u0142ady\\>", "feature": "W\\%u0142a\\%u015bciwo\\%u015b\\%u0107\\>\\|Potrzeba biznesowa\\>\\|Funkcja\\>\\|Aspekt\\>", "given": "Zak\\%u0142adaj\\%u0105c\\>\\|Maj\\%u0105c\\>", "scenario": "Scenariusz\\>", "scenario_outline": "Szablon scenariusza\\>", "then": "Wtedy\\>", "when": "Je\\%u017celi\\>\\|Je\\%u015bli\\>\\|Kiedy\\>\\|Gdy\\>"}, +      \"pt": {"and": "E\\>", "background": "Cen\\%u00e1rio de Fundo\\>\\|Cenario de Fundo\\>\\|Contexto\\>\\|Fundo\\>", "but": "Mas\\>", "examples": "Cen\\%u00e1rios\\>\\|Exemplos\\>\\|Cenarios\\>", "feature": "Caracter\\%u00edstica\\>\\|Funcionalidade\\>\\|Caracteristica\\>", "given": "Dadas\\>\\|Dados\\>\\|Dada\\>\\|Dado\\>", "scenario": "Cen\\%u00e1rio\\>\\|Cenario\\>", "scenario_outline": "Delinea\\%u00e7\\%u00e3o do Cen\\%u00e1rio\\>\\|Esquema do Cen\\%u00e1rio\\>\\|Delineacao do Cenario\\>\\|Esquema do Cenario\\>", "then": "Ent\\%u00e3o\\>\\|Entao\\>", "when": "Quando\\>"}, +      \"ro": {"and": "\\%u015ei\\>\\|\\%u0218i\\>\\|Si\\>", "background": "Context\\>", "but": "Dar\\>", "examples": "Exemple\\>", "feature": "Func\\%u0163ionalitate\\>\\|Func\\%u021bionalitate\\>\\|Functionalitate\\>", "given": "Da\\%u0163i fiind\\>\\|Da\\%u021bi fiind\\>\\|Dati fiind\\>\\|Date fiind\\>\\|Dat fiind\\>", "scenario": "Scenariu\\>", "scenario_outline": "Structur\\%u0103 scenariu\\>\\|Structura scenariu\\>", "then": "Atunci\\>", "when": "C\\%u00e2nd\\>\\|Cand\\>"}, +      \"ru": {"and": "\\%u041a \\%u0442\\%u043e\\%u043c\\%u0443 \\%u0436\\%u0435\\>\\|\\%u0422\\%u0430\\%u043a\\%u0436\\%u0435\\>\\|\\%u0418\\>", "background": "\\%u041f\\%u0440\\%u0435\\%u0434\\%u044b\\%u0441\\%u0442\\%u043e\\%u0440\\%u0438\\%u044f\\>\\|\\%u041a\\%u043e\\%u043d\\%u0442\\%u0435\\%u043a\\%u0441\\%u0442\\>", "but": "\\%u041d\\%u043e\\>\\|\\%u0410\\>", "examples": "\\%u041f\\%u0440\\%u0438\\%u043c\\%u0435\\%u0440\\%u044b\\>", "feature": "\\%u0424\\%u0443\\%u043d\\%u043a\\%u0446\\%u0438\\%u043e\\%u043d\\%u0430\\%u043b\\>\\|\\%u0421\\%u0432\\%u043e\\%u0439\\%u0441\\%u0442\\%u0432\\%u043e\\>\\|\\%u0424\\%u0443\\%u043d\\%u043a\\%u0446\\%u0438\\%u044f\\>", "given": "\\%u0414\\%u043e\\%u043f\\%u0443\\%u0441\\%u0442\\%u0438\\%u043c\\>\\|\\%u041f\\%u0443\\%u0441\\%u0442\\%u044c\\>\\|\\%u0414\\%u0430\\%u043d\\%u043e\\>", "scenario": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0439\\>", "scenario_outline": "\\%u0421\\%u0442\\%u0440\\%u0443\\%u043a\\%u0442\\%u0443\\%u0440\\%u0430 \\%u0441\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u044f\\>", "then": "\\%u0422\\%u043e\\%u0433\\%u0434\\%u0430\\>\\|\\%u0422\\%u043e\\>", "when": "\\%u041a\\%u043e\\%u0433\\%u0434\\%u0430\\>\\|\\%u0415\\%u0441\\%u043b\\%u0438\\>"}, +      \"sk": {"and": "A z\\%u00e1rove\\%u0148\\>\\|A taktie\\%u017e\\>\\|A tie\\%u017e\\>\\|A\\>", "background": "Pozadie\\>", "but": "Ale\\>", "examples": "Pr\\%u00edklady\\>", "feature": "Po\\%u017eiadavka\\>\\|Vlastnos\\%u0165\\>\\|Funkcia\\>", "given": "Za predpokladu\\>\\|Pokia\\%u013e\\>", "scenario": "Scen\\%u00e1r\\>", "scenario_outline": "N\\%u00e1\\%u010drt Scen\\%u00e1ru\\>\\|N\\%u00e1\\%u010drt Scen\\%u00e1ra\\>\\|Osnova Scen\\%u00e1ra\\>", "then": "Potom\\>\\|Tak\\>", "when": "Ke\\%u010f\\>\\|Ak\\>"}, +      \"sr-Cyrl": {"and": "\\%u0418\\>", "background": "\\%u041a\\%u043e\\%u043d\\%u0442\\%u0435\\%u043a\\%u0441\\%u0442\\>\\|\\%u041f\\%u043e\\%u0437\\%u0430\\%u0434\\%u0438\\%u043d\\%u0430\\>\\|\\%u041e\\%u0441\\%u043d\\%u043e\\%u0432\\%u0430\\>", "but": "\\%u0410\\%u043b\\%u0438\\>", "examples": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0458\\%u0438\\>\\|\\%u041f\\%u0440\\%u0438\\%u043c\\%u0435\\%u0440\\%u0438\\>", "feature": "\\%u0424\\%u0443\\%u043d\\%u043a\\%u0446\\%u0438\\%u043e\\%u043d\\%u0430\\%u043b\\%u043d\\%u043e\\%u0441\\%u0442\\>\\|\\%u041c\\%u043e\\%u0433\\%u0443\\%u045b\\%u043d\\%u043e\\%u0441\\%u0442\\>\\|\\%u041e\\%u0441\\%u043e\\%u0431\\%u0438\\%u043d\\%u0430\\>", "given": "\\%u0417\\%u0430\\%u0434\\%u0430\\%u0442\\%u043e\\>\\|\\%u0417\\%u0430\\%u0434\\%u0430\\%u0442\\%u0435\\>\\|\\%u0417\\%u0430\\%u0434\\%u0430\\%u0442\\%u0438\\>", "scenario": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u043e\\>\\|\\%u041f\\%u0440\\%u0438\\%u043c\\%u0435\\%u0440\\>", "scenario_outline": "\\%u0421\\%u0442\\%u0440\\%u0443\\%u043a\\%u0442\\%u0443\\%u0440\\%u0430 \\%u0441\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0458\\%u0430\\>\\|\\%u041a\\%u043e\\%u043d\\%u0446\\%u0435\\%u043f\\%u0442\\>\\|\\%u0421\\%u043a\\%u0438\\%u0446\\%u0430\\>", "then": "\\%u041e\\%u043d\\%u0434\\%u0430\\>", "when": "\\%u041a\\%u0430\\%u0434\\%u0430\\>\\|\\%u041a\\%u0430\\%u0434\\>"}, +      \"sr-Latn": {"and": "I\\>", "background": "Kontekst\\>\\|Pozadina\\>\\|Osnova\\>", "but": "Ali\\>", "examples": "Scenariji\\>\\|Primeri\\>", "feature": "Mogu\\%u0107nost\\>\\|Funkcionalnost\\>\\|Mogucnost\\>\\|Osobina\\>", "given": "Zadato\\>\\|Zadate\\>\\|Zatati\\>", "scenario": "Scenario\\>\\|Primer\\>", "scenario_outline": "Struktura scenarija\\>\\|Koncept\\>\\|Skica\\>", "then": "Onda\\>", "when": "Kada\\>\\|Kad\\>"}, +      \"sv": {"and": "Och\\>", "background": "Bakgrund\\>", "but": "Men\\>", "examples": "Exempel\\>", "feature": "Egenskap\\>", "given": "Givet\\>", "scenario": "Scenario\\>", "scenario_outline": "Abstrakt Scenario\\>\\|Scenariomall\\>", "then": "S\\%u00e5\\>", "when": "N\\%u00e4r\\>"}, +      \"th": {"and": "\\%u0e41\\%u0e25\\%u0e30\\>", "background": "\\%u0e41\\%u0e19\\%u0e27\\%u0e04\\%u0e34\\%u0e14\\>", "but": "\\%u0e41\\%u0e15\\%u0e48\\>", "examples": "\\%u0e0a\\%u0e38\\%u0e14\\%u0e02\\%u0e2d\\%u0e07\\%u0e40\\%u0e2b\\%u0e15\\%u0e38\\%u0e01\\%u0e32\\%u0e23\\%u0e13\\%u0e4c\\>\\|\\%u0e0a\\%u0e38\\%u0e14\\%u0e02\\%u0e2d\\%u0e07\\%u0e15\\%u0e31\\%u0e27\\%u0e2d\\%u0e22\\%u0e48\\%u0e32\\%u0e07\\>", "feature": "\\%u0e04\\%u0e27\\%u0e32\\%u0e21\\%u0e15\\%u0e49\\%u0e2d\\%u0e07\\%u0e01\\%u0e32\\%u0e23\\%u0e17\\%u0e32\\%u0e07\\%u0e18\\%u0e38\\%u0e23\\%u0e01\\%u0e34\\%u0e08\\>\\|\\%u0e04\\%u0e27\\%u0e32\\%u0e21\\%u0e2a\\%u0e32\\%u0e21\\%u0e32\\%u0e23\\%u0e16\\>\\|\\%u0e42\\%u0e04\\%u0e23\\%u0e07\\%u0e2b\\%u0e25\\%u0e31\\%u0e01\\>", "given": "\\%u0e01\\%u0e33\\%u0e2b\\%u0e19\\%u0e14\\%u0e43\\%u0e2b\\%u0e49\\>", "scenario": "\\%u0e40\\%u0e2b\\%u0e15\\%u0e38\\%u0e01\\%u0e32\\%u0e23\\%u0e13\\%u0e4c\\>", "scenario_outline": "\\%u0e42\\%u0e04\\%u0e23\\%u0e07\\%u0e2a\\%u0e23\\%u0e49\\%u0e32\\%u0e07\\%u0e02\\%u0e2d\\%u0e07\\%u0e40\\%u0e2b\\%u0e15\\%u0e38\\%u0e01\\%u0e32\\%u0e23\\%u0e13\\%u0e4c\\>\\|\\%u0e2a\\%u0e23\\%u0e38\\%u0e1b\\%u0e40\\%u0e2b\\%u0e15\\%u0e38\\%u0e01\\%u0e32\\%u0e23\\%u0e13\\%u0e4c\\>", "then": "\\%u0e14\\%u0e31\\%u0e07\\%u0e19\\%u0e31\\%u0e49\\%u0e19\\>", "when": "\\%u0e40\\%u0e21\\%u0e37\\%u0e48\\%u0e2d\\>"}, +      \"tl": {"and": "\\%u0c2e\\%u0c30\\%u0c3f\\%u0c2f\\%u0c41\\>", "background": "\\%u0c28\\%u0c47\\%u0c2a\\%u0c25\\%u0c4d\\%u0c2f\\%u0c02\\>", "but": "\\%u0c15\\%u0c3e\\%u0c28\\%u0c3f\\>", "examples": "\\%u0c09\\%u0c26\\%u0c3e\\%u0c39\\%u0c30\\%u0c23\\%u0c32\\%u0c41\\>", "feature": "\\%u0c17\\%u0c41\\%u0c23\\%u0c2e\\%u0c41\\>", "given": "\\%u0c1a\\%u0c46\\%u0c2a\\%u0c4d\\%u0c2a\\%u0c2c\\%u0c21\\%u0c3f\\%u0c28\\%u0c26\\%u0c3f\\>", "scenario": "\\%u0c38\\%u0c28\\%u0c4d\\%u0c28\\%u0c3f\\%u0c35\\%u0c47\\%u0c36\\%u0c02\\>", "scenario_outline": "\\%u0c15\\%u0c25\\%u0c28\\%u0c02\\>", "then": "\\%u0c05\\%u0c2a\\%u0c4d\\%u0c2a\\%u0c41\\%u0c21\\%u0c41\\>", "when": "\\%u0c08 \\%u0c2a\\%u0c30\\%u0c3f\\%u0c38\\%u0c4d\\%u0c25\\%u0c3f\\%u0c24\\%u0c3f\\%u0c32\\%u0c4b\\>"}, +      \"tr": {"and": "Ve\\>", "background": "Ge\\%u00e7mi\\%u015f\\>", "but": "Fakat\\>\\|Ama\\>", "examples": "\\%u00d6rnekler\\>", "feature": "\\%u00d6zellik\\>", "given": "Diyelim ki\\>", "scenario": "Senaryo\\>", "scenario_outline": "Senaryo tasla\\%u011f\\%u0131\\>", "then": "O zaman\\>", "when": "E\\%u011fer ki\\>"}, +      \"tt": {"and": "\\%u04ba\\%u04d9\\%u043c\\>\\|\\%u0412\\%u04d9\\>", "background": "\\%u041a\\%u0435\\%u0440\\%u0435\\%u0448\\>", "but": "\\%u041b\\%u04d9\\%u043a\\%u0438\\%u043d\\>\\|\\%u04d8\\%u043c\\%u043c\\%u0430\\>", "examples": "\\%u04ae\\%u0440\\%u043d\\%u04d9\\%u043a\\%u043b\\%u04d9\\%u0440\\>\\|\\%u041c\\%u0438\\%u0441\\%u0430\\%u043b\\%u043b\\%u0430\\%u0440\\>", "feature": "\\%u04ae\\%u0437\\%u0435\\%u043d\\%u0447\\%u04d9\\%u043b\\%u0435\\%u043a\\%u043b\\%u0435\\%u043b\\%u0435\\%u043a\\>\\|\\%u041c\\%u04e9\\%u043c\\%u043a\\%u0438\\%u043d\\%u043b\\%u0435\\%u043a\\>", "given": "\\%u04d8\\%u0439\\%u0442\\%u0438\\%u043a\\>", "scenario": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0439\\>", "scenario_outline": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0439\\%u043d\\%u044b\\%u04a3 \\%u0442\\%u04e9\\%u0437\\%u0435\\%u043b\\%u0435\\%u0448\\%u0435\\>", "then": "\\%u041d\\%u04d9\\%u0442\\%u0438\\%u0497\\%u04d9\\%u0434\\%u04d9\\>", "when": "\\%u04d8\\%u0433\\%u04d9\\%u0440\\>"}, +      \"uk": {"and": "\\%u0410 \\%u0442\\%u0430\\%u043a\\%u043e\\%u0436\\>\\|\\%u0422\\%u0430\\>\\|\\%u0406\\>", "background": "\\%u041f\\%u0435\\%u0440\\%u0435\\%u0434\\%u0443\\%u043c\\%u043e\\%u0432\\%u0430\\>", "but": "\\%u0410\\%u043b\\%u0435\\>", "examples": "\\%u041f\\%u0440\\%u0438\\%u043a\\%u043b\\%u0430\\%u0434\\%u0438\\>", "feature": "\\%u0424\\%u0443\\%u043d\\%u043a\\%u0446\\%u0456\\%u043e\\%u043d\\%u0430\\%u043b\\>", "given": "\\%u041f\\%u0440\\%u0438\\%u043f\\%u0443\\%u0441\\%u0442\\%u0438\\%u043c\\%u043e, \\%u0449\\%u043e\\>\\|\\%u041f\\%u0440\\%u0438\\%u043f\\%u0443\\%u0441\\%u0442\\%u0438\\%u043c\\%u043e\\>\\|\\%u041d\\%u0435\\%u0445\\%u0430\\%u0439\\>\\|\\%u0414\\%u0430\\%u043d\\%u043e\\>", "scenario": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0456\\%u0439\\>", "scenario_outline": "\\%u0421\\%u0442\\%u0440\\%u0443\\%u043a\\%u0442\\%u0443\\%u0440\\%u0430 \\%u0441\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0456\\%u044e\\>", "then": "\\%u0422\\%u043e\\%u0434\\%u0456\\>\\|\\%u0422\\%u043e\\>", "when": "\\%u042f\\%u043a\\%u0449\\%u043e\\>\\|\\%u041a\\%u043e\\%u043b\\%u0438\\>"}, +      \"uz": {"and": "\\%u0412\\%u0430\\>", "background": "\\%u0422\\%u0430\\%u0440\\%u0438\\%u0445\\>", "but": "\\%u041b\\%u0435\\%u043a\\%u0438\\%u043d\\>\\|\\%u0411\\%u0438\\%u0440\\%u043e\\%u043a\\>\\|\\%u0410\\%u043c\\%u043c\\%u043e\\>", "examples": "\\%u041c\\%u0438\\%u0441\\%u043e\\%u043b\\%u043b\\%u0430\\%u0440\\>", "feature": "\\%u0424\\%u0443\\%u043d\\%u043a\\%u0446\\%u0438\\%u043e\\%u043d\\%u0430\\%u043b\\>", "given": "\\%u0410\\%u0433\\%u0430\\%u0440\\>", "scenario": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0439\\>", "scenario_outline": "\\%u0421\\%u0446\\%u0435\\%u043d\\%u0430\\%u0440\\%u0438\\%u0439 \\%u0441\\%u0442\\%u0440\\%u0443\\%u043a\\%u0442\\%u0443\\%u0440\\%u0430\\%u0441\\%u0438\\>", "then": "\\%u0423\\%u043d\\%u0434\\%u0430\\>", "when": "\\%u0410\\%u0433\\%u0430\\%u0440\\>"}, +      \"vi": {"and": "V\\%u00e0\\>", "background": "B\\%u1ed1i c\\%u1ea3nh\\>", "but": "Nh\\%u01b0ng\\>", "examples": "D\\%u1eef li\\%u1ec7u\\>", "feature": "T\\%u00ednh n\\%u0103ng\\>", "given": "Bi\\%u1ebft\\>\\|Cho\\>", "scenario": "T\\%u00ecnh hu\\%u1ed1ng\\>\\|K\\%u1ecbch b\\%u1ea3n\\>", "scenario_outline": "Khung t\\%u00ecnh hu\\%u1ed1ng\\>\\|Khung k\\%u1ecbch b\\%u1ea3n\\>", "then": "Th\\%u00ec\\>", "when": "Khi\\>"}, +      \"zh-CN": {"and": "\\%u800c\\%u4e14\\|\\%u5e76\\%u4e14\\|\\%u540c\\%u65f6", "background": "\\%u80cc\\%u666f\\>", "but": "\\%u4f46\\%u662f", "examples": "\\%u4f8b\\%u5b50\\>", "feature": "\\%u529f\\%u80fd\\>", "given": "\\%u5047\\%u5982\\|\\%u5047\\%u8bbe\\|\\%u5047\\%u5b9a", "scenario": "\\%u573a\\%u666f\\>\\|\\%u5267\\%u672c\\>", "scenario_outline": "\\%u573a\\%u666f\\%u5927\\%u7eb2\\>\\|\\%u5267\\%u672c\\%u5927\\%u7eb2\\>", "then": "\\%u90a3\\%u4e48", "when": "\\%u5f53"}, +      \"zh-TW": {"and": "\\%u800c\\%u4e14\\|\\%u4e26\\%u4e14\\|\\%u540c\\%u6642", "background": "\\%u80cc\\%u666f\\>", "but": "\\%u4f46\\%u662f", "examples": "\\%u4f8b\\%u5b50\\>", "feature": "\\%u529f\\%u80fd\\>", "given": "\\%u5047\\%u5982\\|\\%u5047\\%u8a2d\\|\\%u5047\\%u5b9a", "scenario": "\\%u5834\\%u666f\\>\\|\\%u5287\\%u672c\\>", "scenario_outline": "\\%u5834\\%u666f\\%u5927\\%u7db1\\>\\|\\%u5287\\%u672c\\%u5927\\%u7db1\\>", "then": "\\%u90a3\\%u9ebc", "when": "\\%u7576"}} + +function! s:pattern(key) +  let language = matchstr(getline(1),'#\s*language:\s*\zs\S\+') +  if &fileencoding == 'latin1' && language == '' +    let language = 'en' +  endif +  if has_key(g:cucumber_languages, language) +    let languages = [g:cucumber_languages[language]] +  else +    let languages = values(g:cucumber_languages) +  end +  return '\<\%('.join(map(languages,'get(v:val,a:key,"\\%(a\\&b\\)")'),'\|').'\)' +endfunction + +function! s:Add(name) +  let next = " skipempty skipwhite nextgroup=".join(map(["Region","AndRegion","ButRegion","Comment","String","Table"],'"cucumber".a:name.v:val'),",") +  exe "syn region cucumber".a:name.'Region matchgroup=cucumber'.a:name.' start="\%(^\s*\)\@<=\%('.s:pattern(tolower(a:name)).'\)" end="$"'.next +  exe 'syn region cucumber'.a:name.'AndRegion matchgroup=cucumber'.a:name.'And start="\%(^\s*\)\@<='.s:pattern('and').'" end="$" contained'.next +  exe 'syn region cucumber'.a:name.'ButRegion matchgroup=cucumber'.a:name.'But start="\%(^\s*\)\@<='.s:pattern('but').'" end="$" contained'.next +  exe 'syn match cucumber'.a:name.'Comment "\%(^\s*\)\@<=#.*" contained'.next +  exe 'syn region cucumber'.a:name.'String start=+\%(^\s*\)\@<="""+ end=+"""+ contained'.next +  exe 'syn match cucumber'.a:name.'Table "\%(^\s*\)\@<=|.*" contained contains=cucumberDelimiter'.next +  exe 'hi def link cucumber'.a:name.'Comment cucumberComment' +  exe 'hi def link cucumber'.a:name.'String cucumberString' +  exe 'hi def link cucumber'.a:name.'But cucumber'.a:name.'And' +  exe 'hi def link cucumber'.a:name.'And cucumber'.a:name +  exe 'syn cluster cucumberStepRegions add=cucumber'.a:name.'Region,cucumber'.a:name.'AndRegion,cucumber'.a:name.'ButRegion' +endfunction + +syn match   cucumberComment  "\%(^\s*\)\@<=#.*" +syn match   cucumberComment  "\%(\%^\s*\)\@<=#.*" contains=cucumberLanguage +syn match   cucumberLanguage "\%(#\s*\)\@<=language:" contained +syn match   cucumberUnparsed "\S.*" nextgroup=cucumberUnparsedComment,cucumberUnparsed,cucumberTags,cucumberBackground,cucumberScenario,cucumberScenarioOutline,cucumberExamples skipwhite skipempty contained +syn match   cucumberUnparsedComment "#.*" nextgroup=cucumberUnparsedComment,cucumberUnparsed,cucumberTags,cucumberBackground,cucumberScenario,cucumberScenarioOutline,cucumberExamples skipwhite skipempty contained + +exe 'syn match cucumberFeature "\%(^\s*\)\@<='.s:pattern('feature').':" nextgroup=cucumberUnparsedComment,cucumberUnparsed,cucumberBackground,cucumberScenario,cucumberScenarioOutline,cucumberExamples skipwhite skipempty' +exe 'syn match cucumberBackground "\%(^\s*\)\@<='.s:pattern('background').':"' +exe 'syn match cucumberScenario "\%(^\s*\)\@<='.s:pattern('scenario').':"' +exe 'syn match cucumberScenarioOutline "\%(^\s*\)\@<='.s:pattern('scenario_outline').':"' +exe 'syn match cucumberExamples "\%(^\s*\)\@<='.s:pattern('examples').':" nextgroup=cucumberExampleTable skipempty skipwhite' + +syn match   cucumberPlaceholder   "<[^<>]*>" contained containedin=@cucumberStepRegions +syn match   cucumberExampleTable  "\%(^\s*\)\@<=|.*" contains=cucumberDelimiter +syn match   cucumberDelimiter     "\\\@<!\%(\\\\\)*\zs|" contained +syn match   cucumberTags          "\%(^\s*\)\@<=\%(@[^@[:space:]]\+\s\+\)*@[^@[:space:]]\+\s*$" contains=@NoSpell + +call s:Add('Then') +call s:Add('When') +call s:Add('Given') + +hi def link cucumberUnparsedComment   cucumberComment +hi def link cucumberComment           Comment +hi def link cucumberLanguage          SpecialComment +hi def link cucumberFeature           Macro +hi def link cucumberBackground        Define +hi def link cucumberScenario          Define +hi def link cucumberScenarioOutline   Define +hi def link cucumberExamples          Define +hi def link cucumberPlaceholder       Constant +hi def link cucumberDelimiter         Delimiter +hi def link cucumberTags              Tag +hi def link cucumberString            String +hi def link cucumberGiven             Conditional +hi def link cucumberWhen              Function +hi def link cucumberThen              Type + +let b:current_syntax = "cucumber" + +" vim:set sts=2 sw=2: diff --git a/syntax/eruby.vim b/syntax/eruby.vim new file mode 100644 index 00000000..c20b086b --- /dev/null +++ b/syntax/eruby.vim @@ -0,0 +1,74 @@ +" Vim syntax file +" Language:		eRuby +" Maintainer:		Tim Pope <vimNOSPAM@tpope.org> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> + +if exists("b:current_syntax") +  finish +endif + +if !exists("main_syntax") +  let main_syntax = 'eruby' +endif + +if !exists("g:eruby_default_subtype") +  let g:eruby_default_subtype = "html" +endif + +if &filetype =~ '^eruby\.' +  let b:eruby_subtype = matchstr(&filetype,'^eruby\.\zs\w\+') +elseif !exists("b:eruby_subtype") && main_syntax == 'eruby' +  let s:lines = getline(1)."\n".getline(2)."\n".getline(3)."\n".getline(4)."\n".getline(5)."\n".getline("$") +  let b:eruby_subtype = matchstr(s:lines,'eruby_subtype=\zs\w\+') +  if b:eruby_subtype == '' +    let b:eruby_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.erb\|\.eruby\|\.erubis\)\+$','',''),'\.\zs\w\+$') +  endif +  if b:eruby_subtype == 'rhtml' +    let b:eruby_subtype = 'html' +  elseif b:eruby_subtype == 'rb' +    let b:eruby_subtype = 'ruby' +  elseif b:eruby_subtype == 'yml' +    let b:eruby_subtype = 'yaml' +  elseif b:eruby_subtype == 'js' +    let b:eruby_subtype = 'javascript' +  elseif b:eruby_subtype == 'txt' +    " Conventional; not a real file type +    let b:eruby_subtype = 'text' +  elseif b:eruby_subtype == '' +    let b:eruby_subtype = g:eruby_default_subtype +  endif +endif + +if !exists("b:eruby_nest_level") +  let b:eruby_nest_level = strlen(substitute(substitute(substitute(expand("%:t"),'@','','g'),'\c\.\%(erb\|rhtml\)\>','@','g'),'[^@]','','g')) +endif +if !b:eruby_nest_level +  let b:eruby_nest_level = 1 +endif + +if exists("b:eruby_subtype") && b:eruby_subtype != '' +  exe "runtime! syntax/".b:eruby_subtype.".vim" +  unlet! b:current_syntax +endif +syn include @rubyTop syntax/ruby.vim + +syn cluster erubyRegions contains=erubyOneLiner,erubyBlock,erubyExpression,erubyComment + +exe 'syn region  erubyOneLiner   matchgroup=erubyDelimiter start="^%\{1,'.b:eruby_nest_level.'\}%\@!"    end="$"     contains=@rubyTop	     containedin=ALLBUT,@erubyRegions keepend oneline' +exe 'syn region  erubyBlock      matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}%\@!-\=" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop  containedin=ALLBUT,@erubyRegions keepend' +exe 'syn region  erubyExpression matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}=\{1,4}" end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=@rubyTop  containedin=ALLBUT,@erubyRegions keepend' +exe 'syn region  erubyComment    matchgroup=erubyDelimiter start="<%\{1,'.b:eruby_nest_level.'\}-\=#"    end="[=-]\=%\@<!%\{1,'.b:eruby_nest_level.'\}>" contains=rubyTodo,@Spell containedin=ALLBUT,@erubyRegions keepend' + +" Define the default highlighting. + +hi def link erubyDelimiter		PreProc +hi def link erubyComment		Comment + +let b:current_syntax = 'eruby' + +if main_syntax == 'eruby' +  unlet main_syntax +endif + +" vim: nowrap sw=2 sts=2 ts=8: diff --git a/syntax/haml.vim b/syntax/haml.vim new file mode 100644 index 00000000..bf7a0736 --- /dev/null +++ b/syntax/haml.vim @@ -0,0 +1,109 @@ +" Vim syntax file +" Language:	Haml +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Filenames:	*.haml +" Last Change:	2010 Aug 09 + +if exists("b:current_syntax") +  finish +endif + +if !exists("main_syntax") +  let main_syntax = 'haml' +endif +let b:ruby_no_expensive = 1 + +runtime! syntax/html.vim +unlet! b:current_syntax +silent! syn include @hamlSassTop syntax/sass.vim +unlet! b:current_syntax +syn include @hamlRubyTop syntax/ruby.vim + +syn case match + +syn region  rubyCurlyBlock   start="{" end="}" contains=@hamlRubyTop contained +syn cluster hamlRubyTop add=rubyCurlyBlock + +syn cluster hamlComponent    contains=hamlAttributes,hamlAttributesHash,hamlClassChar,hamlIdChar,hamlObject,hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable +syn cluster hamlEmbeddedRuby contains=hamlAttributesHash,hamlObject,hamlRuby,hamlRubyFilter +syn cluster hamlTop          contains=hamlBegin,hamlPlainFilter,hamlRubyFilter,hamlSassFilter,hamlComment,hamlHtmlComment + +syn match   hamlBegin "^\s*\%([<>]\|&[^=~ ]\)\@!" nextgroup=hamlTag,hamlClassChar,hamlIdChar,hamlRuby,hamlPlainChar,hamlInterpolatable + +syn match   hamlTag        "%\w\+\%(:\w\+\)\=" contained contains=htmlTagName,htmlSpecialTagName nextgroup=@hamlComponent +syn region  hamlAttributes     matchgroup=hamlAttributesDelimiter start="(" end=")" contained contains=htmlArg,hamlAttributeString,hamlAttributeVariable,htmlEvent,htmlCssDefinition nextgroup=@hamlComponent +syn region  hamlAttributesHash matchgroup=hamlAttributesDelimiter start="{" end="}" contained contains=@hamlRubyTop nextgroup=@hamlComponent +syn region  hamlObject         matchgroup=hamlObjectDelimiter     start="\[" end="\]" contained contains=@hamlRubyTop nextgroup=@hamlComponent +syn match   hamlDespacer "[<>]" contained nextgroup=hamlDespacer,hamlSelfCloser,hamlRuby,hamlPlainChar,hamlInterpolatable +syn match   hamlSelfCloser "/" contained +syn match   hamlClassChar "\." contained nextgroup=hamlClass +syn match   hamlIdChar "#{\@!" contained nextgroup=hamlId +syn match   hamlClass "\%(\w\|-\)\+" contained nextgroup=@hamlComponent +syn match   hamlId    "\%(\w\|-\)\+" contained nextgroup=@hamlComponent +syn region  hamlDocType start="^\s*!!!" end="$" + +syn region  hamlRuby   matchgroup=hamlRubyOutputChar start="[!&]\==\|\~" skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend +syn region  hamlRuby   matchgroup=hamlRubyChar       start="-"           skip=",\s*$" end="$" contained contains=@hamlRubyTop keepend +syn match   hamlPlainChar "\\" contained +syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="!\===\|!=\@!" end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape,@hamlHtmlTop +syn region hamlInterpolatable matchgroup=hamlInterpolatableChar start="&==\|&=\@!"   end="$" keepend contained contains=hamlInterpolation,hamlInterpolationEscape +syn region hamlInterpolation matchgroup=hamlInterpolationDelimiter start="#{" end="}" contains=@hamlRubyTop containedin=javascriptStringS,javascriptStringD +syn match  hamlInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)" +syn region hamlErbInterpolation matchgroup=hamlInterpolationDelimiter start="<%[=-]\=" end="-\=%>" contained contains=@hamlRubyTop + +syn region  hamlAttributeString start=+\%(=\s*\)\@<='+ skip=+\%(\\\\\)*\\'+ end=+'+ contains=hamlInterpolation,hamlInterpolationEscape +syn region  hamlAttributeString start=+\%(=\s*\)\@<="+ skip=+\%(\\\\\)*\\"+ end=+"+ contains=hamlInterpolation,hamlInterpolationEscape +syn match   hamlAttributeVariable "\%(=\s*\)\@<=\%(@@\=\|\$\)\=\w\+" contained + +syn match   hamlHelper  "\<action_view?\|\<block_is_haml?\|\<is_haml?\|\.\@<!\<flatten" contained containedin=@hamlEmbeddedRuby,@hamlRubyTop +syn keyword hamlHelper   capture_haml escape_once find_and_preserve haml_concat haml_indent haml_tag html_attrs html_esape init_haml_helpers list_of non_haml precede preserve succeed surround tab_down tab_up page_class contained containedin=@hamlEmbeddedRuby,@hamlRubyTop + +syn cluster hamlHtmlTop contains=@htmlTop,htmlBold,htmlItalic,htmlUnderline +syn region  hamlPlainFilter      matchgroup=hamlFilter start="^\z(\s*\):\%(plain\|preserve\|redcloth\|textile\|markdown\|maruku\)\s*$" end="^\%(\z1 \| *$\)\@!" contains=@hamlHtmlTop,hamlInterpolation +syn region  hamlEscapedFilter    matchgroup=hamlFilter start="^\z(\s*\):\%(escaped\|cdata\)\s*$"    end="^\%(\z1 \| *$\)\@!" contains=hamlInterpolation +syn region  hamlErbFilter        matchgroup=hamlFilter start="^\z(\s*\):erb\s*$"        end="^\%(\z1 \| *$\)\@!" contains=@hamlHtmlTop,hamlErbInterpolation +syn region  hamlRubyFilter       matchgroup=hamlFilter start="^\z(\s*\):ruby\s*$"       end="^\%(\z1 \| *$\)\@!" contains=@hamlRubyTop +syn region  hamlJavascriptFilter matchgroup=hamlFilter start="^\z(\s*\):javascript\s*$" end="^\%(\z1 \| *$\)\@!" contains=@htmlJavaScript,hamlInterpolation keepend +syn region  hamlCSSFilter        matchgroup=hamlFilter start="^\z(\s*\):css\s*$"        end="^\%(\z1 \| *$\)\@!" contains=@htmlCss,hamlInterpolation keepend +syn region  hamlSassFilter       matchgroup=hamlFilter start="^\z(\s*\):sass\s*$"       end="^\%(\z1 \| *$\)\@!" contains=@hamlSassTop + +syn region  hamlJavascriptBlock start="^\z(\s*\)%script" nextgroup=@hamlComponent,hamlError end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,@htmlJavaScript keepend +syn region  hamlCssBlock        start="^\z(\s*\)%style" nextgroup=@hamlComponent,hamlError  end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,@htmlCss keepend +syn match   hamlError "\$" contained + +syn region  hamlComment     start="^\z(\s*\)-#" end="^\%(\z1 \| *$\)\@!" contains=rubyTodo +syn region  hamlHtmlComment start="^\z(\s*\)/"  end="^\%(\z1 \| *$\)\@!" contains=@hamlTop,rubyTodo +syn match   hamlIEConditional "\%(^\s*/\)\@<=\[if\>[^]]*]" contained containedin=hamlHtmlComment + +hi def link hamlSelfCloser             Special +hi def link hamlDespacer               Special +hi def link hamlClassChar              Special +hi def link hamlIdChar                 Special +hi def link hamlTag                    Special +hi def link hamlClass                  Type +hi def link hamlId                     Identifier +hi def link hamlPlainChar              Special +hi def link hamlInterpolatableChar     hamlRubyChar +hi def link hamlRubyOutputChar         hamlRubyChar +hi def link hamlRubyChar               Special +hi def link hamlInterpolationDelimiter Delimiter +hi def link hamlInterpolationEscape    Special +hi def link hamlAttributeString        String +hi def link hamlAttributeVariable      Identifier +hi def link hamlDocType                PreProc +hi def link hamlFilter                 PreProc +hi def link hamlAttributesDelimiter    Delimiter +hi def link hamlObjectDelimiter        Delimiter +hi def link hamlHelper                 Function +hi def link hamlHtmlComment            hamlComment +hi def link hamlComment                Comment +hi def link hamlIEConditional          SpecialComment +hi def link hamlError                  Error + +let b:current_syntax = "haml" + +if main_syntax == "haml" +  unlet main_syntax +endif + +" vim:set sw=2: diff --git a/syntax/haskell.vim b/syntax/haskell.vim new file mode 100644 index 00000000..7ac0fe26 --- /dev/null +++ b/syntax/haskell.vim @@ -0,0 +1,359 @@ +" Vim syntax file +" +" Modification of vims Haskell syntax file: +"   - match types using regular expression +"   - highlight toplevel functions +"   - use "syntax keyword" instead of "syntax match" where appropriate +"   - functions and types in import and module declarations are matched +"   - removed hs_highlight_more_types (just not needed anymore) +"   - enable spell checking in comments and strings only +"   - FFI highlighting +"   - QuasiQuotation +"   - top level Template Haskell slices +"   - PackageImport +" +" TODO: find out which vim versions are still supported +" +" From Original file: +" =================== +" +" Language:		    Haskell +" Maintainer:		Haskell Cafe mailinglist <haskell-cafe@haskell.org> +" Last Change:		2010 Feb 21 +" Original Author:	John Williams <jrw@pobox.com> +" +" Thanks to Ryan Crumley for suggestions and John Meacham for +" pointing out bugs. Also thanks to Ian Lynagh and Donald Bruce Stewart +" for providing the inspiration for the inclusion of the handling +" of C preprocessor directives, and for pointing out a bug in the +" end-of-line comment handling. +" +" Options-assign a value to these variables to turn the option on: +" +" hs_highlight_delimiters - Highlight delimiter characters--users +"			    with a light-colored background will +"			    probably want to turn this on. +" hs_highlight_boolean - Treat True and False as keywords. +" hs_highlight_types - Treat names of primitive types as keywords. +" hs_highlight_debug - Highlight names of debugging functions. +" hs_allow_hash_operator - Don't highlight seemingly incorrect C +"			   preprocessor directives but assume them to be +"			   operators +"  +"  + +if version < 600 +  syn clear +elseif exists("b:current_syntax") +  finish +endif + +"syntax sync fromstart "mmhhhh.... is this really ok to do so? +syntax sync linebreaks=15 minlines=50 maxlines=500 + +syn match  hsSpecialChar	contained "\\\([0-9]\+\|o[0-7]\+\|x[0-9a-fA-F]\+\|[\"\\'&\\abfnrtv]\|^[A-Z^_\[\\\]]\)" +syn match  hsSpecialChar	contained "\\\(NUL\|SOH\|STX\|ETX\|EOT\|ENQ\|ACK\|BEL\|BS\|HT\|LF\|VT\|FF\|CR\|SO\|SI\|DLE\|DC1\|DC2\|DC3\|DC4\|NAK\|SYN\|ETB\|CAN\|EM\|SUB\|ESC\|FS\|GS\|RS\|US\|SP\|DEL\)" +syn match  hsSpecialCharError	contained "\\&\|'''\+" +sy region  hsString		start=+"+  skip=+\\\\\|\\"+  end=+"+  contains=hsSpecialChar,@Spell +sy match   hsCharacter		"[^a-zA-Z0-9_']'\([^\\]\|\\[^']\+\|\\'\)'"lc=1 contains=hsSpecialChar,hsSpecialCharError +sy match   hsCharacter		"^'\([^\\]\|\\[^']\+\|\\'\)'" contains=hsSpecialChar,hsSpecialCharError + +" (Qualified) identifiers (no default highlighting) +syn match ConId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[A-Z][a-zA-Z0-9_']*\>" +syn match VarId "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=\<[a-z][a-zA-Z0-9_']*\>" + +" Infix operators--most punctuation characters and any (qualified) identifier +" enclosed in `backquotes`. An operator starting with : is a constructor, +" others are variables (e.g. functions). +syn match hsVarSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[-!#$%&\*\+/<=>\?@\\^|~.][-!#$%&\*\+/<=>\?@\\^|~:.]*" +syn match hsConSym "\(\<[A-Z][a-zA-Z0-9_']*\.\)\=:[-!#$%&\*\+./<=>\?@\\^|~:]*" +syn match hsVarSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[a-z][a-zA-Z0-9_']*`" +syn match hsConSym "`\(\<[A-Z][a-zA-Z0-9_']*\.\)\=[A-Z][a-zA-Z0-9_']*`" + +" Toplevel Template Haskell support +"sy match hsTHTopLevel "^[a-z]\(\(.\&[^=]\)\|\(\n[^a-zA-Z0-9]\)\)*" +sy match hsTHIDTopLevel "^[a-z]\S*"  +sy match hsTHTopLevel "^\$(\?" nextgroup=hsTHTopLevelName  +sy match hsTHTopLevelName "[a-z]\S*" contained + +" Reserved symbols--cannot be overloaded. +syn match hsDelimiter  "(\|)\|\[\|\]\|,\|;\|_\|{\|}" + +sy region hsInnerParen start="(" end=")" contained contains=hsInnerParen,hsConSym,hsType,hsVarSym +sy region hs_InfixOpFunctionName start="^(" end=")\s*[^:`]\(\W\&\S\&[^'\"`()[\]{}@]\)\+"re=s +    \ contained keepend contains=hsInnerParen,hs_HlInfixOp + +sy match hs_hlFunctionName "[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained  +sy match hs_FunctionName "^[a-z_]\(\S\&[^,\(\)\[\]]\)*" contained contains=hs_hlFunctionName +sy match hs_HighliteInfixFunctionName "`[a-z_][^`]*`" contained +sy match hs_InfixFunctionName "^\S[^=]*`[a-z_][^`]*`"me=e-1 contained contains=hs_HighliteInfixFunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter +sy match hs_HlInfixOp "\(\W\&\S\&[^`(){}'[\]]\)\+" contained contains=hsString +sy match hs_InfixOpFunctionName "^\(\(\w\|[[\]{}]\)\+\|\(\".*\"\)\|\('.*'\)\)\s*[^:]=*\(\W\&\S\&[^='\"`()[\]{}@]\)\+" +    \ contained contains=hs_HlInfixOp,hsCharacter + +sy match hs_OpFunctionName        "(\(\W\&[^(),\"]\)\+)" contained +"sy region hs_Function start="^["'a-z_([{]" end="=\(\s\|\n\|\w\|[([]\)" keepend extend +sy region hs_Function start="^["'a-zA-Z_([{]\(\(.\&[^=]\)\|\(\n\s\)\)*=" end="\(\s\|\n\|\w\|[([]\)"  +        \ contains=hs_OpFunctionName,hs_InfixOpFunctionName,hs_InfixFunctionName,hs_FunctionName,hsType,hsConSym,hsVarSym,hsString,hsCharacter + +sy match hs_TypeOp "::" +sy match hs_DeclareFunction "^[a-z_(]\S*\(\s\|\n\)*::" contains=hs_FunctionName,hs_OpFunctionName,hs_TypeOp + +" hi hs_TypeOp guibg=red + +" hi hs_InfixOpFunctionName guibg=yellow +" hi hs_Function guibg=green +" hi hs_InfixFunctionName guibg=red +" hi hs_DeclareFunction guibg=red + +sy keyword hsStructure data family class where instance default deriving +sy keyword hsTypedef type newtype + +sy keyword hsInfix infix infixl infixr +sy keyword hsStatement  do case of let in +sy keyword hsConditional if then else + +"if exists("hs_highlight_types") +  " Primitive types from the standard prelude and libraries. +  sy match hsType "\<[A-Z]\(\S\&[^,.]\)*\>" +  sy match hsType "()" +"endif + +" Not real keywords, but close. +if exists("hs_highlight_boolean") +  " Boolean constants from the standard prelude. +  syn keyword hsBoolean True False +endif + +syn region	hsPackageString	start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained +sy match   hsModuleName  excludenl "\([A-Z]\w*\.\?\)*" contained  + +sy match hsImport "\<import\>\s\+\(qualified\s\+\)\?\(\<\(\w\|\.\)*\>\)"  +    \ contains=hsModuleName,hsImportLabel +    \ nextgroup=hsImportParams,hsImportIllegal skipwhite +sy keyword hsImportLabel import qualified contained + +sy match hsImportIllegal "\w\+" contained + +sy keyword hsAsLabel as contained +sy keyword hsHidingLabel hiding contained + +sy match hsImportParams "as\s\+\(\w\+\)" contained +    \ contains=hsModuleName,hsAsLabel +    \ nextgroup=hsImportParams,hsImportIllegal skipwhite +sy match hsImportParams "hiding" contained +    \ contains=hsHidingLabel +    \ nextgroup=hsImportParams,hsImportIllegal skipwhite  +sy region hsImportParams start="(" end=")" contained +    \ contains=hsBlockComment,hsLineComment, hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName +    \ nextgroup=hsImportIllegal skipwhite + +" hi hsImport guibg=red +"hi hsImportParams guibg=bg +"hi hsImportIllegal guibg=bg +"hi hsModuleName guibg=bg + +"sy match hsImport		"\<import\>\(.\|[^(]\)*\((.*)\)\?"  +"         \ contains=hsPackageString,hsImportLabel,hsImportMod,hsModuleName,hsImportList +"sy keyword hsImportLabel import contained +"sy keyword hsImportMod		as qualified hiding contained +"sy region hsImportListInner start="(" end=")" contained keepend extend contains=hs_OpFunctionName +"sy region  hsImportList matchgroup=hsImportListParens start="("rs=s+1 end=")"re=e-1 +"        \ contained  +"        \ keepend extend +"        \ contains=hsType,hsLineComment,hsBlockComment,hs_hlFunctionName,hsImportListInner + + + +" new module highlighting +syn region hsDelimTypeExport start="\<[A-Z]\(\S\&[^,.]\)*\>(" end=")" contained +   \ contains=hsType + +sy keyword hsExportModuleLabel module contained +sy match hsExportModule "\<module\>\(\s\|\t\|\n\)*\([A-Z]\w*\.\?\)*" contained contains=hsExportModuleLabel,hsModuleName + +sy keyword hsModuleStartLabel module contained +sy keyword hsModuleWhereLabel where contained + +syn match hsModuleStart "^module\(\s\|\n\)*\(\<\(\w\|\.\)*\>\)\(\s\|\n\)*"  +  \ contains=hsModuleStartLabel,hsModuleName +  \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel + +syn region hsModuleCommentA start="{-" end="-}" +  \ contains=hsModuleCommentA,hsCommentTodo,@Spell contained +  \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl + +syn match hsModuleCommentA "--.*\n" +  \ contains=hsCommentTodo,@Spell contained +  \ nextgroup=hsModuleCommentA,hsModuleExports,hsModuleWhereLabel skipwhite skipnl + +syn region hsModuleExports start="(" end=")" contained +   \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl +   \ contains=hsBlockComment,hsLineComment,hsType,hsDelimTypeExport,hs_hlFunctionName,hs_OpFunctionName,hsExportModule + +syn match hsModuleCommentB "--.*\n" +  \ contains=hsCommentTodo,@Spell contained +  \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl + +syn region hsModuleCommentB start="{-" end="-}" +   \ contains=hsModuleCommentB,hsCommentTodo,@Spell contained +   \ nextgroup=hsModuleCommentB,hsModuleWhereLabel skipwhite skipnl +" end module highlighting + +" FFI support +sy keyword hsFFIForeign foreign contained +"sy keyword hsFFIImportExport import export contained +sy keyword hsFFIImportExport export contained +sy keyword hsFFICallConvention ccall stdcall contained +sy keyword hsFFISafety safe unsafe contained +sy region  hsFFIString		start=+"+  skip=+\\\\\|\\"+  end=+"+  contained contains=hsSpecialChar +sy match hsFFI excludenl "\<foreign\>\(.\&[^\"]\)*\"\(.\)*\"\(\s\|\n\)*\(.\)*::" +  \ keepend +  \ contains=hsFFIForeign,hsFFIImportExport,hsFFICallConvention,hsFFISafety,hsFFIString,hs_OpFunctionName,hs_hlFunctionName + + +sy match   hsNumber		"\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>" +sy match   hsFloat		"\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>" + +" Comments +sy keyword hsCommentTodo    TODO FIXME XXX TBD contained +sy match   hsLineComment      "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=hsCommentTodo,@Spell +sy region  hsBlockComment     start="{-"  end="-}" contains=hsBlockComment,hsCommentTodo,@Spell +sy region  hsPragma	       start="{-#" end="#-}" + +" QuasiQuotation +sy region hsQQ start="\[\$" end="|\]"me=e-2 keepend contains=hsQQVarID,hsQQContent nextgroup=hsQQEnd +sy region hsQQNew start="\[\(.\&[^|]\&\S\)*|" end="|\]"me=e-2 keepend contains=hsQQVarIDNew,hsQQContent nextgroup=hsQQEnd +sy match hsQQContent ".*" contained +sy match hsQQEnd "|\]" contained +sy match hsQQVarID "\[\$\(.\&[^|]\)*|" contained +sy match hsQQVarIDNew "\[\(.\&[^|]\)*|" contained + +if exists("hs_highlight_debug") +  " Debugging functions from the standard prelude. +  syn keyword hsDebug undefined error trace +endif + + +" C Preprocessor directives. Shamelessly ripped from c.vim and trimmed +" First, see whether to flag directive-like lines or not +if (!exists("hs_allow_hash_operator")) +    syn match	cError		display "^\s*\(%:\|#\).*$" +endif +" Accept %: for # (C99) +syn region	cPreCondit	start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=cComment,cCppString,cCommentError +syn match	cPreCondit	display "^\s*\(%:\|#\)\s*\(else\|endif\)\>" +syn region	cCppOut		start="^\s*\(%:\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=cCppOut2 +syn region	cCppOut2	contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=cCppSkip +syn region	cCppSkip	contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=cCppSkip +syn region	cIncluded	display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ +syn match	cIncluded	display contained "<[^>]*>" +syn match	cInclude	display "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=cIncluded +syn cluster	cPreProcGroup	contains=cPreCondit,cIncluded,cInclude,cDefine,cCppOut,cCppOut2,cCppSkip,cCommentStartError +syn region	cDefine		matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$" +syn region	cPreProc	matchgroup=cPreCondit start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>\|warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend + +syn region	cComment	matchgroup=cCommentStart start="/\*" end="\*/" contains=cCommentStartError,cSpaceError contained +syntax match	cCommentError	display "\*/" contained +syntax match	cCommentStartError display "/\*"me=e-1 contained +syn region	cCppString	start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=cSpecial contained + + +if version >= 508 || !exists("did_hs_syntax_inits") +  if version < 508 +    let did_hs_syntax_inits = 1 +    command -nargs=+ HiLink hi link <args> +  else +    command -nargs=+ HiLink hi def link <args> +  endif + +  HiLink hs_hlFunctionName    Function +  HiLink hs_HighliteInfixFunctionName Function +  HiLink hs_HlInfixOp       Function +  HiLink hs_OpFunctionName  Function +  HiLink hsTypedef          Typedef +  HiLink hsVarSym           hsOperator +  HiLink hsConSym           hsOperator +  if exists("hs_highlight_delimiters") +    " Some people find this highlighting distracting. +	HiLink hsDelimiter        Delimiter +  endif + +  HiLink hsModuleStartLabel Structure +  HiLink hsExportModuleLabel Keyword +  HiLink hsModuleWhereLabel Structure +  HiLink hsModuleName       Normal +   +  HiLink hsImportIllegal    Error +  HiLink hsAsLabel          hsImportLabel +  HiLink hsHidingLabel      hsImportLabel +  HiLink hsImportLabel      Include +  HiLink hsImportMod        Include +  HiLink hsPackageString    hsString + +  HiLink hsOperator         Operator + +  HiLink hsInfix            Keyword +  HiLink hsStructure        Structure +  HiLink hsStatement        Statement +  HiLink hsConditional      Conditional + +  HiLink hsSpecialCharError Error +  HiLink hsSpecialChar      SpecialChar +  HiLink hsString           String +  HiLink hsFFIString        String +  HiLink hsCharacter        Character +  HiLink hsNumber           Number +  HiLink hsFloat            Float + +  HiLink hsLiterateComment		  hsComment +  HiLink hsBlockComment     hsComment +  HiLink hsLineComment      hsComment +  HiLink hsModuleCommentA   hsComment +  HiLink hsModuleCommentB   hsComment +  HiLink hsComment          Comment +  HiLink hsCommentTodo      Todo +  HiLink hsPragma           SpecialComment +  HiLink hsBoolean			  Boolean + +  if exists("hs_highlight_types") +      HiLink hsDelimTypeExport  hsType +      HiLink hsType             Type +  endif + +  HiLink hsDebug            Debug + +  HiLink hs_TypeOp          hsOperator + +  HiLink cCppString         hsString +  HiLink cCommentStart      hsComment +  HiLink cCommentError      hsError +  HiLink cCommentStartError hsError +  HiLink cInclude           Include +  HiLink cPreProc           PreProc +  HiLink cDefine            Macro +  HiLink cIncluded          hsString +  HiLink cError             Error +  HiLink cPreCondit         PreCondit +  HiLink cComment           Comment +  HiLink cCppSkip           cCppOut +  HiLink cCppOut2           cCppOut +  HiLink cCppOut            Comment + +  HiLink hsFFIForeign       Keyword +  HiLink hsFFIImportExport  Structure +  HiLink hsFFICallConvention Keyword +  HiLink hsFFISafety         Keyword + +  HiLink hsTHIDTopLevel   Macro +  HiLink hsTHTopLevelName Macro + +  HiLink hsQQVarID Keyword +  HiLink hsQQVarIDNew Keyword +  HiLink hsQQEnd   Keyword +  HiLink hsQQContent String + +  delcommand HiLink +endif + +let b:current_syntax = "haskell" diff --git a/syntax/javascript.vim b/syntax/javascript.vim new file mode 100644 index 00000000..e72c63a4 --- /dev/null +++ b/syntax/javascript.vim @@ -0,0 +1,312 @@ +" Vim syntax file +" Language:     JavaScript +" Maintainer:   vim-javascript community +" URL:          https://github.com/pangloss/vim-javascript + +if !exists("main_syntax") +  if version < 600 +    syntax clear +  elseif exists("b:current_syntax") +    finish +  endif +  let main_syntax = 'javascript' +endif + +if !exists('g:javascript_conceal') +  let g:javascript_conceal = 0 +endif + +"" Drop fold if it is set but VIM doesn't support it. +let b:javascript_fold='true' +if version < 600    " Don't support the old version +  unlet! b:javascript_fold +endif + +"" dollar sign is permittd anywhere in an identifier +setlocal iskeyword+=$ + +syntax sync fromstart + +syntax match   jsNoise           /\%(:\|,\|\;\|\.\)/ + +"" Program Keywords +syntax keyword jsStorageClass   const var let +syntax keyword jsOperator       delete instanceof typeof void new in +syntax match   jsOperator       /\(!\||\|&\|+\|-\|<\|>\|=\|%\|\/\|*\|\~\|\^\)/ +syntax keyword jsBooleanTrue    true +syntax keyword jsBooleanFalse   false + +"" JavaScript comments +syntax keyword jsCommentTodo    TODO FIXME XXX TBD contained +syntax region  jsLineComment    start=+\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell +syntax region  jsEnvComment     start="\%^#!" end="$" display +syntax region  jsLineComment    start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend contains=jsCommentTodo,@Spell fold +syntax region  jsCvsTag         start="\$\cid:" end="\$" oneline contained +syntax region  jsComment        start="/\*"  end="\*/" contains=jsCommentTodo,jsCvsTag,@Spell fold + +"" JSDoc / JSDoc Toolkit +if !exists("javascript_ignore_javaScriptdoc") +  syntax case ignore + +  "" syntax coloring for javadoc comments (HTML) +  "syntax include @javaHtml <sfile>:p:h/html.vim +  "unlet b:current_syntax + +  syntax region jsDocComment      matchgroup=jsComment start="/\*\*\s*"  end="\*/" contains=jsDocTags,jsCommentTodo,jsCvsTag,@jsHtml,@Spell fold + +  " tags containing a param +  syntax match  jsDocTags         contained "@\(alias\|augments\|borrows\|class\|constructs\|default\|defaultvalue\|emits\|exception\|exports\|extends\|file\|fires\|kind\|listens\|member\|memberOf\|mixes\|module\|name\|namespace\|requires\|throws\|var\|variation\|version\)\>" nextgroup=jsDocParam skipwhite +  " tags containing type and param +  syntax match  jsDocTags         contained "@\(arg\|argument\|param\|property\)\>" nextgroup=jsDocType skipwhite +  " tags containing type but no param +  syntax match  jsDocTags         contained "@\(callback\|enum\|external\|this\|type\|typedef\|return\|returns\)\>" nextgroup=jsDocTypeNoParam skipwhite +  " tags containing references +  syntax match  jsDocTags         contained "@\(lends\|see\)\>" nextgroup=jsDocSeeTag skipwhite +  " other tags (no extra syntax) +  syntax match  jsDocTags         contained "@\(abstract\|access\|author\|classdesc\|constant\|const\|constructor\|copyright\|deprecated\|desc\|description\|event\|example\|fileOverview\|function\|global\|ignore\|inner\|instance\|license\|method\|mixin\|overview\|private\|protected\|public\|readonly\|since\|static\|todo\|summary\|undocumented\|virtual\)\>" + +  syntax region jsDocType         start="{" end="}" oneline contained nextgroup=jsDocParam skipwhite +  syntax match  jsDocType         contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" nextgroup=jsDocParam skipwhite +  syntax region jsDocTypeNoParam  start="{" end="}" oneline contained +  syntax match  jsDocTypeNoParam  contained "\%(#\|\"\|\w\|\.\|:\|\/\)\+" +  syntax match  jsDocParam        contained "\%(#\|\"\|{\|}\|\w\|\.\|:\|\/\)\+" +  syntax region jsDocSeeTag       contained matchgroup=jsDocSeeTag start="{" end="}" contains=jsDocTags + +  syntax case match +endif   "" JSDoc end + +syntax case match + +"" Syntax in the JavaScript code +syntax match   jsFuncCall        /\k\+\%(\s*(\)\@=/ +syntax match   jsSpecial         "\v\\%(0|\\x\x\{2\}\|\\u\x\{4\}\|\c[A-Z]|.)" +syntax region  jsStringD         start=+"+  skip=+\\\\\|\\$"+  end=+"+  contains=jsSpecial,@htmlPreproc +syntax region  jsStringS         start=+'+  skip=+\\\\\|\\$'+  end=+'+  contains=jsSpecial,@htmlPreproc +syntax region  jsRegexpCharClass start=+\[+ end=+\]+ contained +syntax match   jsRegexpBoundary   "\v%(\<@![\^$]|\\[bB])" contained +syntax match   jsRegexpBackRef   "\v\\[1-9][0-9]*" contained +syntax match   jsRegexpQuantifier "\v\\@<!%([?*+]|\{\d+%(,|,\d+)?})\??" contained +syntax match   jsRegexpOr        "\v\<@!\|" contained +syntax match   jsRegexpMod       "\v\(@<=\?[:=!>]" contained +syntax cluster jsRegexpSpecial   contains=jsRegexpBoundary,jsRegexpBackRef,jsRegexpQuantifier,jsRegexpOr,jsRegexpMod +syntax region  jsRegexpGroup     start="\\\@<!(" end="\\\@<!)" contained contains=jsRegexpCharClass,@jsRegexpSpecial keepend +syntax region  jsRegexpString    start=+\(\(\(return\|case\)\s\+\)\@<=\|\(\([)\]"']\|\d\|\w\)\s*\)\@<!\)/\(\*\|/\)\@!+ skip=+\\\\\|\\/+ end=+/[gimy]\{,4}+ contains=jsSpecial,jsRegexpCharClass,jsRegexpGroup,@jsRegexpSpecial,@htmlPreproc oneline keepend +syntax match   jsNumber          /\<-\=\d\+L\=\>\|\<0[xX]\x\+\>/ +syntax keyword jsNumber          Infinity +syntax match   jsFloat           /\<-\=\%(\d\+\.\d\+\|\d\+\.\|\.\d\+\)\%([eE][+-]\=\d\+\)\=\>/ +syntax match   jsObjectKey       /\<[a-zA-Z_$][0-9a-zA-Z_$]*\(\s*:\)\@=/ contains=jsFunctionKey +syntax match   jsFunctionKey     /\<[a-zA-Z_$][0-9a-zA-Z_$]*\(\s*:\s*function\s*\)\@=/ contained + +"" JavaScript Prototype +syntax keyword jsPrototype      prototype + +if g:javascript_conceal == 1 +  syntax keyword jsNull           null conceal cchar=ø +  syntax keyword jsThis           this conceal cchar=@ +  syntax keyword jsReturn         return conceal cchar=⇚ +  syntax keyword jsUndefined      undefined conceal cchar=¿ +  syntax keyword jsNan            NaN conceal cchar=ℕ +else +  syntax keyword jsNull           null +  syntax keyword jsThis           this +  syntax keyword jsReturn         return +  syntax keyword jsUndefined      undefined +  syntax keyword jsNan            NaN +endif + +"" Statement Keywords +syntax keyword jsStatement      break continue with +syntax keyword jsConditional    if else switch +syntax keyword jsRepeat         do while for +syntax keyword jsLabel          case default +syntax keyword jsKeyword        yield +syntax keyword jsException      try catch throw finally + +syntax keyword jsGlobalObjects   Array Boolean Date Function Iterator Number Object RegExp String Proxy ParallelArray ArrayBuffer DataView Float32Array Float64Array Int16Array Int32Array Int8Array Uint16Array Uint32Array Uint8Array Uint8ClampedArray Intl JSON Math console document window +syntax match   jsGlobalObjects  /\%(Intl\.\)\@<=\(Collator\|DateTimeFormat\|NumberFormat\)/ + +syntax keyword jsExceptions     Error EvalError InternalError RangeError ReferenceError StopIteration SyntaxError TypeError URIError + +syntax keyword jsBuiltins       decodeURI decodeURIComponent encodeURI encodeURIComponent eval isFinite isNaN parseFloat parseInt uneval + +syntax keyword jsFutureKeys     abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws goto private transient debugger implements protected volatile double import public + +"" DOM/HTML/CSS specified things + +  " DOM2 Objects +  syntax keyword jsGlobalObjects  DOMImplementation DocumentFragment Document Node NodeList NamedNodeMap CharacterData Attr Element Text Comment CDATASection DocumentType Notation Entity EntityReference ProcessingInstruction +  syntax keyword jsExceptions     DOMException + +  " DOM2 CONSTANT +  syntax keyword jsDomErrNo       INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR INVALID_STATE_ERR SYNTAX_ERR INVALID_MODIFICATION_ERR NAMESPACE_ERR INVALID_ACCESS_ERR +  syntax keyword jsDomNodeConsts  ELEMENT_NODE ATTRIBUTE_NODE TEXT_NODE CDATA_SECTION_NODE ENTITY_REFERENCE_NODE ENTITY_NODE PROCESSING_INSTRUCTION_NODE COMMENT_NODE DOCUMENT_NODE DOCUMENT_TYPE_NODE DOCUMENT_FRAGMENT_NODE NOTATION_NODE + +  " HTML events and internal variables +  syntax case ignore +  syntax keyword jsHtmlEvents     onblur onclick oncontextmenu ondblclick onfocus onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup onresize +  syntax case match + +" Follow stuff should be highligh within a special context +" While it can't be handled with context depended with Regex based highlight +" So, turn it off by default +if exists("javascript_enable_domhtmlcss") + +    " DOM2 things +    syntax match jsDomElemAttrs     contained /\%(nodeName\|nodeValue\|nodeType\|parentNode\|childNodes\|firstChild\|lastChild\|previousSibling\|nextSibling\|attributes\|ownerDocument\|namespaceURI\|prefix\|localName\|tagName\)\>/ +    syntax match jsDomElemFuncs     contained /\%(insertBefore\|replaceChild\|removeChild\|appendChild\|hasChildNodes\|cloneNode\|normalize\|isSupported\|hasAttributes\|getAttribute\|setAttribute\|removeAttribute\|getAttributeNode\|setAttributeNode\|removeAttributeNode\|getElementsByTagName\|getAttributeNS\|setAttributeNS\|removeAttributeNS\|getAttributeNodeNS\|setAttributeNodeNS\|getElementsByTagNameNS\|hasAttribute\|hasAttributeNS\)\>/ nextgroup=jsParen skipwhite +    " HTML things +    syntax match jsHtmlElemAttrs    contained /\%(className\|clientHeight\|clientLeft\|clientTop\|clientWidth\|dir\|id\|innerHTML\|lang\|length\|offsetHeight\|offsetLeft\|offsetParent\|offsetTop\|offsetWidth\|scrollHeight\|scrollLeft\|scrollTop\|scrollWidth\|style\|tabIndex\|title\)\>/ +    syntax match jsHtmlElemFuncs    contained /\%(blur\|click\|focus\|scrollIntoView\|addEventListener\|dispatchEvent\|removeEventListener\|item\)\>/ nextgroup=jsParen skipwhite + +    " CSS Styles in JavaScript +    syntax keyword jsCssStyles      contained color font fontFamily fontSize fontSizeAdjust fontStretch fontStyle fontVariant fontWeight letterSpacing lineBreak lineHeight quotes rubyAlign rubyOverhang rubyPosition +    syntax keyword jsCssStyles      contained textAlign textAlignLast textAutospace textDecoration textIndent textJustify textJustifyTrim textKashidaSpace textOverflowW6 textShadow textTransform textUnderlinePosition +    syntax keyword jsCssStyles      contained unicodeBidi whiteSpace wordBreak wordSpacing wordWrap writingMode +    syntax keyword jsCssStyles      contained bottom height left position right top width zIndex +    syntax keyword jsCssStyles      contained border borderBottom borderLeft borderRight borderTop borderBottomColor borderLeftColor borderTopColor borderBottomStyle borderLeftStyle borderRightStyle borderTopStyle borderBottomWidth borderLeftWidth borderRightWidth borderTopWidth borderColor borderStyle borderWidth borderCollapse borderSpacing captionSide emptyCells tableLayout +    syntax keyword jsCssStyles      contained margin marginBottom marginLeft marginRight marginTop outline outlineColor outlineStyle outlineWidth padding paddingBottom paddingLeft paddingRight paddingTop +    syntax keyword jsCssStyles      contained listStyle listStyleImage listStylePosition listStyleType +    syntax keyword jsCssStyles      contained background backgroundAttachment backgroundColor backgroundImage gackgroundPosition backgroundPositionX backgroundPositionY backgroundRepeat +    syntax keyword jsCssStyles      contained clear clip clipBottom clipLeft clipRight clipTop content counterIncrement counterReset cssFloat cursor direction display filter layoutGrid layoutGridChar layoutGridLine layoutGridMode layoutGridType +    syntax keyword jsCssStyles      contained marks maxHeight maxWidth minHeight minWidth opacity MozOpacity overflow overflowX overflowY verticalAlign visibility zoom cssText +    syntax keyword jsCssStyles      contained scrollbar3dLightColor scrollbarArrowColor scrollbarBaseColor scrollbarDarkShadowColor scrollbarFaceColor scrollbarHighlightColor scrollbarShadowColor scrollbarTrackColor + +    " Highlight ways +    syntax match jsDotNotation      "\." nextgroup=jsPrototype,jsDomElemAttrs,jsDomElemFuncs,jsHtmlElemAttrs,jsHtmlElemFuncs +    syntax match jsDotNotation      "\.style\." nextgroup=jsCssStyles + +endif "DOM/HTML/CSS + +"" end DOM/HTML/CSS specified things + + +"" Code blocks +syntax cluster jsExpression contains=jsComment,jsLineComment,jsDocComment,jsStringD,jsStringS,jsRegexpString,jsNumber,jsFloat,jsThis,jsOperator,jsBooleanTrue,jsBooleanFalse,jsNull,jsFunction,jsGlobalObjects,jsExceptions,jsFutureKeys,jsDomErrNo,jsDomNodeConsts,jsHtmlEvents,jsDotNotation,jsBracket,jsParen,jsBlock,jsFuncCall,jsUndefined,jsNan,jsKeyword,jsStorageClass,jsPrototype,jsBuiltins,jsNoise +syntax cluster jsAll        contains=@jsExpression,jsLabel,jsConditional,jsRepeat,jsReturn,jsStatement,jsTernaryIf,jsException +syntax region  jsBracket    matchgroup=jsBrackets     start="\[" end="\]" contains=@jsAll,jsParensErrB,jsParensErrC,jsBracket,jsParen,jsBlock,@htmlPreproc fold +syntax region  jsParen      matchgroup=jsParens       start="("  end=")"  contains=@jsAll,jsParensErrA,jsParensErrC,jsParen,jsBracket,jsBlock,@htmlPreproc fold +syntax region  jsBlock      matchgroup=jsBraces       start="{"  end="}"  contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,jsObjectKey,@htmlPreproc fold +syntax region  jsFuncBlock  matchgroup=jsFuncBraces   start="{"  end="}"  contains=@jsAll,jsParensErrA,jsParensErrB,jsParen,jsBracket,jsBlock,@htmlPreproc contained fold +syntax region  jsTernaryIf  matchgroup=jsTernaryIfOperator start=+?+  end=+:+  contains=@jsExpression,jsTernaryIf + +"" catch errors caused by wrong parenthesis +syntax match   jsParensError    ")\|}\|\]" +syntax match   jsParensErrA     contained "\]" +syntax match   jsParensErrB     contained ")" +syntax match   jsParensErrC     contained "}" + +if main_syntax == "javascript" +  syntax sync clear +  syntax sync ccomment jsComment minlines=200 +  syntax sync match jsHighlight grouphere jsBlock /{/ +endif + +if g:javascript_conceal == 1 +  syntax match   jsFunction       /\<function\>/ nextgroup=jsFuncName,jsFuncArgs skipwhite conceal cchar=ƒ +else +  syntax match   jsFunction       /\<function\>/ nextgroup=jsFuncName,jsFuncArgs skipwhite +endif + +syntax match   jsFuncName       contained /\<[a-zA-Z_$][0-9a-zA-Z_$]*/ nextgroup=jsFuncArgs skipwhite +syntax region  jsFuncArgs       contained matchgroup=jsFuncParens start='(' end=')' contains=jsFuncArgCommas nextgroup=jsFuncBlock keepend skipwhite skipempty +syntax match   jsFuncArgCommas  contained ',' +syntax keyword jsArgsObj        arguments contained containedin=jsFuncBlock + +" 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_javascript_syn_inits") +  if version < 508 +    let did_javascript_syn_inits = 1 +    command -nargs=+ HiLink hi link <args> +  else +    command -nargs=+ HiLink hi def link <args> +  endif +  HiLink jsComment              Comment +  HiLink jsLineComment          Comment +  HiLink jsEnvComment           PreProc +  HiLink jsDocComment           Comment +  HiLink jsCommentTodo          Todo +  HiLink jsCvsTag               Function +  HiLink jsDocTags              Special +  HiLink jsDocSeeTag            Function +  HiLink jsDocType              Type +  HiLink jsDocTypeNoParam       Type +  HiLink jsDocParam             Label +  HiLink jsStringS              String +  HiLink jsStringD              String +  HiLink jsTernaryIfOperator    Conditional +  HiLink jsRegexpString         String +  HiLink jsRegexpBoundary       SpecialChar +  HiLink jsRegexpQuantifier     SpecialChar +  HiLink jsRegexpOr             Conditional +  HiLink jsRegexpMod            SpecialChar +  HiLink jsRegexpBackRef        SpecialChar +  HiLink jsRegexpGroup          jsRegexpString +  HiLink jsRegexpCharClass      Character +  HiLink jsCharacter            Character +  HiLink jsPrototype            Special +  HiLink jsConditional          Conditional +  HiLink jsBranch               Conditional +  HiLink jsLabel                Label +  HiLink jsReturn               Statement +  HiLink jsRepeat               Repeat +  HiLink jsStatement            Statement +  HiLink jsException            Exception +  HiLink jsKeyword              Keyword +  HiLink jsFunction             Type +  HiLink jsFuncName             Function +  HiLink jsArgsObj              Special +  HiLink jsError                Error +  HiLink jsParensError          Error +  HiLink jsParensErrA           Error +  HiLink jsParensErrB           Error +  HiLink jsParensErrC           Error +  HiLink jsOperator             Operator +  HiLink jsStorageClass         StorageClass +  HiLink jsThis                 Special +  HiLink jsNan                  Number +  HiLink jsNull                 Type +  HiLink jsUndefined            Type +  HiLink jsNumber               Number +  HiLink jsFloat                Float +  HiLink jsBooleanTrue          Boolean +  HiLink jsBooleanFalse         Boolean +  HiLink jsNoise                Noise +  HiLink jsBrackets             Noise +  HiLink jsParens               Noise +  HiLink jsBraces               Noise +  HiLink jsFuncBraces           Noise +  HiLink jsFuncParens           Noise +  HiLink jsSpecial              Special +  HiLink jsGlobalObjects        Special +  HiLink jsExceptions           Special +  HiLink jsFutureKeys           Special +  HiLink jsBuiltins             Special + +  HiLink jsDomErrNo             Constant +  HiLink jsDomNodeConsts        Constant +  HiLink jsDomElemAttrs         Label +  HiLink jsDomElemFuncs         PreProc + +  HiLink jsHtmlEvents           Special +  HiLink jsHtmlElemAttrs        Label +  HiLink jsHtmlElemFuncs        PreProc + +  HiLink jsCssStyles            Label + +  delcommand HiLink +endif + +" Define the htmlJavaScript for HTML syntax html.vim +"syntax clear htmlJavaScript +"syntax clear jsExpression +syntax cluster  htmlJavaScript       contains=@jsAll,jsBracket,jsParen,jsBlock +syntax cluster  javaScriptExpression contains=@jsAll,jsBracket,jsParen,jsBlock,@htmlPreproc +" Vim's default html.vim highlights all javascript as 'Special' +hi! def link javaScript              NONE + +let b:current_syntax = "javascript" +if main_syntax == 'javascript' +  unlet main_syntax +endif diff --git a/syntax/json.vim b/syntax/json.vim new file mode 100644 index 00000000..f3e27ba2 --- /dev/null +++ b/syntax/json.vim @@ -0,0 +1,77 @@ +" Vim syntax file +" Language:	JSON +" Maintainer:	Jeroen Ruigrok van der Werven <asmodai@in-nomine.org> +" Last Change:	2009-06-16 +" Version:      0.4 +" {{{1 + +" Syntax setup {{{2 +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded + +if !exists("main_syntax") +  if version < 600 +    syntax clear +  elseif exists("b:current_syntax") +    finish +  endif +  let main_syntax = 'json' +endif + +" Syntax: Strings {{{2 +syn region  jsonString    start=+"+  skip=+\\\\\|\\"+  end=+"+  contains=jsonEscape +" Syntax: JSON does not allow strings with single quotes, unlike JavaScript. +syn region  jsonStringSQ  start=+'+  skip=+\\\\\|\\"+  end=+'+ + +" Syntax: Escape sequences {{{3 +syn match   jsonEscape    "\\["\\/bfnrt]" contained +syn match   jsonEscape    "\\u\x\{4}" contained + +" Syntax: Strings should always be enclosed with quotes. +syn match   jsonNoQuotes  "\<\a\+\>" + +" Syntax: Numbers {{{2 +syn match   jsonNumber    "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>" + +" Syntax: An integer part of 0 followed by other digits is not allowed. +syn match   jsonNumError  "-\=\<0\d\.\d*\>" + +" Syntax: Boolean {{{2 +syn keyword jsonBoolean   true false + +" Syntax: Null {{{2 +syn keyword jsonNull      null + +" Syntax: Braces {{{2 +syn match   jsonBraces	   "[{}\[\]]" + +" Define the default highlighting. {{{1 +" 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_json_syn_inits") +  if version < 508 +    let did_json_syn_inits = 1 +    command -nargs=+ HiLink hi link <args> +  else +    command -nargs=+ HiLink hi def link <args> +  endif +  HiLink jsonString             String +  HiLink jsonEscape             Special +  HiLink jsonNumber		Number +  HiLink jsonBraces		Operator +  HiLink jsonNull		Function +  HiLink jsonBoolean		Boolean + +  HiLink jsonNumError           Error +  HiLink jsonStringSQ           Error +  HiLink jsonNoQuotes           Error +  delcommand HiLink +endif + +let b:current_syntax = "json" +if main_syntax == 'json' +  unlet main_syntax +endif + +" Vim settings {{{2 +" vim: ts=8 fdm=marker diff --git a/syntax/less.vim b/syntax/less.vim new file mode 100644 index 00000000..fa5a247e --- /dev/null +++ b/syntax/less.vim @@ -0,0 +1,64 @@ +if exists("b:current_syntax") +  finish +endif + +runtime! syntax/css.vim +runtime! after/syntax/css.vim +" load files from vim-css3-syntax plugin (https://github.com/hail2u/vim-css3-syntax) +runtime! after/syntax/css/*.vim + +syn case ignore + +syn region lessDefinition transparent matchgroup=cssBraces start='{' end='}' contains=css.*Attr,css.*Prop,cssComment,cssValue.*,cssColor,cssTagName,cssPseudoClass,cssUrl,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,lessDefinition,lessComment,lessClassChar,lessVariable,lessMixinChar,lessAmpersandChar,lessFunction,lessNestedSelector,@cssColors fold + +syn match lessVariable "@[[:alnum:]_-]\+" contained +syn match lessVariable "@[[:alnum:]_-]\+" nextgroup=lessVariableAssignment skipwhite +syn match lessVariableAssignment ":" contained nextgroup=lessVariableValue skipwhite +syn match lessVariableValue ".*;"me=e-1 contained contains=lessVariable,lessOperator,lessDefault,cssValue.*,@cssColors "me=e-1 means that the last char of the pattern is not highlighted + +syn match lessOperator "+" contained +syn match lessOperator "-" contained +syn match lessOperator "/" contained +syn match lessOperator "*" contained + +syn match lessNestedSelector "[^/]* {"me=e-1 contained contains=cssTagName,cssAttributeSelector,lessAmpersandChar,lessVariable,lessMixinChar,lessFunction,lessNestedProperty +syn match lessNestedProperty "[[:alnum:]]\+:"me=e-1 contained + +syn match lessDefault "!default" contained + +syn match lessMixinChar "\.[[:alnum:]_-]\@=" contained nextgroup=lessClass +syn match lessAmpersandChar "&" contained nextgroup=lessClass,cssPseudoClass +syn match lessClass "[[:alnum:]_-]\+" contained + +" functions {{{ + +" string functions +syn keyword lessFunction escape e % containedin=cssDefinition contained +" misc functions +syn keyword lessFunction color unit containedin=cssDefinition contained +" math functions +syn keyword lessFunction ceil floor percentage round containedin=cssDefinition contained +" color definition +syn keyword lessFunction rgb rgba argb hsl hsla hsv hsva containedin=cssDefinition contained +" color channel information +syn keyword lessFunction hue saturation lightness red green blue alpha luma containedin=cssDefinition contained +" color operations +syn keyword lessFunction saturate desaturate lighten darken fadein fadeout fade spin mix greyscale contrast containedin=cssDefinition contained +" color blending +syn keyword lessFunction multiply screen overlay softlight hardlight difference exclusion average negation containedin=cssDefinition contained + +" }}} + +syn match lessComment "//.*$" contains=@Spell + +hi def link lessVariable Special +hi def link lessVariableValue Constant +hi def link lessDefault Special +hi def link lessComment Comment +hi def link lessFunction Function +hi def link lessMixinChar Special +hi def link lessAmpersandChar Special +hi def link lessNestedProperty Type +hi def link lessClass PreProc + +let b:current_syntax = "less" diff --git a/syntax/nginx.vim b/syntax/nginx.vim new file mode 100644 index 00000000..ccd47680 --- /dev/null +++ b/syntax/nginx.vim @@ -0,0 +1,664 @@ +" Vim syntax file +" Language: nginx.conf + +if exists("b:current_syntax") +  finish +end + +setlocal iskeyword+=. +setlocal iskeyword+=/ +setlocal iskeyword+=: + +syn match ngxVariable '\$\w\w*' +syn match ngxVariableBlock '\$\w\w*' contained +syn match ngxVariableString '\$\w\w*' contained +syn region ngxBlock start=+^+ end=+{+ contains=ngxComment,ngxDirectiveBlock,ngxVariableBlock,ngxString oneline +syn region ngxString start=+"+ end=+"+ skip=+\\\\\|\\"+ contains=ngxVariableString oneline +syn region ngxString start=+'+ end=+'+ skip=+\\\\\|\\'+ contains=ngxVariableString oneline +syn match ngxComment ' *#.*$' + +syn keyword ngxBoolean on +syn keyword ngxBoolean off + +syn keyword ngxDirectiveBlock http         contained +syn keyword ngxDirectiveBlock mail         contained +syn keyword ngxDirectiveBlock events       contained +syn keyword ngxDirectiveBlock server       contained +syn keyword ngxDirectiveBlock types        contained +syn keyword ngxDirectiveBlock location     contained +syn keyword ngxDirectiveBlock upstream     contained +syn keyword ngxDirectiveBlock charset_map  contained +syn keyword ngxDirectiveBlock limit_except contained +syn keyword ngxDirectiveBlock if           contained +syn keyword ngxDirectiveBlock geo          contained +syn keyword ngxDirectiveBlock map          contained + +syn keyword ngxDirectiveImportant include +syn keyword ngxDirectiveImportant root +syn keyword ngxDirectiveImportant server +syn keyword ngxDirectiveImportant server_name +syn keyword ngxDirectiveImportant listen +syn keyword ngxDirectiveImportant internal +syn keyword ngxDirectiveImportant proxy_pass +syn keyword ngxDirectiveImportant memcached_pass +syn keyword ngxDirectiveImportant fastcgi_pass +syn keyword ngxDirectiveImportant try_files + +syn keyword ngxDirectiveControl break +syn keyword ngxDirectiveControl return +syn keyword ngxDirectiveControl rewrite +syn keyword ngxDirectiveControl set + +syn keyword ngxDirectiveError error_page +syn keyword ngxDirectiveError post_action + +syn keyword ngxDirectiveDeprecated connections +syn keyword ngxDirectiveDeprecated imap +syn keyword ngxDirectiveDeprecated open_file_cache_retest +syn keyword ngxDirectiveDeprecated optimize_server_names +syn keyword ngxDirectiveDeprecated satisfy_any + +syn keyword ngxDirective accept_mutex +syn keyword ngxDirective accept_mutex_delay +syn keyword ngxDirective access_log +syn keyword ngxDirective add_after_body +syn keyword ngxDirective add_before_body +syn keyword ngxDirective add_header +syn keyword ngxDirective addition_types +syn keyword ngxDirective aio +syn keyword ngxDirective alias +syn keyword ngxDirective allow +syn keyword ngxDirective ancient_browser +syn keyword ngxDirective ancient_browser_value +syn keyword ngxDirective auth_basic +syn keyword ngxDirective auth_basic_user_file +syn keyword ngxDirective auth_http +syn keyword ngxDirective auth_http_header +syn keyword ngxDirective auth_http_timeout +syn keyword ngxDirective autoindex +syn keyword ngxDirective autoindex_exact_size +syn keyword ngxDirective autoindex_localtime +syn keyword ngxDirective charset +syn keyword ngxDirective charset_types +syn keyword ngxDirective client_body_buffer_size +syn keyword ngxDirective client_body_in_file_only +syn keyword ngxDirective client_body_in_single_buffer +syn keyword ngxDirective client_body_temp_path +syn keyword ngxDirective client_body_timeout +syn keyword ngxDirective client_header_buffer_size +syn keyword ngxDirective client_header_timeout +syn keyword ngxDirective client_max_body_size +syn keyword ngxDirective connection_pool_size +syn keyword ngxDirective create_full_put_path +syn keyword ngxDirective daemon +syn keyword ngxDirective dav_access +syn keyword ngxDirective dav_methods +syn keyword ngxDirective debug_connection +syn keyword ngxDirective debug_points +syn keyword ngxDirective default_type +syn keyword ngxDirective degradation +syn keyword ngxDirective degrade +syn keyword ngxDirective deny +syn keyword ngxDirective devpoll_changes +syn keyword ngxDirective devpoll_events +syn keyword ngxDirective directio +syn keyword ngxDirective directio_alignment +syn keyword ngxDirective empty_gif +syn keyword ngxDirective env +syn keyword ngxDirective epoll_events +syn keyword ngxDirective error_log +syn keyword ngxDirective eventport_events +syn keyword ngxDirective expires +syn keyword ngxDirective fastcgi_bind +syn keyword ngxDirective fastcgi_buffer_size +syn keyword ngxDirective fastcgi_buffers +syn keyword ngxDirective fastcgi_busy_buffers_size +syn keyword ngxDirective fastcgi_cache +syn keyword ngxDirective fastcgi_cache_key +syn keyword ngxDirective fastcgi_cache_methods +syn keyword ngxDirective fastcgi_cache_min_uses +syn keyword ngxDirective fastcgi_cache_path +syn keyword ngxDirective fastcgi_cache_use_stale +syn keyword ngxDirective fastcgi_cache_valid +syn keyword ngxDirective fastcgi_catch_stderr +syn keyword ngxDirective fastcgi_connect_timeout +syn keyword ngxDirective fastcgi_hide_header +syn keyword ngxDirective fastcgi_ignore_client_abort +syn keyword ngxDirective fastcgi_ignore_headers +syn keyword ngxDirective fastcgi_index +syn keyword ngxDirective fastcgi_intercept_errors +syn keyword ngxDirective fastcgi_max_temp_file_size +syn keyword ngxDirective fastcgi_next_upstream +syn keyword ngxDirective fastcgi_param +syn keyword ngxDirective fastcgi_pass_header +syn keyword ngxDirective fastcgi_pass_request_body +syn keyword ngxDirective fastcgi_pass_request_headers +syn keyword ngxDirective fastcgi_read_timeout +syn keyword ngxDirective fastcgi_send_lowat +syn keyword ngxDirective fastcgi_send_timeout +syn keyword ngxDirective fastcgi_split_path_info +syn keyword ngxDirective fastcgi_store +syn keyword ngxDirective fastcgi_store_access +syn keyword ngxDirective fastcgi_temp_file_write_size +syn keyword ngxDirective fastcgi_temp_path +syn keyword ngxDirective fastcgi_upstream_fail_timeout +syn keyword ngxDirective fastcgi_upstream_max_fails +syn keyword ngxDirective flv +syn keyword ngxDirective geoip_city +syn keyword ngxDirective geoip_country +syn keyword ngxDirective google_perftools_profiles +syn keyword ngxDirective gzip +syn keyword ngxDirective gzip_buffers +syn keyword ngxDirective gzip_comp_level +syn keyword ngxDirective gzip_disable +syn keyword ngxDirective gzip_hash +syn keyword ngxDirective gzip_http_version +syn keyword ngxDirective gzip_min_length +syn keyword ngxDirective gzip_no_buffer +syn keyword ngxDirective gzip_proxied +syn keyword ngxDirective gzip_static +syn keyword ngxDirective gzip_types +syn keyword ngxDirective gzip_vary +syn keyword ngxDirective gzip_window +syn keyword ngxDirective if_modified_since +syn keyword ngxDirective ignore_invalid_headers +syn keyword ngxDirective image_filter +syn keyword ngxDirective image_filter_buffer +syn keyword ngxDirective image_filter_jpeg_quality +syn keyword ngxDirective image_filter_transparency +syn keyword ngxDirective imap_auth +syn keyword ngxDirective imap_capabilities +syn keyword ngxDirective imap_client_buffer +syn keyword ngxDirective index +syn keyword ngxDirective ip_hash +syn keyword ngxDirective keepalive_requests +syn keyword ngxDirective keepalive_timeout +syn keyword ngxDirective kqueue_changes +syn keyword ngxDirective kqueue_events +syn keyword ngxDirective large_client_header_buffers +syn keyword ngxDirective limit_conn +syn keyword ngxDirective limit_conn_log_level +syn keyword ngxDirective limit_rate +syn keyword ngxDirective limit_rate_after +syn keyword ngxDirective limit_req +syn keyword ngxDirective limit_req_log_level +syn keyword ngxDirective limit_req_zone +syn keyword ngxDirective limit_zone +syn keyword ngxDirective lingering_time +syn keyword ngxDirective lingering_timeout +syn keyword ngxDirective lock_file +syn keyword ngxDirective log_format +syn keyword ngxDirective log_not_found +syn keyword ngxDirective log_subrequest +syn keyword ngxDirective map_hash_bucket_size +syn keyword ngxDirective map_hash_max_size +syn keyword ngxDirective master_process +syn keyword ngxDirective memcached_bind +syn keyword ngxDirective memcached_buffer_size +syn keyword ngxDirective memcached_connect_timeout +syn keyword ngxDirective memcached_next_upstream +syn keyword ngxDirective memcached_read_timeout +syn keyword ngxDirective memcached_send_timeout +syn keyword ngxDirective memcached_upstream_fail_timeout +syn keyword ngxDirective memcached_upstream_max_fails +syn keyword ngxDirective merge_slashes +syn keyword ngxDirective min_delete_depth +syn keyword ngxDirective modern_browser +syn keyword ngxDirective modern_browser_value +syn keyword ngxDirective msie_padding +syn keyword ngxDirective msie_refresh +syn keyword ngxDirective multi_accept +syn keyword ngxDirective open_file_cache +syn keyword ngxDirective open_file_cache_errors +syn keyword ngxDirective open_file_cache_events +syn keyword ngxDirective open_file_cache_min_uses +syn keyword ngxDirective open_file_cache_valid +syn keyword ngxDirective open_log_file_cache +syn keyword ngxDirective output_buffers +syn keyword ngxDirective override_charset +syn keyword ngxDirective perl +syn keyword ngxDirective perl_modules +syn keyword ngxDirective perl_require +syn keyword ngxDirective perl_set +syn keyword ngxDirective pid +syn keyword ngxDirective pop3_auth +syn keyword ngxDirective pop3_capabilities +syn keyword ngxDirective port_in_redirect +syn keyword ngxDirective postpone_gzipping +syn keyword ngxDirective postpone_output +syn keyword ngxDirective protocol +syn keyword ngxDirective proxy +syn keyword ngxDirective proxy_bind +syn keyword ngxDirective proxy_buffer +syn keyword ngxDirective proxy_buffer_size +syn keyword ngxDirective proxy_buffering +syn keyword ngxDirective proxy_buffers +syn keyword ngxDirective proxy_busy_buffers_size +syn keyword ngxDirective proxy_cache +syn keyword ngxDirective proxy_cache_key +syn keyword ngxDirective proxy_cache_methods +syn keyword ngxDirective proxy_cache_min_uses +syn keyword ngxDirective proxy_cache_path +syn keyword ngxDirective proxy_cache_use_stale +syn keyword ngxDirective proxy_cache_valid +syn keyword ngxDirective proxy_connect_timeout +syn keyword ngxDirective proxy_headers_hash_bucket_size +syn keyword ngxDirective proxy_headers_hash_max_size +syn keyword ngxDirective proxy_hide_header +syn keyword ngxDirective proxy_ignore_client_abort +syn keyword ngxDirective proxy_ignore_headers +syn keyword ngxDirective proxy_intercept_errors +syn keyword ngxDirective proxy_max_temp_file_size +syn keyword ngxDirective proxy_method +syn keyword ngxDirective proxy_next_upstream +syn keyword ngxDirective proxy_pass_error_message +syn keyword ngxDirective proxy_pass_header +syn keyword ngxDirective proxy_pass_request_body +syn keyword ngxDirective proxy_pass_request_headers +syn keyword ngxDirective proxy_read_timeout +syn keyword ngxDirective proxy_redirect +syn keyword ngxDirective proxy_send_lowat +syn keyword ngxDirective proxy_send_timeout +syn keyword ngxDirective proxy_set_body +syn keyword ngxDirective proxy_set_header +syn keyword ngxDirective proxy_ssl_session_reuse +syn keyword ngxDirective proxy_store +syn keyword ngxDirective proxy_store_access +syn keyword ngxDirective proxy_temp_file_write_size +syn keyword ngxDirective proxy_temp_path +syn keyword ngxDirective proxy_timeout +syn keyword ngxDirective proxy_upstream_fail_timeout +syn keyword ngxDirective proxy_upstream_max_fails +syn keyword ngxDirective random_index +syn keyword ngxDirective read_ahead +syn keyword ngxDirective real_ip_header +syn keyword ngxDirective recursive_error_pages +syn keyword ngxDirective request_pool_size +syn keyword ngxDirective reset_timedout_connection +syn keyword ngxDirective resolver +syn keyword ngxDirective resolver_timeout +syn keyword ngxDirective rewrite_log +syn keyword ngxDirective rtsig_overflow_events +syn keyword ngxDirective rtsig_overflow_test +syn keyword ngxDirective rtsig_overflow_threshold +syn keyword ngxDirective rtsig_signo +syn keyword ngxDirective satisfy +syn keyword ngxDirective secure_link_secret +syn keyword ngxDirective send_lowat +syn keyword ngxDirective send_timeout +syn keyword ngxDirective sendfile +syn keyword ngxDirective sendfile_max_chunk +syn keyword ngxDirective server_name_in_redirect +syn keyword ngxDirective server_names_hash_bucket_size +syn keyword ngxDirective server_names_hash_max_size +syn keyword ngxDirective server_tokens +syn keyword ngxDirective set_real_ip_from +syn keyword ngxDirective smtp_auth +syn keyword ngxDirective smtp_capabilities +syn keyword ngxDirective smtp_client_buffer +syn keyword ngxDirective smtp_greeting_delay +syn keyword ngxDirective so_keepalive +syn keyword ngxDirective source_charset +syn keyword ngxDirective ssi +syn keyword ngxDirective ssi_ignore_recycled_buffers +syn keyword ngxDirective ssi_min_file_chunk +syn keyword ngxDirective ssi_silent_errors +syn keyword ngxDirective ssi_types +syn keyword ngxDirective ssi_value_length +syn keyword ngxDirective ssl +syn keyword ngxDirective ssl_certificate +syn keyword ngxDirective ssl_certificate_key +syn keyword ngxDirective ssl_ciphers +syn keyword ngxDirective ssl_client_certificate +syn keyword ngxDirective ssl_crl +syn keyword ngxDirective ssl_dhparam +syn keyword ngxDirective ssl_engine +syn keyword ngxDirective ssl_prefer_server_ciphers +syn keyword ngxDirective ssl_protocols +syn keyword ngxDirective ssl_session_cache +syn keyword ngxDirective ssl_session_timeout +syn keyword ngxDirective ssl_verify_client +syn keyword ngxDirective ssl_verify_depth +syn keyword ngxDirective starttls +syn keyword ngxDirective stub_status +syn keyword ngxDirective sub_filter +syn keyword ngxDirective sub_filter_once +syn keyword ngxDirective sub_filter_types +syn keyword ngxDirective tcp_nodelay +syn keyword ngxDirective tcp_nopush +syn keyword ngxDirective thread_stack_size +syn keyword ngxDirective timeout +syn keyword ngxDirective timer_resolution +syn keyword ngxDirective types_hash_bucket_size +syn keyword ngxDirective types_hash_max_size +syn keyword ngxDirective underscores_in_headers +syn keyword ngxDirective uninitialized_variable_warn +syn keyword ngxDirective use +syn keyword ngxDirective user +syn keyword ngxDirective userid +syn keyword ngxDirective userid_domain +syn keyword ngxDirective userid_expires +syn keyword ngxDirective userid_mark +syn keyword ngxDirective userid_name +syn keyword ngxDirective userid_p3p +syn keyword ngxDirective userid_path +syn keyword ngxDirective userid_service +syn keyword ngxDirective valid_referers +syn keyword ngxDirective variables_hash_bucket_size +syn keyword ngxDirective variables_hash_max_size +syn keyword ngxDirective worker_connections +syn keyword ngxDirective worker_cpu_affinity +syn keyword ngxDirective worker_priority +syn keyword ngxDirective worker_processes +syn keyword ngxDirective worker_rlimit_core +syn keyword ngxDirective worker_rlimit_nofile +syn keyword ngxDirective worker_rlimit_sigpending +syn keyword ngxDirective worker_threads +syn keyword ngxDirective working_directory +syn keyword ngxDirective xclient +syn keyword ngxDirective xml_entities +syn keyword ngxDirective xslt_stylesheet +syn keyword ngxDirective xslt_types + +" 3rd party module list: +" http://wiki.nginx.org/Nginx3rdPartyModules + +" Accept Language Module <http://wiki.nginx.org/NginxAcceptLanguageModule> +" Parses the Accept-Language header and gives the most suitable locale from a list of supported locales. +syn keyword ngxDirectiveThirdParty set_from_accept_language + +" Access Key Module <http://wiki.nginx.org/NginxHttpAccessKeyModule> +" Denies access unless the request URL contains an access key.  +syn keyword ngxDirectiveThirdParty accesskey +syn keyword ngxDirectiveThirdParty accesskey_arg +syn keyword ngxDirectiveThirdParty accesskey_hashmethod +syn keyword ngxDirectiveThirdParty accesskey_signature + +" Auth PAM Module <http://web.iti.upv.es/~sto/nginx/> +" HTTP Basic Authentication using PAM. +syn keyword ngxDirectiveThirdParty auth_pam +syn keyword ngxDirectiveThirdParty auth_pam_service_name + +" Cache Purge Module <http://labs.frickle.com/nginx_ngx_cache_purge/> +" Module adding ability to purge content from FastCGI and proxy caches. +syn keyword ngxDirectiveThirdParty fastcgi_cache_purge +syn keyword ngxDirectiveThirdParty proxy_cache_purge + +" Chunkin Module <http://wiki.nginx.org/NginxHttpChunkinModule> +" HTTP 1.1 chunked-encoding request body support for Nginx. +syn keyword ngxDirectiveThirdParty chunkin +syn keyword ngxDirectiveThirdParty chunkin_keepalive +syn keyword ngxDirectiveThirdParty chunkin_max_chunks_per_buf +syn keyword ngxDirectiveThirdParty chunkin_resume + +" Circle GIF Module <http://wiki.nginx.org/NginxHttpCircleGifModule> +" Generates simple circle images with the colors and size specified in the URL. +syn keyword ngxDirectiveThirdParty circle_gif +syn keyword ngxDirectiveThirdParty circle_gif_max_radius +syn keyword ngxDirectiveThirdParty circle_gif_min_radius +syn keyword ngxDirectiveThirdParty circle_gif_step_radius + +" Drizzle Module <http://github.com/chaoslawful/drizzle-nginx-module> +" Make nginx talk directly to mysql, drizzle, and sqlite3 by libdrizzle. +syn keyword ngxDirectiveThirdParty drizzle_connect_timeout +syn keyword ngxDirectiveThirdParty drizzle_dbname +syn keyword ngxDirectiveThirdParty drizzle_keepalive +syn keyword ngxDirectiveThirdParty drizzle_module_header +syn keyword ngxDirectiveThirdParty drizzle_pass +syn keyword ngxDirectiveThirdParty drizzle_query +syn keyword ngxDirectiveThirdParty drizzle_recv_cols_timeout +syn keyword ngxDirectiveThirdParty drizzle_recv_rows_timeout +syn keyword ngxDirectiveThirdParty drizzle_send_query_timeout +syn keyword ngxDirectiveThirdParty drizzle_server + +" Echo Module <http://wiki.nginx.org/NginxHttpEchoModule> +" Brings 'echo', 'sleep', 'time', 'exec' and more shell-style goodies to Nginx config file. +syn keyword ngxDirectiveThirdParty echo +syn keyword ngxDirectiveThirdParty echo_after_body +syn keyword ngxDirectiveThirdParty echo_before_body +syn keyword ngxDirectiveThirdParty echo_blocking_sleep +syn keyword ngxDirectiveThirdParty echo_duplicate +syn keyword ngxDirectiveThirdParty echo_end +syn keyword ngxDirectiveThirdParty echo_exec +syn keyword ngxDirectiveThirdParty echo_flush +syn keyword ngxDirectiveThirdParty echo_foreach_split +syn keyword ngxDirectiveThirdParty echo_location +syn keyword ngxDirectiveThirdParty echo_location_async +syn keyword ngxDirectiveThirdParty echo_read_request_body +syn keyword ngxDirectiveThirdParty echo_request_body +syn keyword ngxDirectiveThirdParty echo_reset_timer +syn keyword ngxDirectiveThirdParty echo_sleep +syn keyword ngxDirectiveThirdParty echo_subrequest +syn keyword ngxDirectiveThirdParty echo_subrequest_async + +" Events Module <http://docs.dutov.org/nginx_modules_events_en.html> +" Privides options for start/stop events. +syn keyword ngxDirectiveThirdParty on_start +syn keyword ngxDirectiveThirdParty on_stop + +" EY Balancer Module <http://github.com/ry/nginx-ey-balancer> +" Adds a request queue to Nginx that allows the limiting of concurrent requests passed to the upstream. +syn keyword ngxDirectiveThirdParty max_connections +syn keyword ngxDirectiveThirdParty max_connections_max_queue_length +syn keyword ngxDirectiveThirdParty max_connections_queue_timeout + +" Fancy Indexes Module <https://connectical.com/projects/ngx-fancyindex/wiki> +" Like the built-in autoindex module, but fancier. +syn keyword ngxDirectiveThirdParty fancyindex +syn keyword ngxDirectiveThirdParty fancyindex_exact_size +syn keyword ngxDirectiveThirdParty fancyindex_footer +syn keyword ngxDirectiveThirdParty fancyindex_header +syn keyword ngxDirectiveThirdParty fancyindex_localtime +syn keyword ngxDirectiveThirdParty fancyindex_readme +syn keyword ngxDirectiveThirdParty fancyindex_readme_mode + +" GeoIP Module (DEPRECATED) <http://wiki.nginx.org/NginxHttp3rdPartyGeoIPModule> +" Country code lookups via the MaxMind GeoIP API. +syn keyword ngxDirectiveThirdParty geoip_country_file + +" Headers More Module <http://wiki.nginx.org/NginxHttpHeadersMoreModule> +" Set and clear input and output headers...more than "add"! +syn keyword ngxDirectiveThirdParty more_clear_headers +syn keyword ngxDirectiveThirdParty more_clear_input_headers +syn keyword ngxDirectiveThirdParty more_set_headers +syn keyword ngxDirectiveThirdParty more_set_input_headers + +" HTTP Push Module <http://pushmodule.slact.net/> +" Turn Nginx into an adept long-polling HTTP Push (Comet) server. +syn keyword ngxDirectiveThirdParty push_buffer_size +syn keyword ngxDirectiveThirdParty push_listener +syn keyword ngxDirectiveThirdParty push_message_timeout +syn keyword ngxDirectiveThirdParty push_queue_messages +syn keyword ngxDirectiveThirdParty push_sender + +" HTTP Redis Module <http://people.FreeBSD.ORG/~osa/ngx_http_redis-0.3.1.tar.gz>> +" Redis <http://code.google.com/p/redis/> support.> +syn keyword ngxDirectiveThirdParty redis_bind +syn keyword ngxDirectiveThirdParty redis_buffer_size +syn keyword ngxDirectiveThirdParty redis_connect_timeout +syn keyword ngxDirectiveThirdParty redis_next_upstream +syn keyword ngxDirectiveThirdParty redis_pass +syn keyword ngxDirectiveThirdParty redis_read_timeout +syn keyword ngxDirectiveThirdParty redis_send_timeout + +" HTTP JavaScript Module <http://wiki.github.com/kung-fu-tzu/ngx_http_js_module> +" Embedding SpiderMonkey. Nearly full port on Perl module. +syn keyword ngxDirectiveThirdParty js +syn keyword ngxDirectiveThirdParty js_filter +syn keyword ngxDirectiveThirdParty js_filter_types +syn keyword ngxDirectiveThirdParty js_load +syn keyword ngxDirectiveThirdParty js_maxmem +syn keyword ngxDirectiveThirdParty js_require +syn keyword ngxDirectiveThirdParty js_set +syn keyword ngxDirectiveThirdParty js_utf8 + +" Log Request Speed <http://wiki.nginx.org/NginxHttpLogRequestSpeed> +" Log the time it took to process each request. +syn keyword ngxDirectiveThirdParty log_request_speed_filter +syn keyword ngxDirectiveThirdParty log_request_speed_filter_timeout + +" Memc Module <http://wiki.nginx.org/NginxHttpMemcModule> +" An extended version of the standard memcached module that supports set, add, delete, and many more memcached commands. +syn keyword ngxDirectiveThirdParty memc_buffer_size +syn keyword ngxDirectiveThirdParty memc_cmds_allowed +syn keyword ngxDirectiveThirdParty memc_connect_timeout +syn keyword ngxDirectiveThirdParty memc_flags_to_last_modified +syn keyword ngxDirectiveThirdParty memc_next_upstream +syn keyword ngxDirectiveThirdParty memc_pass +syn keyword ngxDirectiveThirdParty memc_read_timeout +syn keyword ngxDirectiveThirdParty memc_send_timeout +syn keyword ngxDirectiveThirdParty memc_upstream_fail_timeout +syn keyword ngxDirectiveThirdParty memc_upstream_max_fails + +" Mogilefs Module <http://www.grid.net.ru/nginx/mogilefs.en.html> +" Implements a MogileFS client, provides a replace to the Perlbal reverse proxy of the original MogileFS. +syn keyword ngxDirectiveThirdParty mogilefs_connect_timeout +syn keyword ngxDirectiveThirdParty mogilefs_domain +syn keyword ngxDirectiveThirdParty mogilefs_methods +syn keyword ngxDirectiveThirdParty mogilefs_noverify +syn keyword ngxDirectiveThirdParty mogilefs_pass +syn keyword ngxDirectiveThirdParty mogilefs_read_timeout +syn keyword ngxDirectiveThirdParty mogilefs_send_timeout +syn keyword ngxDirectiveThirdParty mogilefs_tracker + +" MP4 Streaming Lite Module <http://wiki.nginx.org/NginxMP4StreamingLite> +" Will seek to a certain time within H.264/MP4 files when provided with a 'start' parameter in the URL.  +syn keyword ngxDirectiveThirdParty mp4 + +" Nginx Notice Module <http://xph.us/software/nginx-notice/> +" Serve static file to POST requests. +syn keyword ngxDirectiveThirdParty notice +syn keyword ngxDirectiveThirdParty notice_type + +" Phusion Passenger <http://www.modrails.com/documentation.html> +" Easy and robust deployment of Ruby on Rails application on Apache and Nginx webservers. +syn keyword ngxDirectiveThirdParty passenger_base_uri +syn keyword ngxDirectiveThirdParty passenger_default_user +syn keyword ngxDirectiveThirdParty passenger_enabled +syn keyword ngxDirectiveThirdParty passenger_log_level +syn keyword ngxDirectiveThirdParty passenger_max_instances_per_app +syn keyword ngxDirectiveThirdParty passenger_max_pool_size +syn keyword ngxDirectiveThirdParty passenger_pool_idle_time +syn keyword ngxDirectiveThirdParty passenger_root +syn keyword ngxDirectiveThirdParty passenger_ruby +syn keyword ngxDirectiveThirdParty passenger_use_global_queue +syn keyword ngxDirectiveThirdParty passenger_user_switching +syn keyword ngxDirectiveThirdParty rack_env +syn keyword ngxDirectiveThirdParty rails_app_spawner_idle_time +syn keyword ngxDirectiveThirdParty rails_env +syn keyword ngxDirectiveThirdParty rails_framework_spawner_idle_time +syn keyword ngxDirectiveThirdParty rails_spawn_method + +" RDS JSON Module <http://github.com/agentzh/rds-json-nginx-module> +" Help ngx_drizzle and other DBD modules emit JSON data. +syn keyword ngxDirectiveThirdParty rds_json +syn keyword ngxDirectiveThirdParty rds_json_content_type +syn keyword ngxDirectiveThirdParty rds_json_format +syn keyword ngxDirectiveThirdParty rds_json_ret + +" RRD Graph Module <http://wiki.nginx.org/NginxNgx_rrd_graph> +" This module provides an HTTP interface to RRDtool's graphing facilities. +syn keyword ngxDirectiveThirdParty rrd_graph +syn keyword ngxDirectiveThirdParty rrd_graph_root + +" Secure Download <http://wiki.nginx.org/NginxHttpSecureDownload> +" Create expiring links. +syn keyword ngxDirectiveThirdParty secure_download +syn keyword ngxDirectiveThirdParty secure_download_fail_location +syn keyword ngxDirectiveThirdParty secure_download_path_mode +syn keyword ngxDirectiveThirdParty secure_download_secret + +" SlowFS Cache Module <http://labs.frickle.com/nginx_ngx_slowfs_cache/> +" Module adding ability to cache static files. +syn keyword ngxDirectiveThirdParty slowfs_big_file_size +syn keyword ngxDirectiveThirdParty slowfs_cache +syn keyword ngxDirectiveThirdParty slowfs_cache_key +syn keyword ngxDirectiveThirdParty slowfs_cache_min_uses +syn keyword ngxDirectiveThirdParty slowfs_cache_path +syn keyword ngxDirectiveThirdParty slowfs_cache_purge +syn keyword ngxDirectiveThirdParty slowfs_cache_valid +syn keyword ngxDirectiveThirdParty slowfs_temp_path + +" Strip Module <http://wiki.nginx.org/NginxHttpStripModule> +" Whitespace remover. +syn keyword ngxDirectiveThirdParty strip + +" Substitutions Module <http://wiki.nginx.org/NginxHttpSubsModule> +" A filter module which can do both regular expression and fixed string substitutions on response bodies. +syn keyword ngxDirectiveThirdParty subs_filter +syn keyword ngxDirectiveThirdParty subs_filter_types + +" Supervisord Module <http://labs.frickle.com/nginx_ngx_supervisord/> +" Module providing nginx with API to communicate with supervisord and manage (start/stop) backends on-demand. +syn keyword ngxDirectiveThirdParty supervisord +syn keyword ngxDirectiveThirdParty supervisord_inherit_backend_status +syn keyword ngxDirectiveThirdParty supervisord_name +syn keyword ngxDirectiveThirdParty supervisord_start +syn keyword ngxDirectiveThirdParty supervisord_stop + +" Upload Module <http://www.grid.net.ru/nginx/upload.en.html> +" Parses multipart/form-data allowing arbitrary handling of uploaded files. +syn keyword ngxDirectiveThirdParty upload_aggregate_form_field +syn keyword ngxDirectiveThirdParty upload_buffer_size +syn keyword ngxDirectiveThirdParty upload_cleanup +syn keyword ngxDirectiveThirdParty upload_limit_rate +syn keyword ngxDirectiveThirdParty upload_max_file_size +syn keyword ngxDirectiveThirdParty upload_max_output_body_len +syn keyword ngxDirectiveThirdParty upload_max_part_header_len +syn keyword ngxDirectiveThirdParty upload_pass +syn keyword ngxDirectiveThirdParty upload_pass_args +syn keyword ngxDirectiveThirdParty upload_pass_form_field +syn keyword ngxDirectiveThirdParty upload_set_form_field +syn keyword ngxDirectiveThirdParty upload_store +syn keyword ngxDirectiveThirdParty upload_store_access + +" Upload Progress Module <http://wiki.nginx.org/NginxHttpUploadProgressModule> +" Tracks and reports upload progress. +syn keyword ngxDirectiveThirdParty report_uploads +syn keyword ngxDirectiveThirdParty track_uploads +syn keyword ngxDirectiveThirdParty upload_progress +syn keyword ngxDirectiveThirdParty upload_progress_content_type +syn keyword ngxDirectiveThirdParty upload_progress_header +syn keyword ngxDirectiveThirdParty upload_progress_json_output +syn keyword ngxDirectiveThirdParty upload_progress_template + +" Upstream Fair Balancer <http://wiki.nginx.org/NginxHttpUpstreamFairModule> +" Sends an incoming request to the least-busy backend server, rather than distributing requests round-robin. +syn keyword ngxDirectiveThirdParty fair +syn keyword ngxDirectiveThirdParty upstream_fair_shm_size + +" Upstream Consistent Hash <http://wiki.nginx.org/NginxHttpUpstreamConsistentHash> +" Select backend based on Consistent hash ring. +syn keyword ngxDirectiveThirdParty consistent_hash + +" Upstream Hash Module <http://wiki.nginx.org/NginxHttpUpstreamRequestHashModule> +" Provides simple upstream load distribution by hashing a configurable variable. +syn keyword ngxDirectiveThirdParty hash +syn keyword ngxDirectiveThirdParty hash_again + +" XSS Module <http://github.com/agentzh/xss-nginx-module> +" Native support for cross-site scripting (XSS) in an nginx. +syn keyword ngxDirectiveThirdParty xss_callback_arg +syn keyword ngxDirectiveThirdParty xss_get +syn keyword ngxDirectiveThirdParty xss_input_types +syn keyword ngxDirectiveThirdParty xss_output_type + +" highlight + +hi link ngxComment Comment +hi link ngxVariable Identifier +hi link ngxVariableBlock Identifier +hi link ngxVariableString PreProc +hi link ngxBlock Normal +hi link ngxString String + +hi link ngxBoolean Boolean +hi link ngxDirectiveBlock Statement +hi link ngxDirectiveImportant Type +hi link ngxDirectiveControl Keyword +hi link ngxDirectiveError Constant +hi link ngxDirectiveDeprecated Error +hi link ngxDirective Identifier +hi link ngxDirectiveThirdParty Special + +let b:current_syntax = "nginx" diff --git a/syntax/ocaml.vim b/syntax/ocaml.vim new file mode 100644 index 00000000..e2abc552 --- /dev/null +++ b/syntax/ocaml.vim @@ -0,0 +1,331 @@ +" Vim syntax file +" Language:     OCaml +" Filenames:    *.ml *.mli *.mll *.mly +" Maintainers:  Markus Mottl      <markus.mottl@gmail.com> +"               Karl-Heinz Sylla  <Karl-Heinz.Sylla@gmd.de> +"               Issac Trotts      <ijtrotts@ucdavis.edu> +" URL:          http://www.ocaml.info/vim/syntax/ocaml.vim +" Last Change:  2010 Oct 11 - Added highlighting of lnot (MM, thanks to Erick Matsen) +"               2010 Sep 03 - Fixed escaping bug (MM, thanks to Florent Monnier) +"               2010 Aug 07 - Fixed module type bug (MM) + +" A minor patch was applied to the official version so that object/end +" can be distinguished from begin/end, which is used for indentation, +" and folding. (David Baelde) + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 +  syntax clear +elseif exists("b:current_syntax") && b:current_syntax == "ocaml" +  finish +endif + +" OCaml is case sensitive. +syn case match + +" Access to the method of an object +syn match    ocamlMethod       "#" + +" Script headers highlighted like comments +syn match    ocamlComment   "^#!.*" + +" Scripting directives +syn match    ocamlScript "^#\<\(quit\|labels\|warnings\|directory\|cd\|load\|use\|install_printer\|remove_printer\|require\|thread\|trace\|untrace\|untrace_all\|print_depth\|print_length\|camlp4o\)\>" + +" lowercase identifier - the standard way to match +syn match    ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/ + +syn match    ocamlKeyChar    "|" + +" Errors +syn match    ocamlBraceErr   "}" +syn match    ocamlBrackErr   "\]" +syn match    ocamlParenErr   ")" +syn match    ocamlArrErr     "|]" + +syn match    ocamlCommentErr "\*)" + +syn match    ocamlCountErr   "\<downto\>" +syn match    ocamlCountErr   "\<to\>" + +if !exists("ocaml_revised") +  syn match    ocamlDoErr      "\<do\>" +endif + +syn match    ocamlDoneErr    "\<done\>" +syn match    ocamlThenErr    "\<then\>" + +" Error-highlighting of "end" without synchronization: +" as keyword or as error (default) +if exists("ocaml_noend_error") +  syn match    ocamlKeyword    "\<end\>" +else +  syn match    ocamlEndErr     "\<end\>" +endif + +" Some convenient clusters +syn cluster  ocamlAllErrs contains=ocamlBraceErr,ocamlBrackErr,ocamlParenErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr + +syn cluster  ocamlAENoParen contains=ocamlBraceErr,ocamlBrackErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr + +syn cluster  ocamlContained contains=ocamlTodo,ocamlPreDef,ocamlModParam,ocamlModParam1,ocamlPreMPRestr,ocamlMPRestr,ocamlMPRestr1,ocamlMPRestr2,ocamlMPRestr3,ocamlModRHS,ocamlFuncWith,ocamlFuncStruct,ocamlModTypeRestr,ocamlModTRWith,ocamlWith,ocamlWithRest,ocamlModType,ocamlFullMod,ocamlVal + + +" Enclosing delimiters +syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="(" matchgroup=ocamlKeyword end=")" contains=ALLBUT,@ocamlContained,ocamlParenErr +syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="{" matchgroup=ocamlKeyword end="}"  contains=ALLBUT,@ocamlContained,ocamlBraceErr +syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="\[" matchgroup=ocamlKeyword end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr +syn region   ocamlEncl transparent matchgroup=ocamlKeyword start="\[|" matchgroup=ocamlKeyword end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr + + +" Comments +syn region   ocamlComment start="(\*" end="\*)" contains=ocamlComment,ocamlTodo +syn keyword  ocamlTodo contained TODO FIXME XXX NOTE + + +" Objects +syn region   ocamlEnd matchgroup=ocamlObject start="\<object\>" matchgroup=ocamlObject end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr + + +" Blocks +if !exists("ocaml_revised") +  syn region   ocamlEnd matchgroup=ocamlKeyword start="\<begin\>" matchgroup=ocamlKeyword end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr +endif + + +" "for" +syn region   ocamlNone matchgroup=ocamlKeyword start="\<for\>" matchgroup=ocamlKeyword end="\<\(to\|downto\)\>" contains=ALLBUT,@ocamlContained,ocamlCountErr + + +" "do" +if !exists("ocaml_revised") +  syn region   ocamlDo matchgroup=ocamlKeyword start="\<do\>" matchgroup=ocamlKeyword end="\<done\>" contains=ALLBUT,@ocamlContained,ocamlDoneErr +endif + +" "if" +syn region   ocamlNone matchgroup=ocamlKeyword start="\<if\>" matchgroup=ocamlKeyword end="\<then\>" contains=ALLBUT,@ocamlContained,ocamlThenErr + + +"" Modules + +" "sig" +syn region   ocamlSig matchgroup=ocamlModule start="\<sig\>" matchgroup=ocamlModule end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr,ocamlModule +syn region   ocamlModSpec matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\>" contained contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlModTRWith,ocamlMPRestr + +" "open" +syn region   ocamlNone matchgroup=ocamlKeyword start="\<open\>" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*\>" contains=@ocamlAllErrs,ocamlComment + +" "include" +syn match    ocamlKeyword "\<include\>" skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod + +" "module" - somewhat complicated stuff ;-) +syn region   ocamlModule matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<\u\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlPreDef +syn region   ocamlPreDef start="."me=e-1 matchgroup=ocamlKeyword end="\l\|=\|)"me=e-1 contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlModTypeRestr,ocamlModTRWith nextgroup=ocamlModPreRHS +syn region   ocamlModParam start="([^*]" end=")" contained contains=@ocamlAENoParen,ocamlModParam1,ocamlVal +syn match    ocamlModParam1 "\<\u\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlPreMPRestr + +syn region   ocamlPreMPRestr start="."me=e-1 end=")"me=e-1 contained contains=@ocamlAllErrs,ocamlComment,ocamlMPRestr,ocamlModTypeRestr + +syn region   ocamlMPRestr start=":" end="."me=e-1 contained contains=@ocamlComment skipwhite skipempty nextgroup=ocamlMPRestr1,ocamlMPRestr2,ocamlMPRestr3 +syn region   ocamlMPRestr1 matchgroup=ocamlModule start="\ssig\s\=" matchgroup=ocamlModule end="\<end\>" contained contains=ALLBUT,@ocamlContained,ocamlEndErr,ocamlModule +syn region   ocamlMPRestr2 start="\sfunctor\(\s\|(\)\="me=e-1 matchgroup=ocamlKeyword end="->" contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam skipwhite skipempty nextgroup=ocamlFuncWith,ocamlMPRestr2 +syn match    ocamlMPRestr3 "\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*" contained +syn match    ocamlModPreRHS "=" contained skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod +syn keyword  ocamlKeyword val +syn region   ocamlVal matchgroup=ocamlKeyword start="\<val\>" matchgroup=ocamlLCIdentifier end="\<\l\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlMPRestr +syn region   ocamlModRHS start="." end=".\w\|([^*]"me=e-2 contained contains=ocamlComment skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod +syn match    ocamlFullMod "\<\u\(\w\|'\)*\(\.\u\(\w\|'\)*\)*" contained skipwhite skipempty nextgroup=ocamlFuncWith + +syn region   ocamlFuncWith start="([^*]"me=e-1 end=")" contained contains=ocamlComment,ocamlWith,ocamlFuncStruct skipwhite skipempty nextgroup=ocamlFuncWith +syn region   ocamlFuncStruct matchgroup=ocamlModule start="[^a-zA-Z]struct\>"hs=s+1 matchgroup=ocamlModule end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr + +syn match    ocamlModTypeRestr "\<\w\(\w\|'\)*\(\.\w\(\w\|'\)*\)*\>" contained +syn region   ocamlModTRWith start=":\s*("hs=s+1 end=")" contained contains=@ocamlAENoParen,ocamlWith +syn match    ocamlWith "\<\(\u\(\w\|'\)*\.\)*\w\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlWithRest +syn region   ocamlWithRest start="[^)]" end=")"me=e-1 contained contains=ALLBUT,@ocamlContained + +" "struct" +syn region   ocamlStruct matchgroup=ocamlModule start="\<\(module\s\+\)\=struct\>" matchgroup=ocamlModule end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr + +" "module type" +syn region   ocamlKeyword start="\<module\>\s*\<type\>\(\s*\<of\>\)\=" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef +syn match    ocamlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s + +syn keyword  ocamlKeyword  and as assert class +syn keyword  ocamlKeyword  constraint else +syn keyword  ocamlKeyword  exception external fun + +syn keyword  ocamlKeyword  in inherit initializer +syn keyword  ocamlKeyword  land lazy let match +syn keyword  ocamlKeyword  method mutable new of +syn keyword  ocamlKeyword  parser private raise rec +syn keyword  ocamlKeyword  try type +syn keyword  ocamlKeyword  virtual when while with + +if exists("ocaml_revised") +  syn keyword  ocamlKeyword  do value +  syn keyword  ocamlBoolean  True False +else +  syn keyword  ocamlKeyword  function +  syn keyword  ocamlBoolean  true false +  syn match    ocamlKeyChar  "!" +endif + +syn keyword  ocamlType     array bool char exn float format format4 +syn keyword  ocamlType     int int32 int64 lazy_t list nativeint option +syn keyword  ocamlType     string unit + +syn keyword  ocamlOperator asr lnot lor lsl lsr lxor mod not + +syn match    ocamlConstructor  "(\s*)" +syn match    ocamlConstructor  "\[\s*\]" +syn match    ocamlConstructor  "\[|\s*>|]" +syn match    ocamlConstructor  "\[<\s*>\]" +syn match    ocamlConstructor  "\u\(\w\|'\)*\>" + +" Polymorphic variants +syn match    ocamlConstructor  "`\w\(\w\|'\)*\>" + +" Module prefix +syn match    ocamlModPath      "\u\(\w\|'\)*\."he=e-1 + +syn match    ocamlCharacter    "'\\\d\d\d'\|'\\[\'ntbr]'\|'.'" +syn match    ocamlCharacter    "'\\x\x\x'" +syn match    ocamlCharErr      "'\\\d\d'\|'\\\d'" +syn match    ocamlCharErr      "'\\[^\'ntbr]'" +syn region   ocamlString       start=+"+ skip=+\\\\\|\\"+ end=+"+ + +syn match    ocamlFunDef       "->" +syn match    ocamlRefAssign    ":=" +syn match    ocamlTopStop      ";;" +syn match    ocamlOperator     "\^" +syn match    ocamlOperator     "::" + +syn match    ocamlOperator     "&&" +syn match    ocamlOperator     "<" +syn match    ocamlOperator     ">" +syn match    ocamlAnyVar       "\<_\>" +syn match    ocamlKeyChar      "|[^\]]"me=e-1 +syn match    ocamlKeyChar      ";" +syn match    ocamlKeyChar      "\~" +syn match    ocamlKeyChar      "?" +syn match    ocamlKeyChar      "\*" +syn match    ocamlKeyChar      "=" + +if exists("ocaml_revised") +  syn match    ocamlErr        "<-" +else +  syn match    ocamlOperator   "<-" +endif + +syn match    ocamlNumber        "\<-\=\d\(_\|\d\)*[l|L|n]\?\>" +syn match    ocamlNumber        "\<-\=0[x|X]\(\x\|_\)\+[l|L|n]\?\>" +syn match    ocamlNumber        "\<-\=0[o|O]\(\o\|_\)\+[l|L|n]\?\>" +syn match    ocamlNumber        "\<-\=0[b|B]\([01]\|_\)\+[l|L|n]\?\>" +syn match    ocamlFloat         "\<-\=\d\(_\|\d\)*\.\?\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>" + +" Labels +syn match    ocamlLabel        "\~\(\l\|_\)\(\w\|'\)*"lc=1 +syn match    ocamlLabel        "?\(\l\|_\)\(\w\|'\)*"lc=1 +syn region   ocamlLabel transparent matchgroup=ocamlLabel start="?(\(\l\|_\)\(\w\|'\)*"lc=2 end=")"me=e-1 contains=ALLBUT,@ocamlContained,ocamlParenErr + + +" Synchronization +syn sync minlines=50 +syn sync maxlines=500 + +if !exists("ocaml_revised") +  syn sync match ocamlDoSync      grouphere  ocamlDo      "\<do\>" +  syn sync match ocamlDoSync      groupthere ocamlDo      "\<done\>" +endif + +if exists("ocaml_revised") +  syn sync match ocamlEndSync     grouphere  ocamlEnd     "\<\(object\)\>" +else +  syn sync match ocamlEndSync     grouphere  ocamlEnd     "\<\(begin\|object\)\>" +endif + +syn sync match ocamlEndSync     groupthere ocamlEnd     "\<end\>" +syn sync match ocamlStructSync  grouphere  ocamlStruct  "\<struct\>" +syn sync match ocamlStructSync  groupthere ocamlStruct  "\<end\>" +syn sync match ocamlSigSync     grouphere  ocamlSig     "\<sig\>" +syn sync match ocamlSigSync     groupthere ocamlSig     "\<end\>" + +" 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_ocaml_syntax_inits") +  if version < 508 +    let did_ocaml_syntax_inits = 1 +    command -nargs=+ HiLink hi link <args> +  else +    command -nargs=+ HiLink hi def link <args> +  endif + +  HiLink ocamlBraceErr	   Error +  HiLink ocamlBrackErr	   Error +  HiLink ocamlParenErr	   Error +  HiLink ocamlArrErr	   Error + +  HiLink ocamlCommentErr   Error + +  HiLink ocamlCountErr	   Error +  HiLink ocamlDoErr	   Error +  HiLink ocamlDoneErr	   Error +  HiLink ocamlEndErr	   Error +  HiLink ocamlThenErr	   Error + +  HiLink ocamlCharErr	   Error + +  HiLink ocamlErr	   Error + +  HiLink ocamlComment	   Comment + +  HiLink ocamlModPath	   Include +  HiLink ocamlObject	   Include +  HiLink ocamlModule	   Include +  HiLink ocamlModParam1    Include +  HiLink ocamlModType	   Include +  HiLink ocamlMPRestr3	   Include +  HiLink ocamlFullMod	   Include +  HiLink ocamlModTypeRestr Include +  HiLink ocamlWith	   Include +  HiLink ocamlMTDef	   Include + +  HiLink ocamlScript	   Include + +  HiLink ocamlConstructor  Constant + +  HiLink ocamlVal          Keyword +  HiLink ocamlModPreRHS    Keyword +  HiLink ocamlMPRestr2	   Keyword +  HiLink ocamlKeyword	   Keyword +  HiLink ocamlMethod	   Include +  HiLink ocamlFunDef	   Keyword +  HiLink ocamlRefAssign    Keyword +  HiLink ocamlKeyChar	   Keyword +  HiLink ocamlAnyVar	   Keyword +  HiLink ocamlTopStop	   Keyword +  HiLink ocamlOperator	   Keyword + +  HiLink ocamlBoolean	   Boolean +  HiLink ocamlCharacter    Character +  HiLink ocamlNumber	   Number +  HiLink ocamlFloat	   Float +  HiLink ocamlString	   String + +  HiLink ocamlLabel	   Identifier + +  HiLink ocamlType	   Type + +  HiLink ocamlTodo	   Todo + +  HiLink ocamlEncl	   Keyword + +  delcommand HiLink +endif + +let b:current_syntax = "ocaml" + +" vim: ts=8 diff --git a/syntax/ruby.vim b/syntax/ruby.vim new file mode 100644 index 00000000..08f71554 --- /dev/null +++ b/syntax/ruby.vim @@ -0,0 +1,369 @@ +" Vim syntax file +" Language:		Ruby +" Maintainer:		Doug Kearns <dougkearns@gmail.com> +" URL:			https://github.com/vim-ruby/vim-ruby +" Release Coordinator:	Doug Kearns <dougkearns@gmail.com> +" ---------------------------------------------------------------------------- +" +" Previous Maintainer:	Mirko Nasato +" Thanks to perl.vim authors, and to Reimer Behrends. :-) (MN) +" ---------------------------------------------------------------------------- + +if exists("b:current_syntax") +  finish +endif + +if has("folding") && exists("ruby_fold") +  setlocal foldmethod=syntax +endif + +syn cluster rubyNotTop contains=@rubyExtendedStringSpecial,@rubyRegexpSpecial,@rubyDeclaration,rubyConditional,rubyExceptional,rubyMethodExceptional,rubyTodo + +if exists("ruby_space_errors") +  if !exists("ruby_no_trail_space_error") +    syn match rubySpaceError display excludenl "\s\+$" +  endif +  if !exists("ruby_no_tab_space_error") +    syn match rubySpaceError display " \+\t"me=e-1 +  endif +endif + +" Operators +if exists("ruby_operators") +  syn match  rubyOperator "[~!^&|*/%+-]\|\%(class\s*\)\@<!<<\|<=>\|<=\|\%(<\|\<class\s\+\u\w*\s*\)\@<!<[^<]\@=\|===\|==\|=\~\|>>\|>=\|=\@<!>\|\*\*\|\.\.\.\|\.\.\|::" +  syn match  rubyOperator "->\|-=\|/=\|\*\*=\|\*=\|&&=\|&=\|&&\|||=\||=\|||\|%=\|+=\|!\~\|!=" +  syn region rubyBracketOperator matchgroup=rubyOperator start="\%(\w[?!]\=\|[]})]\)\@<=\[\s*" end="\s*]" contains=ALLBUT,@rubyNotTop +endif + +" Expression Substitution and Backslash Notation +syn match rubyStringEscape "\\\\\|\\[abefnrstv]\|\\\o\{1,3}\|\\x\x\{1,2}"						    contained display +syn match rubyStringEscape "\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)" contained display +syn match rubyQuoteEscape  "\\[\\']"											    contained display + +syn region rubyInterpolation	      matchgroup=rubyInterpolationDelimiter start="#{" end="}" contained contains=ALLBUT,@rubyNotTop +syn match  rubyInterpolation	      "#\%(\$\|@@\=\)\w\+"    display contained contains=rubyInterpolationDelimiter,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable,rubyPredefinedVariable +syn match  rubyInterpolationDelimiter "#\ze\%(\$\|@@\=\)\w\+" display contained +syn match  rubyInterpolation	      "#\$\%(-\w\|\W\)"       display contained contains=rubyInterpolationDelimiter,rubyPredefinedVariable,rubyInvalidVariable +syn match  rubyInterpolationDelimiter "#\ze\$\%(-\w\|\W\)"    display contained +syn region rubyNoInterpolation	      start="\\#{" end="}"            contained +syn match  rubyNoInterpolation	      "\\#{"		      display contained +syn match  rubyNoInterpolation	      "\\#\%(\$\|@@\=\)\w\+"  display contained +syn match  rubyNoInterpolation	      "\\#\$\W"		      display contained + +syn match rubyDelimEscape	"\\[(<{\[)>}\]]" transparent display contained contains=NONE + +syn region rubyNestedParentheses    start="("  skip="\\\\\|\\)"  matchgroup=rubyString end=")"	transparent contained +syn region rubyNestedCurlyBraces    start="{"  skip="\\\\\|\\}"  matchgroup=rubyString end="}"	transparent contained +syn region rubyNestedAngleBrackets  start="<"  skip="\\\\\|\\>"  matchgroup=rubyString end=">"	transparent contained +syn region rubyNestedSquareBrackets start="\[" skip="\\\\\|\\\]" matchgroup=rubyString end="\]"	transparent contained + +" These are mostly Oniguruma ready +syn region rubyRegexpComment	matchgroup=rubyRegexpSpecial   start="(?#"								  skip="\\)"  end=")"  contained +syn region rubyRegexpParens	matchgroup=rubyRegexpSpecial   start="(\(?:\|?<\=[=!]\|?>\|?<[a-z_]\w*>\|?[imx]*-[imx]*:\=\|\%(?#\)\@!\)" skip="\\)"  end=")"  contained transparent contains=@rubyRegexpSpecial +syn region rubyRegexpBrackets	matchgroup=rubyRegexpCharClass start="\[\^\="								  skip="\\\]" end="\]" contained transparent contains=rubyStringEscape,rubyRegexpEscape,rubyRegexpCharClass oneline +syn match  rubyRegexpCharClass	"\\[DdHhSsWw]"	       contained display +syn match  rubyRegexpCharClass	"\[:\^\=\%(alnum\|alpha\|ascii\|blank\|cntrl\|digit\|graph\|lower\|print\|punct\|space\|upper\|xdigit\):\]" contained +syn match  rubyRegexpEscape	"\\[].*?+^$|\\/(){}[]" contained +syn match  rubyRegexpQuantifier	"[*?+][?+]\="	       contained display +syn match  rubyRegexpQuantifier	"{\d\+\%(,\d*\)\=}?\=" contained display +syn match  rubyRegexpAnchor	"[$^]\|\\[ABbGZz]"     contained display +syn match  rubyRegexpDot	"\."		       contained display +syn match  rubyRegexpSpecial	"|"		       contained display +syn match  rubyRegexpSpecial	"\\[1-9]\d\=\d\@!"     contained display +syn match  rubyRegexpSpecial	"\\k<\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\=>" contained display +syn match  rubyRegexpSpecial	"\\k'\%([a-z_]\w*\|-\=\d\+\)\%([+-]\d\+\)\='" contained display +syn match  rubyRegexpSpecial	"\\g<\%([a-z_]\w*\|-\=\d\+\)>" contained display +syn match  rubyRegexpSpecial	"\\g'\%([a-z_]\w*\|-\=\d\+\)'" contained display + +syn cluster rubyStringSpecial	      contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape +syn cluster rubyExtendedStringSpecial contains=@rubyStringSpecial,rubyNestedParentheses,rubyNestedCurlyBraces,rubyNestedAngleBrackets,rubyNestedSquareBrackets +syn cluster rubyRegexpSpecial	      contains=rubyInterpolation,rubyNoInterpolation,rubyStringEscape,rubyRegexpSpecial,rubyRegexpEscape,rubyRegexpBrackets,rubyRegexpCharClass,rubyRegexpDot,rubyRegexpQuantifier,rubyRegexpAnchor,rubyRegexpParens,rubyRegexpComment + +" Numbers and ASCII Codes +syn match rubyASCIICode	"\%(\w\|[]})\"'/]\)\@<!\%(?\%(\\M-\\C-\|\\C-\\M-\|\\M-\\c\|\\c\\M-\|\\c\|\\C-\|\\M-\)\=\%(\\\o\{1,3}\|\\x\x\{1,2}\|\\\=\S\)\)" +syn match rubyInteger	"\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[xX]\x\+\%(_\x\+\)*\>"								display +syn match rubyInteger	"\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0[dD]\)\=\%(0\|[1-9]\d*\%(_\d\+\)*\)\>"						display +syn match rubyInteger	"\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[oO]\=\o\+\%(_\o\+\)*\>"								display +syn match rubyInteger	"\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<0[bB][01]\+\%(_[01]\+\)*\>"								display +syn match rubyFloat	"\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\.\d\+\%(_\d\+\)*\>"					display +syn match rubyFloat	"\%(\%(\w\|[]})\"']\s*\)\@<!-\)\=\<\%(0\|[1-9]\d*\%(_\d\+\)*\)\%(\.\d\+\%(_\d\+\)*\)\=\%([eE][-+]\=\d\+\%(_\d\+\)*\)\>"	display + +" Identifiers +syn match rubyLocalVariableOrMethod "\<[_[:lower:]][_[:alnum:]]*[?!=]\=" contains=NONE display transparent +syn match rubyBlockArgument	    "&[_[:lower:]][_[:alnum:]]"		 contains=NONE display transparent + +syn match  rubyConstant		"\%(\%(^\|[^.]\)\.\s*\)\@<!\<\u\%(\w\|[^\x00-\x7F]\)*\>\%(\s*(\)\@!" +syn match  rubyClassVariable	"@@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" display +syn match  rubyInstanceVariable "@\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*"  display +syn match  rubyGlobalVariable	"$\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\|-.\)" +syn match  rubySymbol		"[]})\"':]\@<!:\%(\^\|\~\|<<\|<=>\|<=\|<\|===\|[=!]=\|[=!]\~\|!\|>>\|>=\|>\||\|-@\|-\|/\|\[]=\|\[]\|\*\*\|\*\|&\|%\|+@\|+\|`\)" +syn match  rubySymbol		"[]})\"':]\@<!:\$\%(-.\|[`~<=>_,;:!?/.'"@$*\&+0]\)" +syn match  rubySymbol		"[]})\"':]\@<!:\%(\$\|@@\=\)\=\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" +syn match  rubySymbol		"[]})\"':]\@<!:\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\%([?!=]>\@!\)\=" +syn match  rubySymbol		"\%([{(,]\_s*\)\@<=\l\w*[!?]\=::\@!"he=e-1 +syn match  rubySymbol		"[]})\"':]\@<!\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:\s\@="he=e-1 +syn match  rubySymbol		"\%([{(,]\_s*\)\@<=[[:space:],{]\l\w*[!?]\=::\@!"hs=s+1,he=e-1 +syn match  rubySymbol		"[[:space:],{(]\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*[!?]\=:\s\@="hs=s+1,he=e-1 +syn region rubySymbol		start="[]})\"':]\@<!:'"  end="'"  skip="\\\\\|\\'"  contains=rubyQuoteEscape fold +syn region rubySymbol		start="[]})\"':]\@<!:\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial fold + +syn match  rubyBlockParameter	  "\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*" contained +syn region rubyBlockParameterList start="\%(\%(\<do\>\|{\)\s*\)\@<=|" end="|" oneline display contains=rubyBlockParameter + +syn match rubyInvalidVariable	 "$[^ A-Za-z_-]" +syn match rubyPredefinedVariable #$[!$&"'*+,./0:;<=>?@\`~]# +syn match rubyPredefinedVariable "$\d\+"										   display +syn match rubyPredefinedVariable "$_\>"											   display +syn match rubyPredefinedVariable "$-[0FIKadilpvw]\>"									   display +syn match rubyPredefinedVariable "$\%(deferr\|defout\|stderr\|stdin\|stdout\)\>"					   display +syn match rubyPredefinedVariable "$\%(DEBUG\|FILENAME\|KCODE\|LOADED_FEATURES\|LOAD_PATH\|PROGRAM_NAME\|SAFE\|VERBOSE\)\>" display +syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(ARGF\|ARGV\|ENV\|DATA\|FALSE\|NIL\|STDERR\|STDIN\|STDOUT\|TOPLEVEL_BINDING\|TRUE\)\>\%(\s*(\)\@!" +syn match rubyPredefinedConstant "\%(\%(^\|[^.]\)\.\s*\)\@<!\<\%(RUBY_\%(VERSION\|RELEASE_DATE\|PLATFORM\|PATCHLEVEL\|REVISION\|DESCRIPTION\|COPYRIGHT\|ENGINE\)\)\>\%(\s*(\)\@!" + +" Normal Regular Expression +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\%(^\|\<\%(and\|or\|while\|until\|unless\|if\|elsif\|when\|not\|then\|else\)\|[;\~=!|&(,[<>?:*+-]\)\s*\)\@<=/" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="\%(\h\k*\s\+\)\@<=/[ \t=]\@!" end="/[iomxneus]*" skip="\\\\\|\\/" contains=@rubyRegexpSpecial fold + +" Generalized Regular Expression +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\z([~`!@#$%^&*_\-+=|\:;"',.? /]\)" end="\z1[iomxneus]*" skip="\\\\\|\\\z1" contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r{"				 end="}[iomxneus]*"   skip="\\\\\|\\}"	 contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r<"				 end=">[iomxneus]*"   skip="\\\\\|\\>"	 contains=@rubyRegexpSpecial,rubyNestedAngleBrackets,rubyDelimEscape fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r\["				 end="\][iomxneus]*"  skip="\\\\\|\\\]"	 contains=@rubyRegexpSpecial fold +syn region rubyRegexp matchgroup=rubyRegexpDelimiter start="%r("				 end=")[iomxneus]*"   skip="\\\\\|\\)"	 contains=@rubyRegexpSpecial fold + +" Normal String and Shell Command Output +syn region rubyString matchgroup=rubyStringDelimiter start="\"" end="\"" skip="\\\\\|\\\"" contains=@rubyStringSpecial,@Spell fold +syn region rubyString matchgroup=rubyStringDelimiter start="'"	end="'"  skip="\\\\\|\\'"  contains=rubyQuoteEscape,@Spell    fold +syn region rubyString matchgroup=rubyStringDelimiter start="`"	end="`"  skip="\\\\\|\\`"  contains=@rubyStringSpecial fold + +" Generalized Single Quoted String, Symbol and Array of Strings +syn region rubyString matchgroup=rubyStringDelimiter start="%[qwi]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[qwi]{"				   end="}"   skip="\\\\\|\\}"	fold contains=rubyNestedCurlyBraces,rubyDelimEscape +syn region rubyString matchgroup=rubyStringDelimiter start="%[qwi]<"				   end=">"   skip="\\\\\|\\>"	fold contains=rubyNestedAngleBrackets,rubyDelimEscape +syn region rubyString matchgroup=rubyStringDelimiter start="%[qwi]\["				   end="\]"  skip="\\\\\|\\\]"	fold contains=rubyNestedSquareBrackets,rubyDelimEscape +syn region rubyString matchgroup=rubyStringDelimiter start="%[qwi]("				   end=")"   skip="\\\\\|\\)"	fold contains=rubyNestedParentheses,rubyDelimEscape +syn region rubyString matchgroup=rubyStringDelimiter start="%q "				   end=" "   skip="\\\\\|\\)"	fold +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\z([~`!@#$%^&*_\-+=|\:;"',.? /]\)"   end="\z1" skip="\\\\\|\\\z1" fold +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s{"				   end="}"   skip="\\\\\|\\}"	fold contains=rubyNestedCurlyBraces,rubyDelimEscape +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s<"				   end=">"   skip="\\\\\|\\>"	fold contains=rubyNestedAngleBrackets,rubyDelimEscape +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s\["				   end="\]"  skip="\\\\\|\\\]"	fold contains=rubyNestedSquareBrackets,rubyDelimEscape +syn region rubySymbol matchgroup=rubySymbolDelimiter start="%s("				   end=")"   skip="\\\\\|\\)"	fold contains=rubyNestedParentheses,rubyDelimEscape + +" Generalized Double Quoted String and Array of Strings and Shell Command Output +" Note: %= is not matched here as the beginning of a double quoted string +syn region rubyString matchgroup=rubyStringDelimiter start="%\z([~`!@#$%^&*_\-+|\:;"',.?/]\)"	    end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[QWIx]\z([~`!@#$%^&*_\-+=|\:;"',.?/]\)" end="\z1" skip="\\\\\|\\\z1" contains=@rubyStringSpecial fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[QWIx]\={"				    end="}"   skip="\\\\\|\\}"	 contains=@rubyStringSpecial,rubyNestedCurlyBraces,rubyDelimEscape    fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[QWIx]\=<"				    end=">"   skip="\\\\\|\\>"	 contains=@rubyStringSpecial,rubyNestedAngleBrackets,rubyDelimEscape  fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[QWIx]\=\["				    end="\]"  skip="\\\\\|\\\]"	 contains=@rubyStringSpecial,rubyNestedSquareBrackets,rubyDelimEscape fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[QWIx]\=("				    end=")"   skip="\\\\\|\\)"	 contains=@rubyStringSpecial,rubyNestedParentheses,rubyDelimEscape    fold +syn region rubyString matchgroup=rubyStringDelimiter start="%[Qx] "				    end=" "   skip="\\\\\|\\)"   contains=@rubyStringSpecial fold + +" Here Document +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs\%(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)+	 end=+$+ oneline contains=ALLBUT,@rubyNotTop +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs"\%([^"]*\)"+ end=+$+ oneline contains=ALLBUT,@rubyNotTop +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs'\%([^']*\)'+ end=+$+ oneline contains=ALLBUT,@rubyNotTop +syn region rubyHeredocStart matchgroup=rubyStringDelimiter start=+\%(\%(class\s*\|\%([]})"'.]\|::\)\)\_s*\|\w\)\@<!<<-\=\zs`\%([^`]*\)`+ end=+$+ oneline contains=ALLBUT,@rubyNotTop + +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2	matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<"\z([^"]*\)"\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2	matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<'\z([^']*\)'\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2	matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc			fold keepend +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]})"'.]\)\s\|\w\)\@<!<<`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+2	matchgroup=rubyStringDelimiter end=+^\z1$+ contains=rubyHeredocStart,rubyHeredoc,@rubyStringSpecial fold keepend + +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-\z(\%(\h\|[^\x00-\x7F]\)\%(\w\|[^\x00-\x7F]\)*\)\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3    matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-"\z([^"]*\)"\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3  matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-'\z([^']*\)'\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3  matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart		     fold keepend +syn region rubyString start=+\%(\%(class\|::\)\_s*\|\%([]}).]\)\s\|\w\)\@<!<<-`\z([^`]*\)`\ze\%(.*<<-\=['`"]\=\h\)\@!+hs=s+3  matchgroup=rubyStringDelimiter end=+^\s*\zs\z1$+ contains=rubyHeredocStart,@rubyStringSpecial fold keepend + +if exists('main_syntax') && main_syntax == 'eruby' +  let b:ruby_no_expensive = 1 +end + +syn match  rubyAliasDeclaration    "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable nextgroup=rubyAliasDeclaration2 skipwhite +syn match  rubyAliasDeclaration2   "[^[:space:];#.()]\+" contained contains=rubySymbol,rubyGlobalVariable,rubyPredefinedVariable +syn match  rubyMethodDeclaration   "[^[:space:];#(]\+"	 contained contains=rubyConstant,rubyBoolean,rubyPseudoVariable,rubyInstanceVariable,rubyClassVariable,rubyGlobalVariable +syn match  rubyClassDeclaration    "[^[:space:];#<]\+"	 contained contains=rubyConstant,rubyOperator +syn match  rubyModuleDeclaration   "[^[:space:];#<]\+"	 contained contains=rubyConstant,rubyOperator +syn match  rubyFunction "\<[_[:alpha:]][_[:alnum:]]*[?!=]\=[[:alnum:]_.:?!=]\@!" contained containedin=rubyMethodDeclaration +syn match  rubyFunction "\%(\s\|^\)\@<=[_[:alpha:]][_[:alnum:]]*[?!=]\=\%(\s\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2 +syn match  rubyFunction "\%([[:space:].]\|^\)\@<=\%(\[\]=\=\|\*\*\|[+-]@\=\|[*/%|&^~]\|<<\|>>\|[<>]=\=\|<=>\|===\|[=!]=\|[=!]\~\|!\|`\)\%([[:space:];#(]\|$\)\@=" contained containedin=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration + +syn cluster rubyDeclaration contains=rubyAliasDeclaration,rubyAliasDeclaration2,rubyMethodDeclaration,rubyModuleDeclaration,rubyClassDeclaration,rubyFunction,rubyBlockParameter + +" Keywords +" Note: the following keywords have already been defined: +" begin case class def do end for if module unless until while +syn match   rubyControl	       "\<\%(and\|break\|in\|next\|not\|or\|redo\|rescue\|retry\|return\)\>[?!]\@!" +syn match   rubyOperator       "\<defined?" display +syn match   rubyKeyword	       "\<\%(super\|yield\)\>[?!]\@!" +syn match   rubyBoolean	       "\<\%(true\|false\)\>[?!]\@!" +syn match   rubyPseudoVariable "\<\%(nil\|self\|__ENCODING__\|__FILE__\|__LINE__\|__callee__\|__method__\)\>[?!]\@!" " TODO: reorganise +syn match   rubyBeginEnd       "\<\%(BEGIN\|END\)\>[?!]\@!" + +" Expensive Mode - match 'end' with the appropriate opening keyword for syntax +" based folding and special highlighting of module/class/method definitions +if !exists("b:ruby_no_expensive") && !exists("ruby_no_expensive") +  syn match  rubyDefine "\<alias\>"  nextgroup=rubyAliasDeclaration  skipwhite skipnl +  syn match  rubyDefine "\<def\>"    nextgroup=rubyMethodDeclaration skipwhite skipnl +  syn match  rubyDefine "\<undef\>"  nextgroup=rubyFunction	     skipwhite skipnl +  syn match  rubyClass	"\<class\>"  nextgroup=rubyClassDeclaration  skipwhite skipnl +  syn match  rubyModule "\<module\>" nextgroup=rubyModuleDeclaration skipwhite skipnl + +  syn region rubyMethodBlock start="\<def\>"	matchgroup=rubyDefine end="\%(\<def\_s\+\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold +  syn region rubyBlock	     start="\<class\>"	matchgroup=rubyClass  end="\<end\>"		       contains=ALLBUT,@rubyNotTop fold +  syn region rubyBlock	     start="\<module\>" matchgroup=rubyModule end="\<end\>"		       contains=ALLBUT,@rubyNotTop fold + +  " modifiers +  syn match rubyConditionalModifier "\<\%(if\|unless\)\>"    display +  syn match rubyRepeatModifier	     "\<\%(while\|until\)\>" display + +  syn region rubyDoBlock      matchgroup=rubyControl start="\<do\>" end="\<end\>"                 contains=ALLBUT,@rubyNotTop fold +  " curly bracket block or hash literal +  syn region rubyCurlyBlock	matchgroup=rubyCurlyBlockDelimiter  start="{" end="}"				contains=ALLBUT,@rubyNotTop fold +  syn region rubyArrayLiteral	matchgroup=rubyArrayDelimiter	    start="\%(\w\|[\]})]\)\@<!\[" end="]"	contains=ALLBUT,@rubyNotTop fold + +  " statements without 'do' +  syn region rubyBlockExpression       matchgroup=rubyControl	  start="\<begin\>" end="\<end\>" contains=ALLBUT,@rubyNotTop fold +  syn region rubyCaseExpression	       matchgroup=rubyConditional start="\<case\>"  end="\<end\>" contains=ALLBUT,@rubyNotTop fold +  syn region rubyConditionalExpression matchgroup=rubyConditional start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+=-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![?!]\)\s*\)\@<=\%(if\|unless\)\>" end="\%(\%(\%(\.\@<!\.\)\|::\)\s*\)\@<!\<end\>" contains=ALLBUT,@rubyNotTop fold + +  syn match rubyConditional "\<\%(then\|else\|when\)\>[?!]\@!"	contained containedin=rubyCaseExpression +  syn match rubyConditional "\<\%(then\|else\|elsif\)\>[?!]\@!" contained containedin=rubyConditionalExpression + +  syn match rubyExceptional	  "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyBlockExpression +  syn match rubyMethodExceptional "\<\%(\%(\%(;\|^\)\s*\)\@<=rescue\|else\|ensure\)\>[?!]\@!" contained containedin=rubyMethodBlock + +  " statements with optional 'do' +  syn region rubyOptionalDoLine   matchgroup=rubyRepeat start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyOptionalDo end="\%(\<do\>\)" end="\ze\%(;\|$\)" oneline contains=ALLBUT,@rubyNotTop +  syn region rubyRepeatExpression start="\<for\>[?!]\@!" start="\%(\%(^\|\.\.\.\=\|[{:,;([<>~\*/%&^|+-]\|\%(\<[_[:lower:]][_[:alnum:]]*\)\@<![!=?]\)\s*\)\@<=\<\%(until\|while\)\>" matchgroup=rubyRepeat end="\<end\>" contains=ALLBUT,@rubyNotTop nextgroup=rubyOptionalDoLine fold + +  if !exists("ruby_minlines") +    let ruby_minlines = 500 +  endif +  exec "syn sync minlines=" . ruby_minlines + +else +  syn match rubyControl "\<def\>[?!]\@!"    nextgroup=rubyMethodDeclaration skipwhite skipnl +  syn match rubyControl "\<class\>[?!]\@!"  nextgroup=rubyClassDeclaration  skipwhite skipnl +  syn match rubyControl "\<module\>[?!]\@!" nextgroup=rubyModuleDeclaration skipwhite skipnl +  syn match rubyControl "\<\%(case\|begin\|do\|for\|if\|unless\|while\|until\|else\|elsif\|ensure\|then\|when\|end\)\>[?!]\@!" +  syn match rubyKeyword "\<\%(alias\|undef\)\>[?!]\@!" +endif + +" Special Methods +if !exists("ruby_no_special_methods") +  syn keyword rubyAccess    public protected private public_class_method private_class_method public_constant private_constant module_function +  " attr is a common variable name +  syn match   rubyAttribute "\%(\%(^\|;\)\s*\)\@<=attr\>\(\s*[.=]\)\@!" +  syn keyword rubyAttribute attr_accessor attr_reader attr_writer +  syn match   rubyControl   "\<\%(exit!\|\%(abort\|at_exit\|exit\|fork\|loop\|trap\)\>[?!]\@!\)" +  syn keyword rubyEval	    eval class_eval instance_eval module_eval +  syn keyword rubyException raise fail catch throw +  " false positive with 'include?' +  syn match   rubyInclude   "\<include\>[?!]\@!" +  syn keyword rubyInclude   autoload extend load prepend require require_relative +  syn keyword rubyKeyword   callcc caller lambda proc +endif + +" Comments and Documentation +syn match   rubySharpBang "\%^#!.*" display +syn keyword rubyTodo	  FIXME NOTE TODO OPTIMIZE XXX todo contained +syn match   rubyComment   "#.*" contains=rubySharpBang,rubySpaceError,rubyTodo,@Spell +if !exists("ruby_no_comment_fold") +  syn region rubyMultilineComment start="\%(\%(^\s*#.*\n\)\@<!\%(^\s*#.*\n\)\)\%(\(^\s*#.*\n\)\{1,}\)\@=" end="\%(^\s*#.*\n\)\@<=\%(^\s*#.*\n\)\%(^\s*#\)\@!" contains=rubyComment transparent fold keepend +  syn region rubyDocumentation	  start="^=begin\ze\%(\s.*\)\=$" end="^=end\%(\s.*\)\=$" contains=rubySpaceError,rubyTodo,@Spell fold +else +  syn region rubyDocumentation	  start="^=begin\s*$" end="^=end\s*$" contains=rubySpaceError,rubyTodo,@Spell +endif + +" Note: this is a hack to prevent 'keywords' being highlighted as such when called as methods with an explicit receiver +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(alias\|and\|begin\|break\|case\|class\|def\|defined\|do\|else\)\>"		  transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(elsif\|end\|ensure\|false\|for\|if\|in\|module\|next\|nil\)\>"		  transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(not\|or\|redo\|rescue\|retry\|return\|self\|super\|then\|true\)\>"		  transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(undef\|unless\|until\|when\|while\|yield\|BEGIN\|END\|__FILE__\|__LINE__\)\>" transparent contains=NONE + +syn match rubyKeywordAsMethod "\<\%(alias\|begin\|case\|class\|def\|do\|end\)[?!]" transparent contains=NONE +syn match rubyKeywordAsMethod "\<\%(if\|module\|undef\|unless\|until\|while\)[?!]" transparent contains=NONE + +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(abort\|at_exit\|attr\|attr_accessor\|attr_reader\)\>"	transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(attr_writer\|autoload\|callcc\|catch\|caller\)\>"		transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(eval\|class_eval\|instance_eval\|module_eval\|exit\)\>"	transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(extend\|fail\|fork\|include\|lambda\)\>"			transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(load\|loop\|prepend\|private\|proc\|protected\)\>"		transparent contains=NONE +syn match rubyKeywordAsMethod "\%(\%(\.\@<!\.\)\|::\)\_s*\%(public\|require\|require_relative\|raise\|throw\|trap\)\>"	transparent contains=NONE + +" __END__ Directive +syn region rubyData matchgroup=rubyDataDirective start="^__END__$" end="\%$" fold + +hi def link rubyClass			rubyDefine +hi def link rubyModule			rubyDefine +hi def link rubyMethodExceptional	rubyDefine +hi def link rubyDefine			Define +hi def link rubyFunction		Function +hi def link rubyConditional		Conditional +hi def link rubyConditionalModifier	rubyConditional +hi def link rubyExceptional		rubyConditional +hi def link rubyRepeat			Repeat +hi def link rubyRepeatModifier		rubyRepeat +hi def link rubyOptionalDo		rubyRepeat +hi def link rubyControl			Statement +hi def link rubyInclude			Include +hi def link rubyInteger			Number +hi def link rubyASCIICode		Character +hi def link rubyFloat			Float +hi def link rubyBoolean			Boolean +hi def link rubyException		Exception +if !exists("ruby_no_identifiers") +  hi def link rubyIdentifier		Identifier +else +  hi def link rubyIdentifier		NONE +endif +hi def link rubyClassVariable		rubyIdentifier +hi def link rubyConstant		Type +hi def link rubyGlobalVariable		rubyIdentifier +hi def link rubyBlockParameter		rubyIdentifier +hi def link rubyInstanceVariable	rubyIdentifier +hi def link rubyPredefinedIdentifier	rubyIdentifier +hi def link rubyPredefinedConstant	rubyPredefinedIdentifier +hi def link rubyPredefinedVariable	rubyPredefinedIdentifier +hi def link rubySymbol			Constant +hi def link rubyKeyword			Keyword +hi def link rubyOperator		Operator +hi def link rubyBeginEnd		Statement +hi def link rubyAccess			Statement +hi def link rubyAttribute		Statement +hi def link rubyEval			Statement +hi def link rubyPseudoVariable		Constant + +hi def link rubyComment			Comment +hi def link rubyData			Comment +hi def link rubyDataDirective		Delimiter +hi def link rubyDocumentation		Comment +hi def link rubyTodo			Todo + +hi def link rubyQuoteEscape		rubyStringEscape +hi def link rubyStringEscape		Special +hi def link rubyInterpolationDelimiter	Delimiter +hi def link rubyNoInterpolation		rubyString +hi def link rubySharpBang		PreProc +hi def link rubyRegexpDelimiter		rubyStringDelimiter +hi def link rubySymbolDelimiter		rubyStringDelimiter +hi def link rubyStringDelimiter		Delimiter +hi def link rubyHeredoc			rubyString +hi def link rubyString			String +hi def link rubyRegexpEscape		rubyRegexpSpecial +hi def link rubyRegexpQuantifier	rubyRegexpSpecial +hi def link rubyRegexpAnchor		rubyRegexpSpecial +hi def link rubyRegexpDot		rubyRegexpCharClass +hi def link rubyRegexpCharClass		rubyRegexpSpecial +hi def link rubyRegexpSpecial		Special +hi def link rubyRegexpComment		Comment +hi def link rubyRegexp			rubyString + +hi def link rubyInvalidVariable		Error +hi def link rubyError			Error +hi def link rubySpaceError		rubyError + +let b:current_syntax = "ruby" + +" vim: nowrap sw=2 sts=2 ts=8 noet: diff --git a/syntax/sass.vim b/syntax/sass.vim new file mode 100644 index 00000000..d8f6b781 --- /dev/null +++ b/syntax/sass.vim @@ -0,0 +1,100 @@ +" Vim syntax file +" Language:	Sass +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Filenames:	*.sass +" Last Change:	2010 Aug 09 + +if exists("b:current_syntax") +  finish +endif + +runtime! syntax/css.vim + +syn case ignore + +syn cluster sassCssProperties contains=cssFontProp,cssFontDescriptorProp,cssColorProp,cssTextProp,cssBoxProp,cssGeneratedContentProp,cssPagingProp,cssUIProp,cssRenderProp,cssAuralProp,cssTableProp +syn cluster sassCssAttributes contains=css.*Attr,sassEndOfLineComment,scssComment,cssValue.*,cssColor,cssURL,sassDefault,cssImportant,cssError,cssStringQ,cssStringQQ,cssFunction,cssUnicodeEscape,cssRenderProp + +syn region sassDefinition matchgroup=cssBraces start="{" end="}" contains=TOP + +syn match sassProperty "\%([{};]\s*\|^\)\@<=\%([[:alnum:]-]\|#{[^{}]*}\)\+\s*:" contains=css.*Prop skipwhite nextgroup=sassCssAttribute contained containedin=sassDefinition +syn match sassProperty "^\s*\zs\s\%(\%([[:alnum:]-]\|#{[^{}]*}\)\+\s*:\|:[[:alnum:]-]\+\)"hs=s+1 contains=css.*Prop skipwhite nextgroup=sassCssAttribute +syn match sassProperty "^\s*\zs\s\%(:\=[[:alnum:]-]\+\s*=\)"hs=s+1 contains=css.*Prop skipwhite nextgroup=sassCssAttribute +syn match sassCssAttribute +\%("\%([^"]\|\\"\)*"\|'\%([^']\|\\'\)*'\|#{[^{}]*}\|[^{};]\)*+ contained contains=@sassCssAttributes,sassVariable,sassFunction,sassInterpolation +syn match sassDefault "!default\>" contained +syn match sassVariable "!\%(important\>\|default\>\)\@![[:alnum:]_-]\+" +syn match sassVariable "$[[:alnum:]_-]\+" +syn match sassVariableAssignment "\%([!$][[:alnum:]_-]\+\s*\)\@<=\%(||\)\==" nextgroup=sassCssAttribute skipwhite +syn match sassVariableAssignment "\%([!$][[:alnum:]_-]\+\s*\)\@<=:" nextgroup=sassCssAttribute skipwhite + +syn match sassFunction "\<\%(rgb\|rgba\|red\|green\|blue\|mix\)\>(\@=" contained +syn match sassFunction "\<\%(hsl\|hsla\|hue\|saturation\|lightness\|adjust-hue\|lighten\|darken\|saturate\|desaturate\|grayscale\|complement\)\>(\@=" contained +syn match sassFunction "\<\%(alpha\|opacity\|rgba\|opacify\|fade-in\|transparentize\|fade-out\)\>(\@=" contained +syn match sassFunction "\<\%(unquote\|quote\)\>(\@=" contained +syn match sassFunction "\<\%(percentage\|round\|ceil\|floor\|abs\)\>(\@=" contained +syn match sassFunction "\<\%(type-of\|unit\|unitless\|comparable\)\>(\@=" contained + +syn region sassInterpolation matchgroup=sassInterpolationDelimiter start="#{" end="}" contains=@sassCssAttributes,sassVariable,sassFunction containedin=cssStringQ,cssStringQQ,cssPseudoClass,sassProperty + +syn match sassMixinName "[[:alnum:]_-]\+" contained nextgroup=sassCssAttribute +syn match sassMixin  "^="               nextgroup=sassMixinName skipwhite +syn match sassMixin  "\%([{};]\s*\|^\s*\)\@<=@mixin"   nextgroup=sassMixinName skipwhite +syn match sassMixing "^\s\+\zs+"        nextgroup=sassMixinName +syn match sassMixing "\%([{};]\s*\|^\s*\)\@<=@include" nextgroup=sassMixinName skipwhite +syn match sassExtend "\%([{};]\s*\|^\s*\)\@<=@extend" +syn match sassPlaceholder "\%([{};]\s*\|^\s*\)\@<=%"   nextgroup=sassMixinName skipwhite + +syn match sassFunctionName "[[:alnum:]_-]\+" contained nextgroup=sassCssAttribute +syn match sassFunctionDecl "\%([{};]\s*\|^\s*\)\@<=@function"   nextgroup=sassFunctionName skipwhite +syn match sassReturn "\%([{};]\s*\|^\s*\)\@<=@return" + +syn match sassEscape     "^\s*\zs\\" +syn match sassIdChar     "#[[:alnum:]_-]\@=" nextgroup=sassId +syn match sassId         "[[:alnum:]_-]\+" contained +syn match sassClassChar  "\.[[:alnum:]_-]\@=" nextgroup=sassClass +syn match sassClass      "[[:alnum:]_-]\+" contained +syn match sassAmpersand  "&" + +" TODO: Attribute namespaces +" TODO: Arithmetic (including strings and concatenation) + +syn region sassInclude start="@import" end=";\|$" contains=scssComment,cssStringQ,cssStringQQ,cssURL,cssUnicodeEscape,cssMediaType +syn region sassDebugLine end=";\|$" matchgroup=sassDebug start="@debug\>" contains=@sassCssAttributes,sassVariable,sassFunction +syn region sassWarnLine end=";\|$" matchgroup=sassWarn start="@warn\>" contains=@sassCssAttributes,sassVariable,sassFunction +syn region sassControlLine matchgroup=sassControl start="@\%(if\|else\%(\s\+if\)\=\|while\|for\|each\)\>" end="[{};]\@=\|$" contains=sassFor,@sassCssAttributes,sassVariable,sassFunction +syn keyword sassFor from to through in contained + +syn keyword sassTodo        FIXME NOTE TODO OPTIMIZE XXX contained +syn region  sassComment     start="^\z(\s*\)//"  end="^\%(\z1 \)\@!" contains=sassTodo,@Spell +syn region  sassCssComment  start="^\z(\s*\)/\*" end="^\%(\z1 \)\@!" contains=sassTodo,@Spell +syn match   sassEndOfLineComment "//.*" contains=sassComment,sassTodo,@Spell + +hi def link sassEndOfLineComment        sassComment +hi def link sassCssComment              sassComment +hi def link sassComment                 Comment +hi def link sassDefault                 cssImportant +hi def link sassVariable                Identifier +hi def link sassFunction                Function +hi def link sassMixing                  PreProc +hi def link sassMixin                   PreProc +hi def link sassPlaceholder             PreProc +hi def link sassExtend                  PreProc +hi def link sassFunctionDecl            PreProc +hi def link sassReturn                  PreProc +hi def link sassTodo                    Todo +hi def link sassInclude                 Include +hi def link sassDebug                   sassControl +hi def link sassWarn                    sassControl +hi def link sassControl                 PreProc +hi def link sassFor                     PreProc +hi def link sassEscape                  Special +hi def link sassIdChar                  Special +hi def link sassClassChar               Special +hi def link sassInterpolationDelimiter  Delimiter +hi def link sassAmpersand               Character +hi def link sassId                      Identifier +hi def link sassClass                   Type + +let b:current_syntax = "sass" + +" vim:set sw=2: diff --git a/syntax/scss.vim b/syntax/scss.vim new file mode 100644 index 00000000..6fb96915 --- /dev/null +++ b/syntax/scss.vim @@ -0,0 +1,20 @@ +" Vim syntax file +" Language:	SCSS +" Maintainer:	Tim Pope <vimNOSPAM@tpope.org> +" Filenames:	*.scss +" Last Change:	2010 Jul 26 + +if exists("b:current_syntax") +  finish +endif + +runtime! syntax/sass.vim + +syn match scssComment "//.*" contains=sassTodo,@Spell +syn region scssComment start="/\*" end="\*/" contains=sassTodo,@Spell + +hi def link scssComment sassComment + +let b:current_syntax = "scss" + +" vim:set sw=2: diff --git a/syntax/slim.vim b/syntax/slim.vim new file mode 100644 index 00000000..c4371b10 --- /dev/null +++ b/syntax/slim.vim @@ -0,0 +1,98 @@ +" Vim syntax file +" Language: Slim +" Maintainer: Andrew Stone <andy@stonean.com> +" Version:  1 +" Last Change:  2010 Sep 25 +" TODO: Feedback is welcomed. + +" Quit when a syntax file is already loaded. +if exists("b:current_syntax") +  finish +endif + +if !exists("main_syntax") +  let main_syntax = 'slim' +endif + +" Allows a per line syntax evaluation. +let b:ruby_no_expensive = 1 + +" Include Ruby syntax highlighting +syn include @slimRubyTop syntax/ruby.vim +unlet! b:current_syntax +" Include Haml syntax highlighting +syn include @slimHaml syntax/haml.vim +unlet! b:current_syntax + +syn match slimBegin  "^\s*\(&[^= ]\)\@!" nextgroup=slimTag,slimClassChar,slimIdChar,slimRuby + +syn region  rubyCurlyBlock start="{" end="}" contains=@slimRubyTop contained +syn cluster slimRubyTop    add=rubyCurlyBlock + +syn cluster slimComponent contains=slimClassChar,slimIdChar,slimWrappedAttrs,slimRuby,slimAttr,slimInlineTagChar + +syn keyword slimDocType        contained html 5 1.1 strict frameset mobile basic transitional +syn match   slimDocTypeKeyword "^\s*\(doctype\)\s\+" nextgroup=slimDocType + +syn keyword slimTodo        FIXME TODO NOTE OPTIMIZE XXX contained + +syn match slimTag           "\w\+"         contained contains=htmlTagName nextgroup=@slimComponent +syn match slimIdChar        "#{\@!"        contained nextgroup=slimId +syn match slimId            "\%(\w\|-\)\+" contained nextgroup=@slimComponent +syn match slimClassChar     "\."           contained nextgroup=slimClass +syn match slimClass         "\%(\w\|-\)\+" contained nextgroup=@slimComponent +syn match slimInlineTagChar "\s*:\s*"      contained nextgroup=slimTag,slimClassChar,slimIdChar + +syn region slimWrappedAttrs matchgroup=slimWrappedAttrsDelimiter start="\s*{\s*" skip="}\s*\""  end="\s*}\s*"  contained contains=slimAttr nextgroup=slimRuby +syn region slimWrappedAttrs matchgroup=slimWrappedAttrsDelimiter start="\s*\[\s*" end="\s*\]\s*" contained contains=slimAttr nextgroup=slimRuby +syn region slimWrappedAttrs matchgroup=slimWrappedAttrsDelimiter start="\s*(\s*"  end="\s*)\s*"  contained contains=slimAttr nextgroup=slimRuby + +syn match slimAttr "\s*\%(\w\|-\)\+\s*" contained contains=htmlArg nextgroup=slimAttrAssignment +syn match slimAttrAssignment "\s*=\s*" contained nextgroup=slimWrappedAttrValue,slimAttrString + +syn region slimWrappedAttrValue matchgroup=slimWrappedAttrValueDelimiter start="{" end="}" contained contains=slimAttrString,@slimRubyTop nextgroup=slimAttr,slimRuby,slimInlineTagChar +syn region slimWrappedAttrValue matchgroup=slimWrappedAttrValueDelimiter start="\[" end="\]" contained contains=slimAttrString,@slimRubyTop nextgroup=slimAttr,slimRuby,slimInlineTagChar +syn region slimWrappedAttrValue matchgroup=slimWrappedAttrValueDelimiter start="(" end=")" contained contains=slimAttrString,@slimRubyTop nextgroup=slimAttr,slimRuby,slimInlineTagChar + +syn region slimAttrString start=+\s*"+ skip=+\%(\\\\\)*\\"+ end=+"\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr,slimRuby,slimInlineTagChar +syn region slimAttrString start=+\s*'+ skip=+\%(\\\\\)*\\"+ end=+'\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr,slimRuby,slimInlineTagChar + +syn region slimInnerAttrString start=+\s*"+ skip=+\%(\\\\\)*\\"+ end=+"\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr +syn region slimInnerAttrString start=+\s*'+ skip=+\%(\\\\\)*\\"+ end=+'\s*+ contained contains=slimInterpolation,slimInterpolationEscape nextgroup=slimAttr + +syn region slimInterpolation matchgroup=slimInterpolationDelimiter start="#{" end="}" contains=@hamlRubyTop containedin=javascriptStringS,javascriptStringD,slimWrappedAttrs +syn match  slimInterpolationEscape "\\\@<!\%(\\\\\)*\\\%(\\\ze#{\|#\ze{\)" + +syn region slimRuby matchgroup=slimRubyOutputChar start="\s*[=]\==[']\=" skip=",\s*$" end="$" contained contains=@slimRubyTop keepend +syn region slimRuby matchgroup=slimRubyChar       start="\s*-"           skip=",\s*$" end="$" contained contains=@slimRubyTop keepend + +syn match slimComment /^\(\s*\)[/].*\(\n\1\s.*\)*/ contains=slimTodo +syn match slimText    /^\(\s*\)[`|'].*\(\n\1\s.*\)*/ + +syn match slimFilter /\s*\w\+:\s*/                            contained +syn match slimHaml   /^\(\s*\)\<haml:\>.*\(\n\1\s.*\)*/       contains=@slimHaml,slimFilter + +syn match slimIEConditional "\%(^\s*/\)\@<=\[\s*if\>[^]]*]" contained containedin=slimComment + +hi def link slimAttrString                String +hi def link slimBegin                     String +hi def link slimClass                     Type +hi def link slimClassChar                 Type +hi def link slimComment                   Comment +hi def link slimDocType                   Identifier +hi def link slimDocTypeKeyword            Keyword +hi def link slimFilter                    Keyword +hi def link slimIEConditional             SpecialComment +hi def link slimId                        Identifier +hi def link slimIdChar                    Identifier +hi def link slimInnerAttrString           String +hi def link slimInterpolationDelimiter    Delimiter +hi def link slimRubyChar                  Special +hi def link slimRubyOutputChar            Special +hi def link slimText                      String +hi def link slimTodo                      Todo +hi def link slimWrappedAttrValueDelimiter Delimiter +hi def link slimWrappedAttrsDelimiter     Delimiter +hi def link slimInlineTagChar             Delimiter + +let b:current_syntax = "slim" diff --git a/syntax/stylus.vim b/syntax/stylus.vim new file mode 100644 index 00000000..930e0b9b --- /dev/null +++ b/syntax/stylus.vim @@ -0,0 +1,372 @@ +" Vim syntax file +" Language:	CSS3 +" Maintainer:	Hsiaoming Yang <lepture@me.com> +" URL: http://lepture.me/work/css3/ +" Created:	Dec 14, 2011 +" Modified:	Sep 4, 2012 + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if !exists("main_syntax") +  if version < 600 +    syntax clear +  elseif exists("b:current_syntax") +    finish +  endif +  let main_syntax = 'css' +endif + +syn case ignore +syn region cssString start='"' end='"' contained +syn region cssString start="'" end="'" contained + +" HTML4 tags +syn keyword cssTagName abbr acronym address applet area base a b +syn keyword cssTagName basefont bdo big blockquote body button br +syn keyword cssTagName caption cite code col colgroup dd del +syn keyword cssTagName dfn dir div dl dt em fieldset form frame +syn keyword cssTagName frameset h1 h2 h3 h4 h5 h6 head hr html img i +syn keyword cssTagName iframe img input ins isindex kbd label legend li +syn keyword cssTagName link map menu meta noframes noscript ol optgroup +syn keyword cssTagName option p param pre q s samp script select +syn keyword cssTagName span strike strong style sub sup tbody td +syn keyword cssTagName textarea tfoot th thead title tr tt ul u var +syn match cssTagName "\*" +syn match cssTagName /\<table\>/ +syn match cssTagName /\<small\>/ +syn match cssTagName /\<center\>/ +" HTML5 tags +syn keyword cssTagName article aside audio bb canvas command datagrid +syn keyword cssTagName datalist details dialog embed figure footer figcaption +syn keyword cssTagName header hgroup keygen mark meter nav output  +syn keyword cssTagName progress time rt rp section time video +syn match cssTagName /\<ruby\>/ +" class select +syn match cssSelector /\.[A-Za-z][A-Za-z0-9_-]\+/ +" id select +syn match cssSelector /#[A-Za-z][A-Za-z0-9_-]\+/ +syn region cssSelector start='\[' end='\]' contains=cssString + +syn region cssDefineBlock start="{" end="}" transparent contains=ALL + +syn keyword cssCommonVal inherit initial auto both normal hidden none medium contained + + +" Comment +syn keyword cssTodo FIXME TODO contained +syn region cssComment start="/\*" end="\*/" contains=cssTodo +syn match cssImportant "!\s*important\>" contained + +syn match cssValueInteger "[-+]\=\d\+" contained +syn match cssValueNumber "[-+]\=\d\+\(\.\d*\)\=" +syn match cssValueLength "[-+]\=\d\+\(\.\d*\)\=\(%\|mm\|cm\|in\|pt\|pc\|em\|ex\|px\|rem\|vh\|vw\|vm\|fr\|gr\)" contained +syn match cssValueAngle "[-+]\=\d\+\(\.\d*\)\=\(deg\|grad\|rad\|turn\)" contained +syn match cssValueTime "+\=\d\+\(\.\d*\)\=\(ms\|s\)" contained +syn match cssValueFrequency "+\=\d\+\(\.\d*\)\=\(Hz\|kHz\)" contained + + +" Properties http://www.w3.org/community/webed/wiki/CSS/Properties +" background http://www.w3.org/TR/css3-background/ +syn match cssBackgroundProp /\(background-\(color\|image\|repeat\|attachment\|position\)\|background\)/ contained +syn match cssBackgroundProp /background-\(origin\|\(repeat\|position\)-[xy]\|clip\|size\)/ contained +syn match cssBackgroundProp /object-\(fit\|position\)/ contained +" http://www.evotech.net/blog/2010/02/css3-properties-values-browser-support/ +syn keyword cssBackgroundVal tb lr rl snap cover contain widthLength heightLength contained +syn match cssBackgroundVal /\(scale-down\|from-image\)/ contained +syn match cssBackgroundVal /repeat-[xy]/ contained +syn match cssBackgroundVal /no-repeat/ contained +syn keyword cssBackgroundVal circle ellipse to at contained +syn match cssBackgroundVal /\(closest\|farthest\)-\(side\|corner\)/ contained + +syn region cssFuncVal start="\(url\|calc\|min\|max\|counter\|cycle(\)" end=")" oneline contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency +syn region cssFuncVal start="\(linear\|radial\|repeating-linear\|repeating-radial\)-gradient(" end=")" oneline contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency,cssVisualProp,cssColorVal + +syn match cssBorderProp /\(border-\(color\|style\|width\|radius\)\|border\)/ contained +syn match cssBorderProp /border-\(image-\(source\|slice\|width\|outset\|repeat\)\|image\)/ contained +syn match cssBorderProp /border-\(\(top\|right\|bottom\|left\)-\(color\|style\|width\)\|\(top\|right\|bottom\|left\)\)/ contained +syn match cssBorderProp /border-\(top\|bottom\)-\(left\|right\)-radius/ contained +syn keyword cssBorderVal dotted dashed solid double groove ridge inset outset contained +syn match cssBorderVal /\<collapse\>/ contained +syn match cssBorderVal /\<separate\>/ contained +syn match cssBorderVal /\<fill\>/ contained + +" Font +syn match cssFontProp /\(font-\(family\|style\|variant\|weight\|size-adjust\|size\|stretch\)\|font\)/ contained +syn match cssFontVal /\(sans-serif\|small-caps\)/ contained +syn match cssFontVal /\<x\{1,2\}-\(large\|small\)\>/ contained +syn keyword cssFontVal cursive fantasy monospace italic oblique serif contained +syn keyword cssFontVal bold bolder lighter larger smaller contained +syn keyword cssFontVal icon narrower wider contained + +" Color +syn match cssColorVal /transparent/ contained +syn match cssColorVal "#[0-9A-Fa-f]\{3\}\>" contained +syn match cssColorVal "#[0-9A-Fa-f]\{6\}\>" contained +syn match cssFuncVal /rgb(\(\d\{1,3\}\s*,\s*\)\{2\}\d\{1,3\})/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency +syn match cssFuncVal /rgba(\(\d\{1,3\}\s*,\s*\)\{3\}\(1\|0\(\.\d\+\)\?\))/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency  +syn match cssFuncVal /hsl(\d\{1,3\}\s*,\s*\(100\|\d\{1,2\}\(\.\d\+\)\?\)%\s*,\s*\(100\|\d\{1,2\}\(\.\d\+\)\?\)%)/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency +syn match cssFuncVal /hsla(\d\{1,3\}\s*,\s*\(\(100\|\d\{1,2\}\(\.\d\+\)\?\)%\s*,\s*\)\{2\}\(1\|0\(\.\d\+\)\?\))/ contained contains=cssString,cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency +syn keyword cssColorVal aliceblue antiquewhite aqua aquamarine azure contained +syn keyword cssColorVal beige bisque black blanchedalmond blue blueviolet brown burlywood contained +syn keyword cssColorVal cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan contained +syn match cssColorVal /dark\(blue\|cyan\|goldenrod\|gray\|green\|grey\|khaki\)/ contained +syn match cssColorVal /dark\(magenta\|olivegreen\|orange\|orchid\|red\|salmon\|seagreen\)/ contained +syn match cssColorVal /darkslate\(blue\|gray\|grey\)/ contained +syn match cssColorVal /dark\(turquoise\|violet\)/ contained +syn keyword cssColorVal deeppink deepskyblue dimgray dimgrey dodgerblue firebrick contained +syn keyword cssColorVal floralwhite forestgreen fuchsia gainsboro ghostwhite gold contained +syn keyword cssColorVal goldenrod gray green greenyellow grey honeydew hotpink contained +syn keyword cssColorVal indianred indigo ivory khaki lavender lavenderblush lawngreen contained +syn keyword cssColorVal lemonchiffon lime limegreen linen magenta maroon contained +syn match cssColorVal /light\(blue\|coral\|cyan\|goldenrodyellow\|gray\|green\)/ contained +syn match cssColorVal /light\(grey\|pink\|salmon\|seagreen\|skyblue\|yellow\)/ contained +syn match cssColorVal /light\(slategray\|slategrey\|steelblue\)/ contained +syn match cssColorVal /medium\(aquamarine\|blue\|orchid\|purple\|seagreen\)/ contained +syn match cssColorVal /medium\(slateblue\|springgreen\|turquoise\|violetred\)/ contained +syn keyword cssColorVal midnightblue mintcream mistyrose moccasin navajowhite contained +syn keyword cssColorVal navy oldlace olive olivedrab orange orangered orchid contained +syn match cssColorVal /pale\(goldenrod\|green\|turquoise\|violetred\)/ contained +syn keyword cssColorVal papayawhip peachpuff peru pink plum powderblue purple contained +syn keyword cssColorVal red rosybrown royalblue saddlebrown salmon sandybrown contained +syn keyword cssColorVal seagreen seashell sienna silver skyblue slateblue contained +syn keyword cssColorVal slategray slategrey snow springgreen steelblue tan contained +syn keyword cssColorVal teal thistle tomato turquoise violet wheat contained +syn keyword cssColorVal whitesmoke yellow yellowgreen contained +syn match cssColorVal "\<white\>" contained +syn keyword cssColorProp color opaticy contained +syn match cssColorProp /color-profile/ contained + +" Box +syn match cssBoxProp /\(\(margin\|padding\)-\(top\|right\|bottom\|left\)\|\(margin\|padding\)\)/ contained +syn match cssBoxProp /\(min\|max\)-\(width\|height\)/ contained +syn match cssBoxProp /box-\(align\|decoration-break\|direction\|flex-group\|flex\|lines\)/ contained +syn match cssBoxProp /box-\(ordinal-group\|orient\|pack\|shadow\|sizing\)/ contained +syn match cssBoxProp /\(outline-\(color\|offset\|style\|width\)\|outline\)/ contained +syn keyword cssBoxProp width height contained + +" Text +syn match cssTextProp /text-\(align-last\|align\|decoration\|emphasis\|height\|indent\|justify\|outline\|shadow\|transform\|wrap\|overflow\)\|text/ contained +syn match cssTextProp /\(line-stacking-\(ruby\|shift\|strategy\)\|line-stacking\|line-height\)/ contained +syn match cssTextProp /vertical-align/ contained +syn match cssTextProp /letter-spacing/ contained +syn match cssTextProp /white-\(space-collapse\|space\)/ contained +syn match cssTextProp /word-\(break\|spacing\|wrap\)/ contained +syn match cssTextProp "\<word-wrap\>" contained +syn match cssTextVal "\<break-word\>" contained +syn match cssTextVal "\<break-all\>" contained +syn match cssTextVal "\<line-through\>" contained +syn match cssTextVal /text-\(top\|bottom\)/ contained +syn keyword cssTextVal uppercase lowercase ellipsis middle contained + +" List +syn match cssListProp /\(list-style-\(type\|image\|position\)\|list-style\)/ contained +syn keyword cssListVal armenian circle disc georgian hebrew square contained +syn match cssListVal /cjk-ideographic/ contained +syn match cssListVal /\(decimal-leading-zero\|decimal\)/ contained +syn match cssListVal /\(\(hiragana\|katakana\)-iroha\|\(hiragana\|katakana\)\)/ contained +syn match cssListVal /\(lower\|upper\)-\(alpha\|latin\|roman\)/ contained +syn match cssListVal /lower-greek/ contained + +" Visual formatting +syn keyword cssVisualProp display position top right bottom left float clear clip contained +syn keyword cssVisualProp zoom visibility cursor direction outline resize contained +syn keyword cssVisualProp opacity contained +syn match cssVisualProp /z-index/ contained +syn match cssVisualProp /\(overflow-\(style\|[xy]\)\|overflow\)/ contained +syn keyword cssVisualVal inline block compact contained +syn match cssVisualVal '\<table\>' contained +syn match cssVisualVal /\(inline-\(block\|table\)\|list-item\|run-in\)/ contained +syn match cssVisualVal /table-\(row-group\|header-group\|footer-group\|row\|column-group\|column\|cell\|caption\)/ contained +syn match cssVisualVal /\<ruby\>-\(base-group\|text-group\|base\|text\)/  contained +syn keyword cssVisualVal static relative absolute fixed contained +syn keyword cssVisualVal ltr rtl embed bidi-override pre nowrap contained +syn keyword cssVisualVal crosshair help move pointer progress wait contained +syn keyword cssVisualVal e-resize n-resize ne-resize nw-resize s-resize se-resize sw-resize w-resize contained + +" Table +syn match cssTableProp /border-\(collapse\|spacing\)/ contained +syn match cssTableProp /\(table-layout\|caption-side\|empty-cells\)/ contained + +" Generated content +syn match cssCommonProp /counter-\(reset\|increment\)/ contained +syn keyword cssCommonProp content quotes contained + +" Print +syn match cssPrintProp /break-\(before\|after\|inside\)/ +syn match cssPrintProp /\(page-break-\(before\|after\|inside\)\|page-policy\)/ +syn keyword cssPrintProp orphans windows + +" special keywords +syn match cssSpecialProp /-\(webkit\|moz\|ms\|o\)-/ +syn match cssRuleProp /@\(media\|font-face\|charset\|import\|page\|namespace\)/ +" http://www.w3.org/TR/selectors/ +syn match cssPseudo /:\(link\|visited\|active\|hover\|focus\|before\|after\)/ +syn match cssPseudo /:\(target\|lang\|enabled\|disabled\|checked\|indeterminate\)/ +syn match cssPseudo /:\(root\|\(first\|last\|only\)-\(child\|of-type\)\|empty\)/ +syn match cssPseudo /:\(nth-last-\|nth-\)\(child\|of-type\)(\<\S\+\>)/ +syn match cssPseudo /:not(\<\S*\>)/ +syn match cssPseudo /:first-\(line\|letter\)/ +syn match cssPseudo /::\(first-\(line\|letter\)\|before\|after\|selection\)/ + +" CSS3 Advanced http://meiert.com/en/indices/css-properties/ +syn keyword cssAdvancedProp appearance azimuth binding bleed columns crop hyphens icon +syn keyword cssAdvancedProp phonemes resize richness size volumne +syn match cssAdvancedProp /\(animation-\(delay\|direction\|duration\|name\|iteration-count\|play-state\|timing-function\)\|animation\)/ +syn match cssAdvancedProp /alignment-\(adjust\|baseline\)/ +syn match cssAdvancedProp /\(backface-visibility\baseline-shift\)/ +syn match cssAdvancedProp /bookmark-\(label\|level\|state\|target\)/ +syn match cssAdvancedProp /column-\(count\|fill\|gap\|rule-\(color\|style\|width\)\|rule\|span\|width\)/ +syn match cssAdvancedProp /\(cue-\(after\|before\)\|cue\)/ +syn match cssAdvancedProp /dominant-baseline/ +syn match cssAdvancedProp /drop-initial-\(size\|value\|\(after\|before\)-\(adjust\|align\)\)/ +syn match cssAdvancedProp /\(fit-position\|fit\)/ +syn match cssAdvancedProp /\(float-offset\|hanging-punctuation\)/ +syn match cssAdvancedProp /grid-\(columns\|rows\)/ +syn match cssAdvancedProp /hyphenate-\(after\|before\|character\|lines\|resource\)/ +syn match cssAdvancedProp /image-\(orientation\|rendering\|resolution\)/ +syn match cssAdvancedProp /inline-box-align/ +syn match cssAdvancedProp /\(mark-\(after\|before\)\|mark\|marks\)/ +syn match cssAdvancedProp /marquee-\(direction\|loop\|play-count\|speed\|style\)/ +syn match cssAdvancedProp /move-to/ +syn match cssAdvancedProp /nav-\(down\|index\|left\|right\|up\)/ +syn match cssAdvancedProp /\(pause-\(after\|before\)\|pause\)/ +syn match cssAdvancedProp /\(perspective-origin\|perspective\)/ +syn match cssAdvancedProp /\(pitch-range\|pitch\)/ +syn match cssAdvancedProp /presentation-level/ +syn match cssAdvancedProp /punctuation-trim/ +syn match cssAdvancedProp /rendering-intent/ +syn match cssAdvancedProp /\(rest-\(after\|before\)\|rest\)/ +syn match cssAdvancedProp /\(rotation-point\|rotation\)/ +syn match cssAdvancedProp /ruby-\(align\|overhang\|position\|span\)/ +syn match cssAdvancedProp /\(target-\(name\|new\|position\)\|target\)/ +syn match cssAdvancedProp /\(transform-\(origin\|style\)\|transform\)/ +syn match cssAdvancedProp /\(transition-\(delay\|duration\|property\|timing-function\)\|transition\)/ +syn match cssAdvancedProp /voice-\(balance\|duration\|family\|pitch-range\|pitch\|rate\|stress\|volume\)/ + +syn match cssAdvancedVal /\(ease-\(in\|out\|in-out\)\|ease\)/ contained + +" CSS3 Advanced value  +"syn match cssAdvancedVal  + + +if main_syntax == "css" +  syn sync minlines=10 +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_css_syn_inits") +  if version < 508 +    let did_css_syn_inits = 1 +    command -nargs=+ HiLink hi link <args> +  else +    command -nargs=+ HiLink hi def link <args> +  endif + +  HiLink cssString String +  HiLink cssComment Comment +  HiLink cssTagName Statement +  HiLink cssSelector Function +  HiLink cssBackgroundProp StorageClass +  HiLink cssTableProp StorageClass +  HiLink cssBorderProp StorageClass +  HiLink cssFontProp StorageClass +  HiLink cssColorProp StorageClass +  HiLink cssBoxProp StorageClass +  HiLink cssTextProp StorageClass +  HiLink cssListProp StorageClass +  HiLink cssVisualProp StorageClass +  HiLink cssAdvancedProp StorageClass +  HiLink cssCommonProp StorageClass +  HiLink cssSpecialProp Special  +  HiLink cssImportant Special +  HiLink cssRuleProp PreProc +  HiLink cssPseudo PreProc + +  HiLink cssColorVal Constant +  HiLink cssCommonVal Type +  HiLink cssFontVal Type +  HiLink cssListVal Type +  HiLink cssTextVal Type +  HiLink cssVisualVal Type +  HiLink cssBorderVal Type +  HiLink cssBackgroundVal Type +  HiLink cssFuncVal Function +  HiLink cssAdvancedVal Function + +  HiLink cssValueLength Number +  HiLink cssValueInteger Number +  HiLink cssValueNumber Number +  HiLink cssValueAngle Number +  HiLink cssValueTime Number +  HiLink cssValueFrequency Number +  delcommand HiLink +endif + +" let b:current_syntax = "css" +"  +if main_syntax == 'css' +  unlet main_syntax +endif + +" Vim syntax file +" Language: Stylus +" Maintainer: Marc Harter +" Filenames: *.styl, *.stylus +" Based On: Tim Pope (sass.vim) + +syn case ignore +syn region cssInclude start="@import" end="\n" contains=cssComment,cssFuncVal,cssRuleProp + +syn cluster stylusCssSelectors contains=cssTagName,cssSelector,cssPseudo +syn cluster stylusCssValues contains=cssValueLength,cssValueInteger,cssValueNumber,cssValueAngle,cssValueTime,cssValueFrequency,cssColorVal,cssCommonVal,cssFontVal,cssListVal,cssTextVal,cssVisualVal,cssBorderVal,cssBackgroundVal,cssFuncVal,cssAdvancedVal +syn cluster stylusCssProperties contains=cssBackgroundProp,cssTableProp,cssBorderProp,cssFontProp,cssColorProp,cssBoxProp,cssTextProp,cssListProp,cssVisualProp,cssAdvancedProp,cssCommonProp,cssSpecialProp + +syn match stylusVariable "$\?[[:alnum:]_-]\+" +syn match stylusVariableAssignment "\%([[:alnum:]_-]\+\s*\)\@<==" nextgroup=stylusCssAttribute,stylusVariable skipwhite + +syn match stylusProperty "\%([{};]\s*\|^\)\@<=\%([[:alnum:]-]\|#{[^{}]*}\)\+:" contains=@stylusCssProperties,@stylusCssSelectors skipwhite nextgroup=stylusCssAttribute contained containedin=cssDefineBlock +syn match stylusProperty "^\s*\zs\s\%(\%([[:alnum:]-]\|#{[^{}]*}\)\+[ :]\|:[[:alnum:]-]\+\)"hs=s+1 contains=@stylusCssProperties,@stylusCssSelectors skipwhite nextgroup=stylusCssAttribute +syn match stylusProperty "^\s*\zs\s\%(:\=[[:alnum:]-]\+\s*=\)"hs=s+1 contains=@stylusCssProperties,@stylusCssSelectors skipwhite nextgroup=stylusCssAttribute + +syn match stylusCssAttribute +\%("\%([^"]\|\\"\)*"\|'\%([^']\|\\'\)*'\|#{[^{}]*}\|[^{};]\)*+ contained contains=@stylusCssValues,cssImportant,stylusFunction,stylusVariable,stylusControl,stylusUserFunction,stylusInterpolation,cssString,stylusComment,cssComment + +syn match stylusInterpolation %{[[:alnum:]_-]\+}% + +syn match stylusFunction "\<\%(red\|green\|blue\|alpha\|dark\|light\)\>(\@=" contained +syn match stylusFunction "\<\%(hue\|saturation\|lightness\|push\|unshift\|typeof\|unit\|match\)\>(\@=" contained +syn match stylusFunction "\<\%(hsla\|hsl\|rgba\|rgb\|lighten\|darken\)\>(\@=" contained +syn match stylusFunction "\<\%(abs\|ceil\|floor\|round\|min\|max\|even\|odd\|sum\|avg\|sin\|cos\|join\)\>(\@=" contained +syn match stylusFunction "\<\%(desaturate\|saturate\|invert\|unquote\|quote\|s\)\>(\@=" contained +syn match stylusFunction "\<\%(operate\|length\|warn\|error\|last\|p\|\)\>(\@=" contained +syn match stylusFunction "\<\%(opposite-position\|image-size\|add-property\)\>(\@=" contained + +syn keyword stylusVariable null true false arguments +syn keyword stylusControl  if else unless for in return + +syn match stylusAmpersand  "&" +syn match stylusClass      "[[:alnum:]_-]\+" contained +syn match stylusClassChar  "\.[[:alnum:]_-]\@=" nextgroup=stylusClass +syn match stylusEscape     "^\s*\zs\\" +syn match stylusId         "[[:alnum:]_-]\+" contained +syn match stylusIdChar     "#[[:alnum:]_-]\@=" nextgroup=stylusId + +syn region stylusComment    start="//" end="$" contains=cssTodo,@Spell fold + +hi def link stylusComment               Comment +hi def link stylusVariable              Identifier +hi def link stylusControl               PreProc +hi def link stylusFunction              Function +hi def link stylusInterpolation         Delimiter + +hi def link stylusAmpersand             Character +hi def link stylusClass                 Type +hi def link stylusClassChar             Special +hi def link stylusEscape                Special +hi def link stylusId                    Identifier +hi def link stylusIdChar                Special + +let b:current_syntax = "stylus" + +" vim:set sw=2: diff --git a/syntax/textile.vim b/syntax/textile.vim new file mode 100644 index 00000000..e9534e9b --- /dev/null +++ b/syntax/textile.vim @@ -0,0 +1,91 @@ +" +"   You will have to restart vim for this to take effect.  In any case +"   it is a good idea to read ":he new-filetype" so that you know what +"   is going on, and why the above lines work. +" +"   Written originally by Dominic Mitchell, Jan 2006. +"   happygiraffe.net +" +"   Modified by Aaron Bieber, May 2007. +"   blog.aaronbieber.com +" +"   Modified by Tim Harper, July 2008 - current +"   tim.theenchanter.com +" @(#) $Id$ + +if version < 600 +    syntax clear +elseif exists("b:current_syntax") +    finish +endif + +" Textile commands like "h1" are case sensitive, AFAIK. +syn case match + +" Textile syntax: <http://textism.com/tools/textile/> + +" Inline elements. +syn match txtEmphasis    /_[^_]\+_/ +syn match txtBold        /\*[^*]\+\*/ +syn match txtCite        /??.\+??/ +syn match txtDeleted     /-[^-]\+-/ +syn match txtInserted    /+[^+]\++/ +syn match txtSuper       /\^[^^]\+\^/ +syn match txtSub         /\~[^~]\+\~/ +syn match txtSpan        /%[^%]\+%/ +syn match txtFootnoteRef /\[[0-9]\+]/ +syn match txtCode        /@[^@]\+@/ + +" Block elements. +syn match txtHeader      /^h1\(([^)]*)\|{[^}]*}\|\[[^]]*\]\|[<>=()]\)*\. .\+/ +syn match txtHeader2     /^h2\(([^)]*)\|{[^}]*}\|\[[^]]*\]\|[<>=()]\)*\. .\+/ +syn match txtHeader3     /^h[3-6]\(([^)]*)\|{[^}]*}\|\[[^]]*\]\|[<>=()]\)*\..\+/ +syn match txtFootnoteDef /^fn[0-9]\+\(([^)]*)\|{[^}]*}\|\[[^]]*\]\|[<>=()]\)*\./ +syn match txtListBullet  /\v^\*+ / +syn match txtListBullet2  /\v^(\*\*)+ / +syn match txtListNumber  /\v^#+ / +syn match txtListNumber2  /\v^(##)+ / + +syn region txtCodeblock start="^bc\(([^)]*)\|{[^}]*}\|\[[^]]*\]\|[<>=()]\)*\. " end="^$" +syn region txtBlockquote start="^bq\(([^)]*)\|{[^}]*}\|\[[^]]*\]\|[<>=()]\)*\. " end="^$" +syn region txtParagraph start="^bq\(([^)]*)\|{[^}]*}\|\[[^]]*\]\|[<>=()]\)*\. " end="^$" + +syn cluster txtBlockElement contains=txtHeader,txtBlockElement,txtFootnoteDef,txtListBullet,txtListNumber + + +" Everything after the first colon is from RFC 2396, with extra +" backslashes to keep vim happy...  Original: +" ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? +" +" Revised the pattern to exclude spaces from the URL portion of the +" pattern. Aaron Bieber, 2007. +syn match txtLink /"[^"]\+":\(\([^:\/?# ]\+\):\)\?\(\/\/\([^\/?# ]*\)\)\?\([^?# ]*\)\(?\([^# ]*\)\)\?\(#\([^ ]*\)\)\?/ + +syn cluster txtInlineElement contains=txtEmphasis,txtBold,txtCite,txtDeleted,txtInserted,txtSuper,txtSub,txtSpan + +if version >= 508 || !exists("did_txt_syn_inits") +    if version < 508 +        let did_txt_syn_inits = 1 +        command -nargs=+ HiLink hi link <args> +    else +        command -nargs=+ HiLink hi def link <args> +    endif + +    HiLink txtHeader Title +    HiLink txtHeader2 Question +    HiLink txtHeader3 Statement +    HiLink txtBlockquote Comment +    HiLink txtCodeblock Identifier +    HiLink txtListBullet Operator +    HiLink txtListBullet2 Constant +    HiLink txtListNumber Operator +    HiLink txtListNumber2 Constant +    HiLink txtLink String +    HiLink txtCode Identifier +    hi def txtEmphasis term=underline cterm=underline gui=italic +    hi def txtBold term=bold cterm=bold gui=bold + +    delcommand HiLink +endif + +" vim: set ai et sw=4 : diff --git a/syntax/tmux.vim b/syntax/tmux.vim new file mode 100644 index 00000000..ae24be76 --- /dev/null +++ b/syntax/tmux.vim @@ -0,0 +1,104 @@ +" Vim syntax file +" Language: tmux(1) configuration file +" Maintainer: Tiago Cunha <me@tiagocunha.org> +" Last Change: $Date: 2010-07-27 18:29:07 $ +" License: This file is placed in the public domain. + +if version < 600 +	syntax clear +elseif exists("b:current_syntax") +	finish +endif + +setlocal iskeyword+=- +syntax case match + +syn keyword tmuxAction	any current none +syn keyword tmuxBoolean	off on + +syn keyword tmuxCmds detach[-client] ls list-sessions neww new-window +syn keyword tmuxCmds bind[-key] unbind[-key] prev[ious-window] last[-window] +syn keyword tmuxCmds lsk list-keys set[-option] renamew rename-window selectw +syn keyword tmuxCmds select-window lsw list-windows attach[-session] +syn keyword tmuxCmds send-prefix refresh[-client] killw kill-window lsc +syn keyword tmuxCmds list-clients linkw link-window unlinkw unlink-window +syn keyword tmuxCmds next[-window] send[-keys] swapw swap-window +syn keyword tmuxCmds rename[-session] kill-session switchc switch-client +syn keyword tmuxCmds has[-session] copy-mode pasteb paste-buffer +syn keyword tmuxCmds new[-session] start[-server] kill-server setw +syn keyword tmuxCmds set-window-option show[-options] showw show-window-options +syn keyword tmuxCmds command-prompt setb set-buffer showb show-buffer lsb +syn keyword tmuxCmds list-buffers deleteb delete-buffer lscm list-commands +syn keyword tmuxCmds movew move-window respawnw respawn-window +syn keyword tmuxCmds source[-file] info server-info clock-mode lock[-server] +syn keyword tmuxCmds saveb save-buffer killp +syn keyword tmuxCmds kill-pane resizep resize-pane selectp select-pane swapp +syn keyword tmuxCmds swap-pane splitw split-window choose-session +syn keyword tmuxCmds choose-window loadb load-buffer copyb copy-buffer suspendc +syn keyword tmuxCmds suspend-client findw find-window breakp break-pane nextl +syn keyword tmuxCmds next-layout rotatew rotate-window confirm[-before] +syn keyword tmuxCmds clearhist clear-history selectl select-layout if[-shell] +syn keyword tmuxCmds display[-message] setenv set-environment showenv +syn keyword tmuxCmds show-environment choose-client displayp display-panes +syn keyword tmuxCmds run[-shell] lockc lock-client locks lock-session lsp +syn keyword tmuxCmds list-panes pipep pipe-pane showmsgs show-messages capturep +syn keyword tmuxCmds capture-pane joinp join-pane choose-buffer + +syn keyword tmuxOptsSet prefix status status-fg status-bg bell-action +syn keyword tmuxOptsSet default-command history-limit status-left status-right +syn keyword tmuxOptsSet status-interval set-titles display-time buffer-limit +syn keyword tmuxOptsSet status-left-length status-right-length +syn keyword tmuxOptsSet message-[command-]bg lock-after-time default-path +syn keyword tmuxOptsSet message-[command-]attr status-attr set-remain-on-exit +syn keyword tmuxOptsSet status-utf8 default-terminal visual-activity repeat-time +syn keyword tmuxOptsSet visual-bell visual-content status-justify status-keys +syn keyword tmuxOptsSet terminal-overrides status-left-attr status-left-bg +syn keyword tmuxOptsSet status-left-fg status-right-attr status-right-bg +syn keyword tmuxOptsSet status-right-fg update-environment base-index +syn keyword tmuxOptsSet display-panes-colour display-panes-time default-shell +syn keyword tmuxOptsSet set-titles-string lock-command lock-server +syn keyword tmuxOptsSet mouse-select-pane message-limit quiet escape-time +syn keyword tmuxOptsSet pane-active-border-bg pane-active-border-fg +syn keyword tmuxOptsSet pane-border-bg pane-border-fg message-[command-]fg +syn keyword tmuxOptsSet display-panes-active-colour alternate-screen +syn keyword tmuxOptsSet detach-on-destroy + +syn keyword tmuxOptsSetw monitor-activity aggressive-resize force-width +syn keyword tmuxOptsSetw force-height remain-on-exit uft8 mode-fg mode-bg +syn keyword tmuxOptsSetw mode-keys clock-mode-colour clock-mode-style +syn keyword tmuxOptsSetw xterm-keys mode-attr window-status-attr +syn keyword tmuxOptsSetw window-status-bg window-status-fg automatic-rename +syn keyword tmuxOptsSetw main-pane-width main-pane-height monitor-content +syn keyword tmuxOptsSetw window-status-current-attr window-status-current-bg +syn keyword tmuxOptsSetw window-status-current-fg mode-mouse synchronize-panes +syn keyword tmuxOptsSetw window-status-format window-status-current-format +syn keyword tmuxOptsSetw word-separators window-status-alert-attr +syn keyword tmuxOptsSetw window-status-alert-bg window-status-alert-fg + +syn keyword tmuxTodo FIXME NOTE TODO XXX contained + +syn match tmuxKey		/\(C-\|M-\|\^\)\+\S\+/	display +syn match tmuxNumber 		/\d\+/			display +syn match tmuxOptions		/\s-\a\+/		display +syn match tmuxVariable		/\w\+=/			display +syn match tmuxVariableExpansion	/\${\=\w\+}\=/		display + +syn region tmuxComment	start=/#/ end=/$/ contains=tmuxTodo display oneline +syn region tmuxString	start=/"/ end=/"/ display oneline +syn region tmuxString	start=/'/ end=/'/ display oneline + +hi def link tmuxAction			Boolean +hi def link tmuxBoolean			Boolean +hi def link tmuxCmds			Keyword +hi def link tmuxComment			Comment +hi def link tmuxKey			Special +hi def link tmuxNumber			Number +hi def link tmuxOptions			Identifier +hi def link tmuxOptsSet			Function +hi def link tmuxOptsSetw		Function +hi def link tmuxString			String +hi def link tmuxTodo			Todo +hi def link tmuxVariable		Constant +hi def link tmuxVariableExpansion	Constant + +let b:current_syntax = "tmux" | 
