├── .gitignore ├── Manifest ├── .version ├── ftdetect └── ruby-sinatra.vim ├── Bakefile ├── snippets └── ruby-sinatra.snippets ├── README.md └── syntax └── ruby-sinatra.vim /.gitignore: -------------------------------------------------------------------------------- 1 | .*.sw[p-z] 2 | *.tag 3 | *.tmp 4 | *.vba* 5 | tmp/* 6 | 7 | -------------------------------------------------------------------------------- /Manifest: -------------------------------------------------------------------------------- 1 | ftdetect/ruby-sinatra.vim 2 | snippets/ruby-sinatra.snippets 3 | syntax/ruby-sinatra.vim 4 | -------------------------------------------------------------------------------- /.version: -------------------------------------------------------------------------------- 1 | # version attributes 2 | tag=0.2.0 3 | date=2010-01-29 4 | milestone='Beta version' 5 | timestamp=2010-01-22T18:54:42-04:00 6 | -------------------------------------------------------------------------------- /ftdetect/ruby-sinatra.vim: -------------------------------------------------------------------------------- 1 | " Ruby/Sinatra application name 2 | autocmd BufNewFile,BufRead *.rb 3 | \ let lines = getline(1).getline(2).getline(3).getline(3).getline(4).getline(5) 4 | \|if lines =~? '[Ss]inatra' 5 | \| set filetype=ruby-sinatra 6 | \|endif 7 | 8 | " I'm learning more. 9 | " 10 | " autocmd BufReadPost *.rb 11 | " \ if b:current_syntax == 'ruby,sinatra' 12 | " \| runtime! syntax/ruby-sinatra.vim 13 | " \|endif 14 | " 15 | " autocmd Syntax 16 | " \ runtime! syntax/ruby-sinatra.vim 17 | " 18 | 19 | -------------------------------------------------------------------------------- /Bakefile: -------------------------------------------------------------------------------- 1 | source version.bk 2 | source manifest.bk 3 | 4 | GLOB=(ftdetect/* snippets/* syntax/*) 5 | 6 | declare pkg_name=ruby-sinatra 7 | declare pkg_base=$(dirname "$0") 8 | declare pkg_version=$(git tag | sort | tail -n 1) 9 | declare pkg_file="${pkg_name}-${pkg_version#v}.vba" 10 | declare prefix=".vim" 11 | 12 | desc package "Create ${pkg_file}.gz" 13 | task package { 14 | test -f ${pkg_file} && rm ${pkg_file} 15 | test -f ${pkg_file}.* && rm ${pkg_file}.* 16 | 17 | status "Creating package" 18 | vim Manifest +":%MkVimball! ${pkg_file} ." +":q" 19 | gzip ${pkg_file} 20 | } 21 | 22 | desc install "Install vimball in ${HOME}/.vim/" 23 | task install { 24 | package 25 | status "Intalling ${pkg_file}.gz" 26 | vim ${pkg_file}.gz +":source %" +":q" &> /dev/null 27 | } 28 | 29 | desc doc "Build documentation" 30 | task doc { 31 | status "Building documentation" 32 | run markdown -f toc -T -o README.html README.mkd 33 | } 34 | 35 | task push { 36 | news="github codaset" 37 | hosts="origin github codaset" 38 | } 39 | 40 | desc push:news "Push all changes to hosts" 41 | task push:news { 42 | status "Pushing new changes to ${news// /, }" 43 | for remote in ${news}; do 44 | run git push $remote news 45 | done 46 | } 47 | 48 | desc push:release "Push a new release to hosts" 49 | task push:release { 50 | status "Pushing new release to ${hosts// /, }" 51 | for remote in ${hosts}; do 52 | git push --tags $remote master 53 | done 54 | } 55 | 56 | # vim: filetype=sh 57 | 58 | -------------------------------------------------------------------------------- /snippets/ruby-sinatra.snippets: -------------------------------------------------------------------------------- 1 | # get path do ... end 2 | snippet get 3 | get '/${1:path}'${2:, options} do 4 | ${3:# ...} 5 | end 6 | # post path do ... end 7 | snippet post 8 | post '/${1:path}'${2:, options} do 9 | ${3:# ...} 10 | end 11 | # put path do ... end 12 | snippet put 13 | put '/${1:path}'${2:, options} do 14 | ${3:# ...} 15 | end 16 | # delete path do ... end 17 | snippet del 18 | delete '/${1:path}'${2:, options} do 19 | ${3:# ...} 20 | end 21 | # head ... end 22 | snippet head 23 | head '/${1:path}'${2:, options} do 24 | ${3:# ...} 25 | end 26 | snippet rest 27 | get '/${1:path}' do 28 | ${2} 29 | end 30 | 31 | post '/${1}' do 32 | ${3} 33 | end 34 | 35 | put '/${1}' do 36 | ${4} 37 | end 38 | 39 | delete '/${1}' do 40 | ${5} 41 | end 42 | snippet gp 43 | get '/${1:path}' do 44 | ${2} 45 | end 46 | 47 | post '/${1}' do 48 | ${3} 49 | end 50 | snippet err 51 | error ${1:ErrorName} do 52 | stop ${2:number}, ${3:'

Error!

'} 53 | end 54 | snippet be 55 | before do 56 | ${1} 57 | end 58 | snippet conf 59 | configure :${1:stage} do 60 | ${2} 61 | end 62 | snippet lay 63 | __END__ 64 | 65 | @@ ${1:layout} 66 | ${2:= yield} 67 | ${3} 68 | snippet @ 69 | @@ ${1:page} 70 | snippet erb 71 | erb :${1:name_of_view} 72 | snippet haml 73 | haml :${1:name_of_view} 74 | snippet nf 75 | not_found do 76 | ${1:'

Four Oh Four!

'} 77 | end 78 | snippet sass 79 | haml :${1:name_of_stylesheet} 80 | 81 | # helpers inclass 82 | snippet helc 83 | helpers ${1:inclass} 84 | # helpers do def helper end ... end 85 | snippet held 86 | helpers do 87 | ${1:helper} 88 | end 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Vim - Ruby/Sinatra 2 | ================== 3 | 4 | Description 5 | ----------- 6 | 7 | [Vim][] support for syntax highlight and snippets that helper coding 8 | applications based in [Sinatra][] micro-framework. 9 | 10 | The snippets are written with base the [SnipMate][] plugin. 11 | 12 | Install 13 | ------- 14 | 15 | Download the [gzipball][script homepage] from [Vim][] [script homepage][] and 16 | open the package using [Vim][] and use the command `:source %`. Or run the 17 | following command: 18 | 19 | vim ruby-sinatra-.vba.gz +":source %" 20 | 21 | Done! All files will be extracted in your [Vim][] home directory. 22 | If you checkout from repository, install using the [Bash-Toolbox][]: 23 | 24 | bake install 25 | 26 | This instruction will be create a Vimball file and install. 27 | 28 | Information 29 | ----------- 30 | 31 | You maybe contributes to source. So, send a feedback in [issue tracker][]. 32 | 33 | Vim-Ruby/Sinatra is hosted on following servers: 34 | 35 | * [Github][github host] 36 | * [Codaset][codaset host] 37 | 38 | Visit the [script homepage][] for more information. 39 | 40 | Copyright 41 | --------- 42 | 43 | Copyright (C) 2010 Hallison Batista <email@hallisonbatista.com> 44 | 45 | [vim]: http://www.vim.org/ 46 | "Vim Editor" 47 | 48 | [sinatra]: http://www.sinatrarb.com/ 49 | "Sintra micro-framework for Web applications" 50 | 51 | [snipmate]: http://www.vim.org/scripts/script.php?script_id=2540 52 | "SnipMate plugin" 53 | 54 | [issue tracker]: http://github.com/hallison/vim-ruby-sinatra/issues 55 | "Github issue tracker" 56 | 57 | [github host]: http://github.com/hallison/vim-ruby-sinatra 58 | "Vim - Ruby/Sinatra repository" 59 | 60 | [codaset host]: http://codaset.com/hallison/vim-ruby-sinatra 61 | "Vim - Ruby/Sinatra repository" 62 | 63 | [bash-toolbox]: http://github.com/codigorama/bash-toolbox 64 | "Bash-Toolbox - Scripting tools" 65 | 66 | [script homepage]: http://www.vim.org/scripts/script.php?script_id=2942 67 | "Vim - Ruby/Sinatra" 68 | 69 | -------------------------------------------------------------------------------- /syntax/ruby-sinatra.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Ruby, Sinatra 3 | " Maintainer: Hallison Batista 4 | " URL: http://gibhub.com/hallison/vim-ruby-sinatra 5 | " License: This script is released under the Vim License. 6 | " Remark: This script file was based in the original Ruby syntax highlight. 7 | 8 | " Read the Ruby syntax. 9 | if version < 600 10 | so :p:h/ruby.vim 11 | else 12 | runtime! syntax/ruby.vim 13 | unlet b:current_syntax 14 | endif 15 | 16 | if exists("b:current_syntax") 17 | finish 18 | endif 19 | 20 | syntax keyword rubyInclude use register helpers 21 | syntax keyword rubyAttribute set enable disable 22 | syntax match rubyControl "\<\%(get\|put\|post\|delete\)\>[?!]\@!" 23 | "syntax match rubyControl "\<\%(set\|enable\|disable\)\>[?!]\@!" 24 | "syntax match rubyControl "\<\%(register\|use\)\>[?!]\@!" 25 | syntax match rubyControl "\<\%(configure\|before\|after\)\>[?!]\@!" 26 | "syntax keyword rubyHelpers helpers 27 | "syntax region rubyDoBlock matchgroup=rubyHelpers start="\" end="\" contains=ALLBUT,@rubyNotTop fold 28 | 29 | " Note: the following statements was extracted from the original Ruby syntax file for a hack that prevent wrong 'keywords'. 30 | syn match rubyKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE 31 | syn match rubyKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE 32 | syn match rubyKeywordAsMethod "\%(\%(\.\@" transparent contains=NONE 33 | 34 | highlight def link rubyInclude Include 35 | highlight def link rubyHelpers Statement 36 | highlight def link rubyAttribute Statement 37 | highlight def link rubyControl Statement 38 | if !exists("ruby_no_identifiers") 39 | highlight def link rubyIdentifier Identifier 40 | else 41 | highlight def link rubyIdentifier NONE 42 | endif 43 | 44 | let b:current_syntax = 'ruby-sinatra' 45 | 46 | --------------------------------------------------------------------------------