Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into fix-def-indentation

  • Loading branch information...
commit 8577bafb1962bfdeb5b1c8405c21c86a515ed410 2 parents 00ecb05 + 30c6aee
@AndrewRadev AndrewRadev authored
View
1  .gitignore
@@ -0,0 +1 @@
+doc/tags
View
1  bin/vim-ruby-install.rb
@@ -431,6 +431,7 @@ def path
puts
puts "Target directory '#{target_dir}' does not exist."
response = Env.ask_user "Do you want to create it? [Yn] "
+ response = "y" if response.empty?
if response.strip =~ /^y(es)?$/i
FileUtils.mkdir_p(target_dir, :verbose => true)
else
View
25 etc/examples/indent/blocks.rb
@@ -0,0 +1,25 @@
+proc do |(a, b)|
+ puts a
+ puts b
+end
+
+proc do |foo, (a, b), bar|
+ puts a
+ puts b
+end
+
+define_method "something" do |param|
+ if param == 42
+ do_something
+ else
+ do_something_else
+ end
+end
+
+def foo
+ opts.on('--coordinator host=HOST[,port=PORT]',
+ 'Specify the HOST and the PORT of the coordinator') do |str|
+ h = sub_opts_to_hash(str)
+ puts h
+ end
+end
View
6 etc/examples/indent/continuation_blocks.rb
@@ -1,6 +0,0 @@
-def foo
- opts.on('--coordinator host=HOST[,port=PORT]',
- 'Specify the HOST and the PORT of the coordinator') do |str|
- h = sub_opts_to_hash(str)
- end
-end
View
8 etc/examples/indent/nested_hashes.rb
@@ -35,7 +35,7 @@ class Foo
foo,
bar = {
:bar => {
- :foo { 'bar' => 'baz' },
+ :foo => { 'bar' => 'baz' },
:one => 'two',
:three => 'four'
}
@@ -46,8 +46,8 @@ class Foo
var.
func1(:param => 'value') {
func1_5(:param => 'value')
- var.func2(:param => 'value') {
- puts "test"
- }
+ var.func2(:param => 'value') {
+ puts "test"
+ }
}
end
View
12 etc/release/README
@@ -1,12 +0,0 @@
-cvsrelease is a wicked shell script for creating tarballs and/or zips from
-CVS. It is very flexible, allowing arbitrary scripts to be executed on the
-temporary export tree before archiving it. One such application of this would
-be the removal of some files from the "stable" version.
-
-release.sh is my wrapper around cvsrelease. The main benefit is that it
-deduces the CVS root from the local working directory. It contains usage
-information. When required, I will amend this, and add whatever other scripts
-are needed, to produce stable and development releases for us.
-
-Gavin Sinclair, 2003-09-26
-
View
167 etc/release/cvsrelease
@@ -1,167 +0,0 @@
-#!/bin/sh
-
-#
-# Automates the process of tagging, exporting and packaging a release from CVS.
-# Steve Purcell <stephen_purcell at yahoo dot com>
-#
-
-AUTHOR='Steve Purcell <stephen_purcell at yahoo dot com>'
-VERSION=`echo '$Revision$'|cut -d' ' -f2`
-PROJECT='Visit http://cvsutils.sourceforge.net/ for updates and information'
-
-progname=`basename $0`
-
-function usage() {
- cat <<EOF 1>&2
-Creates appropriately named .tar.gz and .zip files containing the files in
-the current \$CVSROOT for release 'release-tag' of the CVS module 'cvsmodule'.
-
- usage: $progname [options] -t release-tag -r release-number cvsmodule
-
-options:
- -t The CVS tag name
- -r The release number, e.g. 1.2
- -b branch Make the release in the branch with the given name (not
- allowed unless -T is also set)
- -z Make a '.zip'. release file as well as the usual '.tar.gz' file
- -T Also create the CVS tag (use with caution)
- -f flavour Name the release files cvsmodule-flavour-releasenum.tar.gz etc.
- -x script Execute script inside exported module directory before
- Packaging
- -h Show this help page
- -V Show version information
-
-The following example would create a CVS tag '0-3' for the module 'webunit',
-and package that module into both a 'tar.gz' archive and a 'zip' archive
-containing a top-level directory 'webunit-0.3'.
-
- % $progname -Tz -t 0-3 -r 0.3 webunit
-
-If a script is specified using the '-x' option, it will be executed in the
-root directory of the exported module before the release file is created.
-This option can be used to remove unwanted portions of a release, or to
-pre-compile binaries for inclusion in the release file. The release tag and
-number are exported to the script as \$RELEASETAG and \$RELEASENUM
-respectively. Often that script will be used in conjunction with the '-f'
-option.
-EOF
-}
-
-function showversion() {
- echo "$progname version $VERSION, by $AUTHOR"
- echo "$PROJECT"
-}
-
-function message() {
- echo "$progname$1" 1>&2
-}
-
-function error_exit() {
- message "error: $1" 1>&2
- tidyup
- exit 1
-}
-
-function tidyup() {
- if [ -n "$tempdir" -a -d "$tempdir" ]; then
- rm -r $tempdir
- fi
-}
-
-
-## Begin option parsing
-while getopts t:r:zThx:f:Vb: opt; do
- case "$opt" in
- t) releasetag="$OPTARG" ;;
- r) releasenum="$OPTARG" ;;
- b) frombranch="$OPTARG" ;;
- z) makezip=1 ;;
- T) maketag=1 ;;
- f) flavour="$OPTARG" ;;
- x) releasescript="$OPTARG" ;;
- V) showversion; exit 0 ;;
- h) usage; exit 0 ;;
- *) usage; exit 2 ;;
- esac
-done
-
-shift $(($OPTIND - 1))
-
-## Check values of options
-module=$1
-
-if [ -z "$module" -o -z "$releasetag" -o -z "$releasenum" ]; then
- message "mandatory option(s) missing"
- usage
- exit 2
-fi
-if [ -n "$frombranch" -a -z "$maketag" ]; then
- message "option -b cannot be used without -T"
- usage
- exit 2
-fi
-
-## Prepare a directory in which to work
-orig_dir=$PWD
-tempdir=/tmp/$progname.$$
-mkdir $tempdir || error_exit "couldn't create $tempdir"
-cd $tempdir
-
-message "CVS root is $CVSROOT"
-
-## Create the CVS tag if it was requested
-if [ "$maketag" ]; then
- if [ -n "$frombranch" ]; then
- branch=$frombranch
- else
- branch=HEAD
- fi
- cvs co -r $branch $module || \
- error_exit "error checking out from CVS"
- cvs tag $releasetag || \
- error_exit "error setting tag '$releasetag'"
- rm -rf $module
-fi
-
-## Choose a name for the top level directory
-releasedir=$module-$releasenum
-
-## Export the files to package
-message "exporting from CVS"
-cvs export -r$releasetag -d $releasedir $module || \
- error_exit "error exporting code from CVS"
-
-## Choose a name for the generated archive files
-if [ -n "$flavour" ]; then
- archive_base=$orig_dir/$module-$flavour-$releasenum
-else
- archive_base=$orig_dir/$module-$releasenum
-fi
-
-if [ -n "$releasescript" ]; then
- message "running release script '$releasescript' in $releasedir"
- (cd $releasedir && \
- RELEASETAG=$releasetag RELEASENUM=$releasenum $releasescript) || \
- error_exit "error running release script; aborting."
-fi
-
-## Create a '.tar.gz'
-tarball=$archive_base.tar.gz
-message "creating release tarball: $tarball"
-tar cfz $tarball $module-$releasenum || \
- error_exit "couldn't create $tarball"
-
-## And a '.zip' too if it was requested
-if [ "$makezip" ]; then
- zipfile=$archive_base.zip
- message "creating release zipfile: $zipfile"
- zip -qr $zipfile $module-$releasenum || \
- error_exit "couldn't create $zipfile"
-fi
-
-## finish up
-cd $orig_dir
-tidyup
-
-message "done"
-exit 0
View
19 etc/release/release.sh
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-# This depends on cvsrelease, downloadable from cvsutils.sourceforge.net,
-# but included in this directory. It is covered by a BSD license.
-
-usage() {
- echo "usage: $0 <tag> <release number>" 1>&2
- echo " eg: $0 v0_2_0 0.2.0" 1>&2
- exit 2
-}
-
-[ $# -eq 2 ] || usage
-
-release_tag=$1
-release_number=$2
-
-export CVSROOT=`cat CVS/Root`
-cvsrelease -z -t $release_tag -r $release_number vim-ruby
-
View
34 etc/website/djk-theme.css
@@ -1,34 +0,0 @@
-body {
- margin: 0em 2em;
- font-family: Verdana, Helvetica, Arial, sans-serif;
- color: black;
- background-color: white;
-}
-
-h1 {
- padding: 0.2em 0.5em;
- color: black;
- background-color: #C1AEC9;
- font-weight:900;
- font-size: xx-large;
-}
-
-h2 {
- padding: 0.2em 0.5em;
- border: thin solid silver;
- color: white;
- background-color: #653579;
- font-weight:900;
- font-size: x-large;
-}
-
-p {
- line-height: 1.3em;
- padding: 0em 1em;
-}
-
-.readme {
- padding: 2em;
- margin: 2em;
- border: thin solid black;
-}
View
133 etc/website/index.html
@@ -1,133 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
- "http://www.w3.org/TR/html4/strict.dtd">
-<html lang="en">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <title>
- Vim/Ruby Configuration Files
- </title>
- <link media="screen" href="djk-theme.css" type="text/css" rel="stylesheet">
- </head>
- <body>
- <h1>
- Vim/Ruby Configuration Files
- </h1>
- <h2>
- Introduction
- </h2>
- <p>
- If you edit <a href="http://www.ruby-lang.org/">Ruby</a> code in <a href="http://www.vim.org/">Vim</a>, there are some configuration files (distributed with Vim) that aim to make your life easier. These are maintained by three different people, but are grouped together in <a href="http://www.rubyforge.org/projects/vim-ruby">this project</a> so we can keep them all up to date and offer them in a <a href="http://rubyforge.org/project/showfiles.php?group_id=16">convenient download</a>.
- </p>
- <p>
- Below you will find the README file from the <a href="https://github.com/vim-ruby/vim-ruby">Git repository</a>, which discusses the structure of the project, and how to take advantage of the resources it offers.
- </p>
- <p>
- <em>Gavin Sinclair, 2003-07-28</em>
- </p>
- <h2>
- Links
- </h2>
- <p>
- The links from the document below are presented here so they will be hyperlinked.
- </p>
- <p>
- Project page: <a href="http://www.rubyforge.org/projects/vim-ruby">http://www.rubyforge.org/projects/vim-ruby</a><br>
- Explanation: <a href="http://www.rubygarden.org/Ruby/page/show/VimRubySupport">http://www.rubygarden.org/Ruby/page/show/VimRubySupport</a>
- </p>
- <h2>
- README
- </h2>
- <p>
- <em>This is the text of the README document in the project package.</em>
- </p>
- <pre class="readme">
- +-----------------------------------+
- | vim-ruby RubyForge project README |
- +-----------------------------------+
-
-Summary:
- This project contains Vim configuration files for editing and compiling Ruby
- within Vim. See the project homepage for more details.
-
-Web links:
- Homepage: http://vim-ruby.rubyforge.org
- Project: http://www.rubyforge.org/vim-ruby
-
-For regular users:
- - The project page should have two tarballs for download:
- - vim-ruby-YYYY.MM.DD.tar.gz (the current stable release)
- - vim-ruby-devel-YYYY.MM.DD.tar.gz (cutting-edge features we'd like you
- to test)
- - Please give feedback through the bug tracking and feature request features
- of RubyForge.
- - Feel free to join discussions on the vim-ruby-devel mailing list.
- Instructions on how to join are in the project page somewhere.
- - RubyForge also features forums, but the mailing list is better.
-
-For would-be contributors:
- - Please get the latest from Git.
- - Please join the mailing list and discuss changes, submit patches, etc.
- - Thank you very much for taking an interest.
-
-Contents of the project:
- - The autoload, compiler, ftdetect, ftplugin, indent and syntax directories
- contain the ruby*.vim files that are to be copied to a location somewhere
- in the Vim 'runtimepath'.
- - vim-ruby-install.rb performs this copying.
-
-How you get these files into Vim:
- - By downloading the project via a snapshot or Git, you can keep up with
- the latest, make changes, and install the files to a Vim directory.
- - By downloading one of the tarballs, you can easily install the latest
- stable or development version wherever you like on your machine. No
- README, no vim-ruby-install.rb, just Vim files. You would typically
- install these into either $VIM/vimfiles, for system-wide use, or $HOME/.vim
- ($HOME/vimfiles on Windows) for personal use.
- - Remember that when you install Vim in the first place, all of these files
- are present. The purpose of downloading and installing them from
- RubyForge is to get the latest version of them.
-
-Understanding the configuration files:
- - See http://www.rubygarden.org/Ruby/page/show/VimRubySupport
- - Email any one of us or ruby-talk if you want more information added to
- this page.
-
-Git topics:
- - Project was migrated from CVS in August, 2008.
- - Files are tagged according to which version of Vim they are released in.
- - The project was initiated in July 2003, when the current version of Vim
- was 6.2. Thus every file began its life tagged as vim6.2.
- - Modifications to the files are made in the expectation that they need to
- be tested by interested users. They therefore (probably) don't have a
- tag, and are available via "git pull --rebase", or a development snapshot.
- - When a modification is considered stable, it is given a tag.
- Everything that is stable gets released in vim-ruby-YYY.MM.DD.tar.gz files.
- - When a new version of Vim is about to be released, the stable tarball is
- contributed to it. After it has been released, the files are tagged
- accordingly.
- - MORAL OF THE STORY: modifications are committed to the head of the tree;
- when they are ready for release into userland, they are tagged "stable".
-
-Any questions or suggestions?
- - If there's something about the project or its concepts that you don't
- understand, send an email to the project maintainer, Gavin Sinclair
- (gsinclair at gmail.com).
- - To ask about the contents of the configuration files, ask on the mailing
- list, as different people maintain the different files. Gavin knows
- nothing about the syntax file, for instance. (Come to think of it, nor does
- Doug - djk)
-
-Project gossip:
- - Two of the configuration file maintainers, Doug Kearns and Gavin Sinclair,
- live in Australia (Jindabyne and Sydney respectively). Tim Hammerquist,
- the last man standing, has lived in the Reno/Lake Tahoe area of Nevada,
- USA, since the late 1970s and doesn't like to gamble; a waste, really.
- - While the individual effort to maintain these files has a long history,
- this actual project began in late July 2003. Therefore, if you're reading
- this soon thereafter and something doesn't make sense, now is the time to
- let us know.
-
- --= End of Document =--
- </pre>
- </body>
-</html>
View
1  etc/website/update.sh
@@ -1 +0,0 @@
-scp index.html gsinclair@rubyforge.org:/var/www/gforge-projects/vim-ruby/
View
35 ftdetect/ruby.vim
@@ -1,44 +1,49 @@
" Ruby
-au BufNewFile,BufRead *.rb,*.rbw,*.gemspec set filetype=ruby
+au BufNewFile,BufRead *.rb,*.rbw,*.gemspec set filetype=ruby
" Ruby on Rails
-au BufNewFile,BufRead *.builder,*.rxml,*.rjs set filetype=ruby
+au BufNewFile,BufRead *.builder,*.rxml,*.rjs set filetype=ruby
" Rakefile
-au BufNewFile,BufRead [rR]akefile,*.rake set filetype=ruby
+au BufNewFile,BufRead [rR]akefile,*.rake set filetype=ruby
" Rantfile
-au BufNewFile,BufRead [rR]antfile,*.rant set filetype=ruby
+au BufNewFile,BufRead [rR]antfile,*.rant set filetype=ruby
" IRB config
-au BufNewFile,BufRead .irbrc,irbrc set filetype=ruby
+au BufNewFile,BufRead .irbrc,irbrc set filetype=ruby
" Pry config
-au BufNewFile,BufRead .pryrc set filetype=ruby
+au BufNewFile,BufRead .pryrc set filetype=ruby
" Rackup
-au BufNewFile,BufRead *.ru set filetype=ruby
+au BufNewFile,BufRead *.ru set filetype=ruby
" Capistrano
-au BufNewFile,BufRead Capfile set filetype=ruby
+au BufNewFile,BufRead Capfile set filetype=ruby
" Bundler
-au BufNewFile,BufRead Gemfile set filetype=ruby
+au BufNewFile,BufRead Gemfile set filetype=ruby
" Guard
-au BufNewFile,BufRead Guardfile,.Guardfile set filetype=ruby
+au BufNewFile,BufRead Guardfile,.Guardfile set filetype=ruby
" Vagrant
-au BufNewFile,BufRead [vV]agrantfile set filetype=ruby
+au BufNewFile,BufRead [vV]agrantfile set filetype=ruby
" Autotest
-au BufNewFile,BufRead .autotest set filetype=ruby
+au BufNewFile,BufRead .autotest set filetype=ruby
" eRuby
-au BufNewFile,BufRead *.erb,*.rhtml set filetype=eruby
+au BufNewFile,BufRead *.erb,*.rhtml set filetype=eruby
" Thor
-au BufNewFile,BufRead [tT]horfile,*.thor set filetype=ruby
+au BufNewFile,BufRead [tT]horfile,*.thor set filetype=ruby
" Rabl
-au BufNewFile,BufRead *.rabl set filetype=ruby
+au BufNewFile,BufRead *.rabl set filetype=ruby
+
+" Jbuilder
+au BufNewFile,BufRead *.jbuilder set filetype=ruby
+
+" vim: nowrap sw=2 sts=2 ts=8 noet:
View
38 indent/ruby.vim
@@ -33,7 +33,7 @@ set cpo&vim
" ============
" Regex of syntax group names that are or delimit string or are comments.
-let s:syng_strcom = '\<ruby\%(Regexp\|RegexpDelimiter' .
+let s:syng_strcom = '\<ruby\%(Regexp\|RegexpDelimiter\|RegexpEscape' .
\ '\|String\|StringEscape\|ASCIICode' .
\ '\|Interpolation\|NoInterpolation\|Comment\|Documentation\)\>'
@@ -91,8 +91,16 @@ let s:continuation_regex =
let s:bracket_continuation_regex = '\%([({[]\)\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*\%(|\%([*@&]\=\h\w*,\=\s*\)\%(,\s*[*@&]\=\h\w*\)*|\)\=\s*\%(#.*\)\=$'
+ \ '\%(\<do:\@!\>\|{\)\s*\%(|\s*(\=\%([*@&]\=\h\w*,\=\s*\)\%(,\s*(\=\s*[*@&]\=\h\w*)\=\)*|\)\=\s*\%(#.*\)\=$'
" 2. Auxiliary Functions {{{1
" ======================
@@ -151,15 +159,41 @@ function s:GetMSL(lnum)
if line =~ s:non_bracket_continuation_regex && msl_body =~ 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 line =~ s:non_bracket_continuation_regex && (msl_body =~ s:bracket_continuation_regex || msl_body =~ s:block_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 line =~ s:bracket_continuation_regex && (msl_body =~ s:bracket_continuation_regex || msl_body =~ s:block_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 line =~ s:block_regex && msl_body !~ s:continuation_regex && msl_body !~ s:block_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
Please sign in to comment.
Something went wrong with that request. Please try again.