mirror of
https://github.com/amix/vimrc
synced 2025-07-03 05:55:00 +08:00
Cleaning deps.
This commit is contained in:
Submodule sources_non_forked/vim-ruby deleted from b60da6c63b
1
sources_non_forked/vim-ruby/.gitignore
vendored
Normal file
1
sources_non_forked/vim-ruby/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
doc/tags
|
1
sources_non_forked/vim-ruby/.rspec
Normal file
1
sources_non_forked/vim-ruby/.rspec
Normal file
@ -0,0 +1 @@
|
||||
--color
|
18
sources_non_forked/vim-ruby/CONTRIBUTORS
Normal file
18
sources_non_forked/vim-ruby/CONTRIBUTORS
Normal file
@ -0,0 +1,18 @@
|
||||
Maintainers:
|
||||
Mark Guzman <segfault@hasno.info>
|
||||
Doug Kearns <dougkearns@gmail.com>
|
||||
Tim Pope <vim@NOSPAMtpope.org>
|
||||
Andrew Radev <andrey.radev@gmail.com>
|
||||
Nikolai Weibull <now@bitwi.se>
|
||||
|
||||
Other contributors:
|
||||
Michael Brailsford <brailsmt@yahoo.com>
|
||||
Sean Flanagan <sdflanagan@ozemail.com.au>
|
||||
Tim Hammerquist <timh@rubyforge.org>
|
||||
Ken Miller <ken.miller@gmail.com>
|
||||
Hugh Sasse <hgs@dmu.ac.uk>
|
||||
Tilman Sauerbeck <tilman@code-monkey.de>
|
||||
Bertram Scharpf <info@bertram-scharpf.de>
|
||||
Gavin Sinclair <gsinclair@gmail.com>
|
||||
Aaron Son <aaronson@uiuc.edu>
|
||||
Ned Konz <ned@bike-nomad.com>
|
1579
sources_non_forked/vim-ruby/ChangeLog
Normal file
1579
sources_non_forked/vim-ruby/ChangeLog
Normal file
File diff suppressed because it is too large
Load Diff
251
sources_non_forked/vim-ruby/FAQ
Normal file
251
sources_non_forked/vim-ruby/FAQ
Normal file
@ -0,0 +1,251 @@
|
||||
*vim-ruby.txt* *vim-ruby* *vim-ruby-faq*
|
||||
|
||||
VIM/RUBY CONFIGURATION FILES
|
||||
|
||||
The vim-ruby Project FAQ
|
||||
|
||||
https://github.com/vim-ruby/vim-ruby
|
||||
|
||||
The vim-ruby project maintains Ruby-related configuration files for Vim. This
|
||||
FAQ contains all you need to know about it.
|
||||
|
||||
*** TOC ***
|
||||
|
||||
==============================================================================
|
||||
|
||||
*vim-ruby-faq-X* What is the vim-ruby project?
|
||||
|
||||
It maintains all the configuration files that help Vim edit Ruby code. By
|
||||
installing these files, Vim will properly highlight and indent Ruby files, and
|
||||
will be able to run them and go directly to the location of any errors.
|
||||
Rakefiles, ERB files, and unit tests are also identified and supported.
|
||||
|
||||
If you make use of this project, make sure you read the installation and
|
||||
configuration instructions in this FAQ.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* Doesn't Vim include these files?
|
||||
|
||||
Yes it does. You should only want to download and install this project if it
|
||||
has changed since you last installed your version of Vim. Read the "News"
|
||||
section of the |vim-ruby-homepage| to see when the most recent release was
|
||||
made.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* How do you get it?
|
||||
|
||||
The easiest way is to run: >
|
||||
|
||||
gem install vim-ruby
|
||||
|
||||
(This really only downloads it. See installation instructions
|
||||
|vim-ruby-install| below.)
|
||||
|
||||
If you don't have RubyGems, download a tarball from: >
|
||||
|
||||
https://github.com/vim-ruby/vim-ruby/downloads
|
||||
|
||||
Again, see installation instructions below.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* How do you install it? *vim-ruby-install*
|
||||
|
||||
If you obtained the vim-ruby files via RubyGems, run: >
|
||||
|
||||
vim-ruby-install.rb
|
||||
|
||||
If you downloaded a tarball, unpack it, change to the created directory, and
|
||||
run: >
|
||||
|
||||
ruby bin/vim-ruby-install.rb
|
||||
|
||||
Whichever way you run it, the effect is the same. The installer will:
|
||||
- Search for a Vim config directory to put its files and ask you to confirm.
|
||||
- Copy the configuration files to the appropriate places underneath the
|
||||
directory you selected.
|
||||
|
||||
Here is an example installation transcript:
|
||||
|
||||
Possible Vim installation directories: ~
|
||||
1) D:/Gavin/vimfiles ~
|
||||
2) E:/Vim/vimfiles ~
|
||||
~
|
||||
Please select one (or anything else to specify another directory): 2 ~
|
||||
autoload/rubycomplete.vim -> E:/Vim/vimfiles/autoload/rubycomplete.vim ~
|
||||
compiler/eruby.vim -> E:/Vim/vimfiles/compiler/eruby.vim ~
|
||||
compiler/ruby.vim -> E:/Vim/vimfiles/compiler/ruby.vim ~
|
||||
compiler/rubyunit.vim -> E:/Vim/vimfiles/compiler/rubyunit.vim ~
|
||||
ftdetect/ruby.vim -> E:/Vim/vimfiles/ftdetect/ruby.vim ~
|
||||
ftplugin/eruby.vim -> E:/Vim/vimfiles/ftplugin/eruby.vim ~
|
||||
ftplugin/ruby.vim -> E:/Vim/vimfiles/ftplugin/ruby.vim ~
|
||||
indent/eruby.vim -> E:/Vim/vimfiles/indent/eruby.vim ~
|
||||
indent/ruby.vim -> E:/Vim/vimfiles/indent/ruby.vim ~
|
||||
syntax/eruby.vim -> E:/Vim/vimfiles/syntax/eruby.vim ~
|
||||
syntax/ruby.vim -> E:/Vim/vimfiles/syntax/ruby.vim ~
|
||||
|
||||
Existing files are overwritten. This is safe, because it's a slow-maturing
|
||||
project, so new files are better than old ones. However, if you had edited the
|
||||
files, you will have lost your changes. Better make your changes in, for
|
||||
instance:
|
||||
|
||||
~/.vim/after/ftplugin/ruby.vim ~
|
||||
|
||||
This file will be loaded _after_ the regular config files are loaded, so your
|
||||
customisations will definitely take effect.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* What Vim config do I need? *vim-ruby-config*
|
||||
|
||||
Without the following lines in your .vimrc, _vimrc, or other startup file, the
|
||||
files in the vim-ruby project will be largely useless. >
|
||||
|
||||
set nocompatible " We're running Vim, not Vi!
|
||||
syntax on " Enable syntax highlighting
|
||||
filetype on " Enable filetype detection
|
||||
filetype indent on " Enable filetype-specific indenting
|
||||
filetype plugin on " Enable filetype-specific plugins
|
||||
compiler ruby " Enable compiler support for ruby
|
||||
|
||||
See |.vimrc| for more information about this important Vim configuration file.
|
||||
|
||||
See |matchit-install| for instructions on installing "matchit", which will
|
||||
allow you to use |%| to bounce between Ruby keywords (class, def, while, ...)
|
||||
and their respective "end" keywords.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* How do I know that everything's working?
|
||||
|
||||
If you've run the installer and added the configuration |vim-ruby-config|
|
||||
above, everything should be fine when you restart Vim. To test this:
|
||||
- Edit a Ruby file with Vim (make sure it has a .rb extension).
|
||||
- The code should be syntax highlighted.
|
||||
- Type in some code. When you start a new line, it should be automatically
|
||||
indented to the correct spot.
|
||||
- Add or remove some space from the beginning of a line of code and hit ==.
|
||||
That line should be reindented.
|
||||
- Put the cursor on a "class" or "def" keyword and hit %. The cursor should
|
||||
now be on the matching "end" keyword.
|
||||
- TODO: what else?
|
||||
|
||||
|
||||
*vim-ruby-faq-X* How do I use it?
|
||||
|
||||
TODO: write.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* How do I customise it? *vim-ruby-customize*
|
||||
|
||||
The most important customisation for editing Ruby code is the amount of space to
|
||||
indent. The following is a typical setup. Look up the various options to read
|
||||
about them. >
|
||||
|
||||
set expandtab
|
||||
set tabstop=2 shiftwidth=2 softtabstop=2
|
||||
set autoindent
|
||||
|
||||
TODO: is autoindent necessary? What other options should go here? What about
|
||||
Ruby comments?
|
||||
FIXME: Autoindent is good. maybe mention |i_CTRL_D| and |i_CTRL_T| for
|
||||
moving lines about in this context?
|
||||
COMMENT: I never use ^D and ^T in insert mode, though I always knew what they
|
||||
do. Might try them!
|
||||
|
||||
|
||||
*vim-ruby-faq-X* I want feature X. Will you include it?
|
||||
|
||||
The idea of the vim-ruby project is to maintain configuration files that are
|
||||
actually distributed with Vim. Therefore all functionality should be helpful to
|
||||
all Vim/Ruby users. So the project does not deal with people's individual
|
||||
tastes.
|
||||
|
||||
That said, we are considering creating a separate configuration file for less
|
||||
universal features, whose features users can pick and choose. So don't hesitate
|
||||
to send us your suggestions.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* What are some other cool Ruby-related Vim tricks I can use?
|
||||
|
||||
An example is the following (put it in ~/.vimrc/ftplugin/ruby_extra.vim or
|
||||
similar): [similar? |$VIMRUNTIME| or what?] >
|
||||
|
||||
if !exists( "*EndToken" )
|
||||
function EndToken()
|
||||
let current_line = getline( '.' )
|
||||
let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$'
|
||||
if match( current_line, braces_at_end ) >= 0
|
||||
return '}'
|
||||
else
|
||||
return 'end'
|
||||
endif
|
||||
endfunction
|
||||
endif
|
||||
|
||||
imap <S-CR> <ESC>:execute 'normal o' . EndToken()<CR>O
|
||||
|
||||
This will help you create ruby blocks of code, by inserting "}" or "end" as
|
||||
appropriate. Try creating these lines of code and hitting SHIFT-ENTER:
|
||||
|
||||
array.map { |elem| ~
|
||||
|
||||
def fibonacci(n) ~
|
||||
|
||||
For other suggestions, search the web or look at: >
|
||||
|
||||
https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport
|
||||
|
||||
|
||||
*vim-ruby-faq-X* How can I report a bug? *vim-ruby-bug-reporting*
|
||||
|
||||
Bug reports are most welcome. In order of preference:
|
||||
- submit a bug at https://github.com/vim-ruby/vim-ruby/issues
|
||||
- send an email to the mailing list (see below)
|
||||
- email the maintainer (email address appears in each configuration file)
|
||||
|
||||
|
||||
*vim-ruby-list*
|
||||
*vim-ruby-faq-X* Does the project have a mailing list?
|
||||
|
||||
Yes: vim-ruby-devel@rubyforge.org. Only subscribers can post. To join, visit:
|
||||
>
|
||||
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
|
||||
|
||||
The list is mirrored at: >
|
||||
|
||||
http://news.gmane.org/gmane.comp.editors.vim.vim%2druby.devel
|
||||
|
||||
|
||||
*vim-ruby-faq-X* Why is this project separate from Vim?
|
||||
|
||||
We can't use Vim's CVS to keep track of these files, so we organise it ourselves
|
||||
and give Bram the latest files in time for each release of Vim. By keeping the
|
||||
Ruby stuff together, we can release it all at once and people can update it
|
||||
independently of Vim.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* I have another question...
|
||||
|
||||
The mailing list or the file maintainer is a good place to ask. Or perhaps
|
||||
comp.lang.ruby, but please make sure you've read the FAQ thoroughly before
|
||||
asking there.
|
||||
|
||||
|
||||
*vim-ruby-faq-X* Can you repeat all the web pages listed in this FAQ?
|
||||
|
||||
Homepage *vim-ruby-homepage* : >
|
||||
https://github.com/vim-ruby/vim-ruby/
|
||||
|
||||
Bug tracker: >
|
||||
https://github.com/vim-ruby/vim-ruby/issues
|
||||
|
||||
Relevant Wiki page: >
|
||||
https://github.com/vim-ruby/vim-ruby/wiki
|
||||
|
||||
Mailing list archives: >
|
||||
http://news.gmane.org/gmane.comp.editors.vim.vim%2druby.devel
|
||||
http://rubyforge.org/pipermail/vim-ruby-devel/
|
||||
|
||||
Mailing list join: >
|
||||
http://rubyforge.org/mailman/listinfo/vim-ruby-devel
|
||||
|
||||
|
||||
vim: ft=help tw=78 noet :
|
4
sources_non_forked/vim-ruby/Gemfile
Normal file
4
sources_non_forked/vim-ruby/Gemfile
Normal file
@ -0,0 +1,4 @@
|
||||
source 'http://rubygems.org'
|
||||
|
||||
gem 'rspec'
|
||||
gem 'vimrunner'
|
20
sources_non_forked/vim-ruby/Gemfile.lock
Normal file
20
sources_non_forked/vim-ruby/Gemfile.lock
Normal file
@ -0,0 +1,20 @@
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
diff-lcs (1.1.3)
|
||||
rspec (2.11.0)
|
||||
rspec-core (~> 2.11.0)
|
||||
rspec-expectations (~> 2.11.0)
|
||||
rspec-mocks (~> 2.11.0)
|
||||
rspec-core (2.11.1)
|
||||
rspec-expectations (2.11.2)
|
||||
diff-lcs (~> 1.1.3)
|
||||
rspec-mocks (2.11.2)
|
||||
vimrunner (0.1.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
rspec
|
||||
vimrunner
|
36
sources_non_forked/vim-ruby/INSTALL.markdown
Normal file
36
sources_non_forked/vim-ruby/INSTALL.markdown
Normal file
@ -0,0 +1,36 @@
|
||||
Installation
|
||||
============
|
||||
|
||||
In general, your favorite method works. Here are some options.
|
||||
|
||||
With pathogen.vim
|
||||
-----------------
|
||||
|
||||
Install [pathogen.vim](https://github.com/tpope/vim-pathogen),
|
||||
then copy and paste:
|
||||
|
||||
git clone git://github.com/vim-ruby/vim-ruby.git ~/.vim/bundle/vim-ruby
|
||||
|
||||
With Vundle
|
||||
-----------
|
||||
|
||||
Install [Vundle](https://github.com/gmarik/vundle), then add the
|
||||
following to your vimrc:
|
||||
|
||||
Bundle 'vim-ruby/vim-ruby'
|
||||
|
||||
With patience
|
||||
-------------
|
||||
|
||||
Wait for an upgrade to Vim and install it. Vim ships with the latest
|
||||
version of vim-ruby at the time of its release. (Remember this when
|
||||
choosing another installation method. The version you download will
|
||||
supersede the version that ships with Vim, so you will now be
|
||||
responsible for keeping it up-to-date.)
|
||||
|
||||
Manually
|
||||
--------
|
||||
|
||||
[Download](https://github.com/vim-ruby/vim-ruby/archives/master) and
|
||||
extract an archive, and run `bin/vim-ruby-install.rb` to copy the
|
||||
relevant files to `~/.vim`.
|
243
sources_non_forked/vim-ruby/NEWS
Normal file
243
sources_non_forked/vim-ruby/NEWS
Normal file
@ -0,0 +1,243 @@
|
||||
This file is no longer maintained. Consult the Git log for newer changes.
|
||||
|
||||
= 2008.07.XX
|
||||
|
||||
== Filetype Detection
|
||||
|
||||
The IRB RC file (.irbrc) is now detected as being a Ruby file.
|
||||
|
||||
|
||||
= 2007.05.07
|
||||
|
||||
== Ruby Syntax Highlighting
|
||||
|
||||
Highlight OPTIMIZE alongside FIXME and TODO.
|
||||
|
||||
Multiline array literals can now be folded.
|
||||
|
||||
== Ruby Filetype Support
|
||||
|
||||
Added mappings for [[, ]], [], ][, [m, ]m, [M, and ]M. The first four bounce
|
||||
between class and module declarations, and the last four between method
|
||||
declarations.
|
||||
|
||||
== eRuby Syntax Highlighting
|
||||
|
||||
Tim Pope has taken over maintenance of the eRuby syntax file. The subtype of
|
||||
the file is now determined dynamically from the filename, rather than being
|
||||
hardwired to HTML. It can be overridden with b:eruby_subtype.
|
||||
|
||||
== eRuby Filetype Support
|
||||
|
||||
Tim Pope has taken over maintenance of the eRuby filetype plugin. Like with
|
||||
the syntax file, the subtype is now determined dynamically.
|
||||
|
||||
== eRuby Indenting
|
||||
|
||||
As with the syntax file and filetype plugin, the subtype is now determined
|
||||
dynamically.
|
||||
|
||||
== Bug Fixes
|
||||
|
||||
Ruby syntax file
|
||||
- when ruby_operators is set, highlight scope and range operators, and don't
|
||||
match '>' in =>'
|
||||
- regexp literals are highlighted after the 'else' keyword
|
||||
- don't match [!=?] as part of a sigil prefixed symbol name
|
||||
- allow text to appear after, and on the same line, as '=begin' in
|
||||
rubyDocumentation regions
|
||||
- highlight %s() ans a symbol, not a string
|
||||
- eliminated some false positves for here docs, symbols, ASCII codes, and
|
||||
conditionals as statement modifiers
|
||||
- added "neus" to regexp flags
|
||||
- Highlight punctuation variables in string interpolation, and flag invalid
|
||||
ones as errors
|
||||
- removed : from rubyOptionalDoLine (falsely matches on symbols)
|
||||
|
||||
Ruby filetype plugin
|
||||
- eliminated some false positives with the matchit patterns
|
||||
|
||||
Ruby indent plugin
|
||||
- ignore instance, class, and global variables named "end"
|
||||
|
||||
|
||||
= 2007.03.02
|
||||
|
||||
== Omni Completion
|
||||
|
||||
Fall back to syntax highlighting completion if Vim lacks the Ruby interface.
|
||||
|
||||
RubyGems is now loaded by default if available.
|
||||
|
||||
Classes are detected using ObjectSpace. Kernel methods are included in method
|
||||
completion.
|
||||
|
||||
Added completion in Rails views. Rails helpers are included. Rails migrations
|
||||
now have completion.
|
||||
|
||||
== Ruby Syntax Highlighting
|
||||
|
||||
Ruby code is highlighted inside interpolation regions.
|
||||
|
||||
Symbols are now highlighted with the Constant highlight group; Constants and
|
||||
class names with the Type highlight group.
|
||||
|
||||
Symbol names specified with a string recognise interpolation and escape
|
||||
sequences.
|
||||
|
||||
Alias statements receive special highlighting similar to other 'definitions'.
|
||||
|
||||
== Ruby Filetype Support
|
||||
|
||||
Matchit support has been improved to include (), {}, and [] in the list of
|
||||
patterns so that these will be appropriately skipped when included in comments.
|
||||
|
||||
ri has been added as the 'keywordprg' and 'balloonexpr' is set to return the
|
||||
output of ri.
|
||||
|
||||
== eRuby Indenting
|
||||
|
||||
Tim Pope has taken over maintenance of the eRuby indent file. Ruby code is now
|
||||
indented appropriately.
|
||||
|
||||
== Bug Fixes
|
||||
|
||||
Ruby syntax file
|
||||
- trailing whitespace is no longer included with the def, class, module
|
||||
keywords.
|
||||
- escaped interpolation regions should now be ignored in all cases.
|
||||
- conditional and loop statements are now highlighted correctly in more
|
||||
locations (where they're used as expressions).
|
||||
|
||||
eRuby syntax file
|
||||
- '-' trim mode block delimiters are now recognised.
|
||||
|
||||
Omni Completion
|
||||
- more robustness; failure to parse buffer no longer errors or prevents
|
||||
completion.
|
||||
|
||||
|
||||
= 2006.07.11
|
||||
|
||||
== Omni Completion
|
||||
|
||||
A new omni completion function is now included which offers IntelliSense-like
|
||||
functionality. See :help ft-ruby-omni for further information.
|
||||
|
||||
Note: This will only work with Vim 7.x, compiled with the Ruby interface
|
||||
(+ruby), and Ruby 1.8.x
|
||||
|
||||
== Ruby Filetype Support
|
||||
|
||||
Matchit support has been improved to include (), {}, and [] in the list of
|
||||
patterns meaning these will be appropriately skipped when included in comments.
|
||||
|
||||
== Ruby Syntax Highlighting
|
||||
|
||||
Operators can now be highlighted by defining the Vim global variable
|
||||
"ruby_operators".
|
||||
|
||||
Multiline comments will now be folded. This can be disabled by defining the
|
||||
"ruby_no_comment_fold" Vim variable.
|
||||
|
||||
== Filetype Detection
|
||||
|
||||
RJS and RXML templates are now detected as being 'filetype=ruby'.
|
||||
|
||||
== FAQ
|
||||
|
||||
There is a new FAQ document included. This is a work in progress and any
|
||||
feedback would be appreciated.
|
||||
|
||||
== Bug Fixes
|
||||
|
||||
Ruby syntax file - if/unless modifiers after a method name ending with [?!=]
|
||||
should now be highlighted correctly.
|
||||
|
||||
|
||||
= 2005.10.07
|
||||
|
||||
== Vim 6.4
|
||||
|
||||
This release is included in Vim 6.4.
|
||||
|
||||
== Bug Fixes
|
||||
|
||||
Ruby filetype plugin - symbols were incorrectly being matched as match_words
|
||||
causing the matchit motion command to jump to an incorrect location in some
|
||||
circumstances.
|
||||
|
||||
|
||||
= 2005.10.05
|
||||
|
||||
== Bug Fixes
|
||||
|
||||
Ruby syntax file - allow for comments directly after module/class/def lines
|
||||
without intervening whitespace (fold markers were breaking syntax highlighting).
|
||||
|
||||
Ruby filetype plugin - improve ordering of 'path' elements.
|
||||
|
||||
eRuby syntax file - make use of ruby_no_expensive local to the buffer.
|
||||
|
||||
|
||||
= 2005.09.24
|
||||
|
||||
== Filetype Detection
|
||||
|
||||
The eruby filetype is now detected solely based on the file's extension. This
|
||||
was being overridden by the scripts.vim detection script.
|
||||
|
||||
Note: Only files ending in *.rhtml are detected as filetype eruby since these
|
||||
are currently assumed to be Ruby embedded in (X)HTML only. Other filetypes
|
||||
could be supported if requested.
|
||||
|
||||
== eRuby Indent File
|
||||
|
||||
There is a new eRuby indent file which simply sources the HTML indent file for
|
||||
now.
|
||||
|
||||
== eRuby Compiler Plugin
|
||||
|
||||
This now supports erb as the default 'makeprg'. To use eruby set the
|
||||
eruby_compiler variable to "eruby" in your .vimrc
|
||||
|
||||
== Test::Unit Compiler Plugin
|
||||
|
||||
This has been improved and should now display messages similar to, though more
|
||||
detailed than, the GUI test runners.
|
||||
|
||||
== Bug Fixes
|
||||
|
||||
A few minor bugs have been fixed in the Ruby syntax and indent files.
|
||||
|
||||
|
||||
= 2005.09.15
|
||||
|
||||
== eRuby Support
|
||||
|
||||
There are new syntax, compiler, and ftplugin files for eRuby. This support is
|
||||
incomplete and we're keen to hear of any problems or suggestions you may have
|
||||
to improve it.
|
||||
|
||||
== Ruby Filetype Support
|
||||
|
||||
The Ruby filetype plugin has been improved to include as many useful settings
|
||||
as possible without intruding too much on an individual user's preferences.
|
||||
Matchit support has been improved, and the following options are now set to
|
||||
appropriate values: comments, commentstring, formatoptions, include,
|
||||
includeexpr, path, and suffixesadd
|
||||
|
||||
== Filetype Detection
|
||||
|
||||
The new ftdetect mechanism of Vim 6.3 is being utilized to enable filetype
|
||||
detection of eRuby files until this is officially added to the next release of
|
||||
Vim.
|
||||
|
||||
== Installation Directories
|
||||
|
||||
The installer script now, where possible, automatically determines both the
|
||||
user and system-wide preferences directory.
|
||||
|
||||
== Bug Fixes
|
||||
|
||||
A large number of bugs have been fixed in the Ruby syntax and indent files.
|
74
sources_non_forked/vim-ruby/README
Normal file
74
sources_non_forked/vim-ruby/README
Normal file
@ -0,0 +1,74 @@
|
||||
+---------------------------------+
|
||||
| vim-ruby github 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: https://github.com/vim-ruby
|
||||
Explanation: https://github.com/vim-ruby/vim-ruby/wiki
|
||||
|
||||
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 github.
|
||||
- Feel free to join discussions on the vim-ruby-devel mailing list:
|
||||
http://rubyforge.org/mail/?group_id=16
|
||||
|
||||
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
|
||||
github is to get the latest version of them.
|
||||
|
||||
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 release coordinator, Doug Kearns
|
||||
(dougkearns at gmail.com).
|
||||
- To ask about the contents of the configuration files, open a GitHub issue
|
||||
or ask on the mailing list, as different people maintain the different
|
||||
files.
|
||||
|
||||
Project gossip:
|
||||
- While the individual effort to maintain these files has a long history,
|
||||
this actual project began in late July 2003.
|
||||
|
||||
--= End of Document =--
|
42
sources_non_forked/vim-ruby/Rakefile
Normal file
42
sources_non_forked/vim-ruby/Rakefile
Normal file
@ -0,0 +1,42 @@
|
||||
require 'rubygems'
|
||||
require 'rake/gempackagetask'
|
||||
|
||||
PACKAGE_NAME = 'vim-ruby'
|
||||
RELEASE_FILES = FileList[
|
||||
'ChangeLog', 'CONTRIBUTORS', 'FAQ', 'INSTALL', 'NEWS', 'README', 'bin/*.rb',
|
||||
'doc/*.txt','{autoload,compiler,ftdetect,ftplugin,indent,syntax}/*.vim'
|
||||
]
|
||||
PACKAGE_VERSION = Time.now.gmtime.strftime('%Y.%m.%d')
|
||||
|
||||
desc "Build all the packages"
|
||||
task :default => :package
|
||||
|
||||
|
||||
def gemspec
|
||||
Gem::Specification.new do |s|
|
||||
s.name = PACKAGE_NAME
|
||||
s.version = PACKAGE_VERSION
|
||||
s.files = RELEASE_FILES.to_a
|
||||
s.summary = "Ruby configuration files for Vim. Run 'vim-ruby-install.rb' to complete installation."
|
||||
s.description = s.summary + "\n\nThis package doesn't contain a Ruby library."
|
||||
s.requirements << 'RubyGems 0.8+' << 'Vim 6.0+'
|
||||
s.required_ruby_version = '>= 1.8.0'
|
||||
s.require_path = '.'
|
||||
s.bindir = 'bin'
|
||||
s.executables = ['vim-ruby-install.rb']
|
||||
s.author = 'Gavin Sinclair et al.'
|
||||
s.email = 'gsinclair@soyabean.com.au'
|
||||
s.homepage = 'https://github.com/vim-ruby/vim-ruby'
|
||||
s.has_rdoc = false
|
||||
end
|
||||
end
|
||||
|
||||
Rake::GemPackageTask.new(gemspec) do |t|
|
||||
t.package_dir = 'etc/package'
|
||||
t.need_tar = true
|
||||
t.need_zip = true
|
||||
end
|
||||
|
||||
# Supporting methods
|
||||
|
||||
# vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
|
805
sources_non_forked/vim-ruby/autoload/rubycomplete.vim
Normal file
805
sources_non_forked/vim-ruby/autoload/rubycomplete.vim
Normal file
@ -0,0 +1,805 @@
|
||||
" 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*\<' . 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 = ''.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_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
|
||||
|
||||
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:
|
455
sources_non_forked/vim-ruby/bin/vim-ruby-install.rb
Executable file
455
sources_non_forked/vim-ruby/bin/vim-ruby-install.rb
Executable file
@ -0,0 +1,455 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# vim-ruby-install: install the Vim config files for Ruby editing
|
||||
#
|
||||
# * scope out the target directory and get user to confirm
|
||||
# * if no directory found, ask user
|
||||
# * allow user to force a search for a Windows gvim installation
|
||||
# * find source files from gem or from top level directory
|
||||
# * copy to target directory, taking account of
|
||||
# * line endings (NL for Unix-ish; CRLF for Windows)
|
||||
# * permissions (755 for directories; 644 for files)
|
||||
#
|
||||
|
||||
require 'rbconfig'
|
||||
include RbConfig
|
||||
require 'fileutils'
|
||||
require 'optparse'
|
||||
require 'pathname'
|
||||
|
||||
SOURCE_FILES = %w{
|
||||
autoload/rubycomplete.vim
|
||||
compiler/eruby.vim
|
||||
compiler/rspec.vim
|
||||
compiler/ruby.vim
|
||||
compiler/rubyunit.vim
|
||||
ftdetect/ruby.vim
|
||||
ftplugin/eruby.vim
|
||||
ftplugin/ruby.vim
|
||||
indent/eruby.vim
|
||||
indent/ruby.vim
|
||||
syntax/eruby.vim
|
||||
syntax/ruby.vim
|
||||
}
|
||||
|
||||
#
|
||||
# Miscellaneous functions in the user's environment.
|
||||
#
|
||||
class Env
|
||||
#
|
||||
# Returns :UNIX or :WINDOWS, according to CONFIG['host_os'] and $options[:windows].
|
||||
#
|
||||
def Env.determine_target_os
|
||||
os = CONFIG['host_os']
|
||||
if os =~ /mswin/ or $options[:windows]
|
||||
return :WINDOWS
|
||||
else
|
||||
return :UNIX
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the path to the directory where the vim configuration files will be copied from.
|
||||
# The first preference is the directory above this script. If that fails, we look for the
|
||||
# RubyGems package 'vim-ruby'. Failing that, we return +nil+.
|
||||
#
|
||||
def Env.determine_source_directory
|
||||
# 1. Try the directory above this installation script.
|
||||
vim_ruby_source_dir = File.expand_path(File.join(File.dirname($0), '..'))
|
||||
return vim_ruby_source_dir if _valid_vim_ruby_dir(vim_ruby_source_dir)
|
||||
# 2. Try the gem 'vim-ruby'.
|
||||
begin
|
||||
require 'rubygems'
|
||||
raise "Need RubyGems 0.8+" if Gem::RubyGemsPackageVersion < '0.8'
|
||||
rescue LoadError
|
||||
return nil
|
||||
end
|
||||
#vim_ruby_gem_dir = Gem.latest_load_paths.grep(%r{gems/vim-ruby-\d{4}\.\d{2}\.\d{2}}).last
|
||||
vim_ruby_gem_dir = Gem.all_load_paths.grep(%r{gems/vim-ruby-\d{4}\.\d{2}\.\d{2}}).sort.last
|
||||
if vim_ruby_gem_dir and _valid_vim_ruby_dir(vim_ruby_gem_dir)
|
||||
return vim_ruby_gem_dir
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
# Returns the Vim installation directory ($VIM).
|
||||
# TODO: print warning if vim command not in PATH or appropriate key not in registry?
|
||||
def Env.determine_vim_dir
|
||||
installation_dir = ENV['VIM'] ||
|
||||
case Env.determine_target_os
|
||||
when :UNIX
|
||||
IO.popen('vim --version 2>/dev/null') do |version|
|
||||
dir = version.read[/fall-back for \$VIM: "(.*)"/, 1]
|
||||
end
|
||||
when :WINDOWS
|
||||
begin
|
||||
require 'win32/registry'
|
||||
Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\Vim\Gvim') do |reg|
|
||||
path = reg['path', Win32::Registry::REG_SZ]
|
||||
dir = path.sub(/\\vim\d\d\\gvim.exe/i, '')
|
||||
end
|
||||
rescue Win32::Registry::Error
|
||||
nil
|
||||
end
|
||||
end
|
||||
return installation_dir
|
||||
end
|
||||
|
||||
def Env.determine_home_dir
|
||||
home_dir = ENV['HOME'] ||
|
||||
case Env.determine_target_os
|
||||
when :WINDOWS
|
||||
ENV['HOMEDRIVE'] + ENV['HOMEPATH'] if ENV['HOMEDRIVE'] and ENV['HOMEPATH']
|
||||
end
|
||||
return home_dir
|
||||
end
|
||||
|
||||
def Env.ask_user(message)
|
||||
print message
|
||||
gets.strip
|
||||
end
|
||||
|
||||
private_class_method
|
||||
|
||||
def Env._valid_vim_ruby_dir(dir)
|
||||
Dir.chdir(dir) do
|
||||
return SOURCE_FILES.all? { |path| FileTest.file?(path) }
|
||||
end
|
||||
end
|
||||
|
||||
end # class Env
|
||||
|
||||
|
||||
#
|
||||
# A FileWriter writes files with pre-selected line endings and permissions.
|
||||
#
|
||||
# writer = FileWriter.new(:UNIX, 0664)
|
||||
# writer.copy(source, target)
|
||||
#
|
||||
class FileWriter
|
||||
LINE_ENDINGS = { :UNIX => "\n", :WINDOWS => "\r\n" }
|
||||
|
||||
def initialize(ending, file_permissions=0644, directory_permissions=0755)
|
||||
@ending = LINE_ENDINGS[ending] or raise "No/invalid line ending given: #{ending}"
|
||||
@permissions = {
|
||||
:file => file_permissions,
|
||||
:dir => directory_permissions
|
||||
}
|
||||
end
|
||||
|
||||
# Source and target paths assumed to be Pathname objects. Copy the source to the target,
|
||||
# ensuring the right line endings.
|
||||
def copy(source_path, target_path)
|
||||
_ensure_directory_exists(target_path)
|
||||
target_path.open('wb', @permissions[:file]) do |io|
|
||||
lines = source_path.read.split("\n")
|
||||
lines.each do |line|
|
||||
io.write(line.chomp + @ending)
|
||||
end
|
||||
end
|
||||
puts "#{source_path.to_s.ljust(25)} -> #{target_path}"
|
||||
end
|
||||
|
||||
# Create the given directory with the correct directory permissions.
|
||||
def mkpath(directory)
|
||||
FileUtils.mkdir_p(directory.to_s, :mode => @permissions[:dir], :verbose => true)
|
||||
end
|
||||
|
||||
def _ensure_directory_exists(path)
|
||||
dir = path.dirname
|
||||
unless dir.directory?
|
||||
# <XXX> FileUtils.mkdir_p already checks if it exists and is a
|
||||
# directory. What if it exists as a file? (HGS)</XXX>
|
||||
mkpath(dir)
|
||||
end
|
||||
end
|
||||
end # class FileWriter
|
||||
|
||||
#
|
||||
# Represents the target base directory for installs. Handles writing the files through a
|
||||
# given FileWriter.
|
||||
#
|
||||
class TargetDirectory
|
||||
def self.finder
|
||||
TargetDirectory::Finder.new
|
||||
end
|
||||
|
||||
def initialize(directory, writer)
|
||||
@directory = Pathname.new(directory)
|
||||
@writer = writer # FileWriter
|
||||
end
|
||||
|
||||
# Copies the given relative path from the current directory to the target.
|
||||
def copy(path)
|
||||
source_path = Pathname.new(path)
|
||||
target_path = @directory + path
|
||||
@writer.copy(source_path, target_path)
|
||||
end
|
||||
|
||||
def [](path)
|
||||
@directory + path
|
||||
end
|
||||
|
||||
def path
|
||||
@directory
|
||||
end
|
||||
end # class TargetDirectory
|
||||
|
||||
#
|
||||
# Represents the target directory. Can find candidates, based on the operating system and
|
||||
# user options; but is ultimately created with one in mind.
|
||||
#
|
||||
class TargetDirectory::Finder
|
||||
# Guides the user through a selection process, ending in a chosen directory.
|
||||
def find_target_directory
|
||||
# 1. Was a directory specified using the --directory option?
|
||||
if option_dir = $options[:target_dir]
|
||||
return option_dir
|
||||
end
|
||||
# 2. Try the potentials (if there are any).
|
||||
if dirs = _potential_directories and not dirs.empty?
|
||||
puts
|
||||
puts "Possible Vim installation directories:"
|
||||
dirs.each_with_index do |dir, idx|
|
||||
puts " #{idx+1}) #{dir}"
|
||||
end
|
||||
puts
|
||||
r = Env.ask_user "Please select one (or anything else to specify another directory): "
|
||||
if (1..dirs.size).include? r.to_i
|
||||
chosen_directory = dirs[r.to_i - 1]
|
||||
return chosen_directory
|
||||
end
|
||||
end
|
||||
# 3. We didn't find any, or the user wants to enter another.
|
||||
if dirs.empty?
|
||||
puts
|
||||
puts "Couldn't find any Vim installation directories."
|
||||
end
|
||||
entered_directory = Env.ask_user "Please enter the full path to your Vim installation directory: "
|
||||
entered_directory = File.expand_path(entered_directory)
|
||||
return entered_directory
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Return an array of _potential_ directories (i.e. they exist). Take the options into
|
||||
# account.
|
||||
def _potential_directories
|
||||
dirs = []
|
||||
dirs << _vim_user_dir
|
||||
dirs << _vim_system_dir
|
||||
return dirs.compact.map { |dir| File.expand_path(dir) }
|
||||
end
|
||||
|
||||
# Return the Vim system preferences directory
|
||||
def _vim_system_dir
|
||||
vim_dir = Env.determine_vim_dir
|
||||
system_dir = vim_dir + "/vimfiles" if vim_dir
|
||||
return system_dir
|
||||
end
|
||||
|
||||
# Return the Vim user preferences directory
|
||||
def _vim_user_dir
|
||||
platform_dir = { :UNIX => "/.vim", :WINDOWS => "/vimfiles" }
|
||||
home_dir = Env.determine_home_dir
|
||||
user_dir = home_dir + platform_dir[Env.determine_target_os] if home_dir
|
||||
return user_dir
|
||||
end
|
||||
end # class TargetDirectory::Finder
|
||||
|
||||
#
|
||||
# VimRubyInstaller is the class that copies the files from the source directory to the target
|
||||
# directory, both of which are provided.
|
||||
#
|
||||
class VimRubyInstaller
|
||||
# +source+ and +target+ are the base directories from and to which the configuration files
|
||||
# will be copied. Both are strings.
|
||||
def initialize(source, target)
|
||||
unless FileTest.directory?(source)
|
||||
raise "Automatically determined source directory ('#{source}') doesn't exist"
|
||||
end
|
||||
unless FileTest.directory?(target)
|
||||
raise "Chosen target directory ('#{target}') doesn't exist"
|
||||
end
|
||||
@source_dir = source
|
||||
file_writer = FileWriter.new(Env.determine_target_os)
|
||||
@target_dir = TargetDirectory.new(target, file_writer)
|
||||
end
|
||||
|
||||
# Since we know the source and target directories, all we have to do is copy the files
|
||||
# across. If the --backup option was specified or the target file is
|
||||
# _newer_ than the source file, we make a backup of it and report that to
|
||||
# the user.
|
||||
def install
|
||||
backupdir = BackupDir.new("./vim-ruby-backup.#{Process.pid}")
|
||||
Dir.chdir(@source_dir) do
|
||||
SOURCE_FILES.each do |path|
|
||||
source_path = Pathname.new(path)
|
||||
target_path = @target_dir[path]
|
||||
# FIXME: Backup everything for now
|
||||
if $options[:backup] and target_path.file?
|
||||
backupdir.backup(@target_dir, path)
|
||||
elsif target_path.file? and target_path.mtime > source_path.mtime
|
||||
# We're going to overwrite a newer file; back it up, unless they're the same.
|
||||
unless _same_contents?(target_path, source_path)
|
||||
backupdir.backup(@target_dir, path)
|
||||
end
|
||||
end
|
||||
@target_dir.copy(path)
|
||||
end
|
||||
end
|
||||
backups = backupdir.contents
|
||||
unless backups.empty?
|
||||
puts
|
||||
puts "The following backups were made:"
|
||||
backups.each do |path|
|
||||
puts " * #{path}"
|
||||
end
|
||||
puts
|
||||
puts "These backups are located in this directory: #{backupdir.path}"
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Test two files for equality of contents, ignoring line endings.
|
||||
def _same_contents?(p1, p2)
|
||||
contents1 = p1.read.split("\n").map { |line| line.chomp }
|
||||
contents2 = p2.read.split("\n").map { |line| line.chomp }
|
||||
contents1 == contents2
|
||||
end
|
||||
|
||||
# A directory for holding backups of configuration files.
|
||||
class BackupDir
|
||||
def initialize(path)
|
||||
@base = Pathname.new(path).expand_path
|
||||
end
|
||||
|
||||
# Copy basedir/path to @path/path.
|
||||
def backup(basedir, path)
|
||||
@base.mkpath unless @base.directory?
|
||||
source = basedir.path + path
|
||||
target = @base + path
|
||||
target.dirname.mkpath
|
||||
FileUtils.cp(source.to_s, target.dirname.to_s, :verbose => true)
|
||||
end
|
||||
|
||||
def [](path)
|
||||
@base + path
|
||||
end
|
||||
|
||||
def contents
|
||||
return [] unless @base.directory?
|
||||
results = []
|
||||
Dir.chdir(@base) do
|
||||
Pathname.new('.').find do |path|
|
||||
results << path if path.file?
|
||||
end
|
||||
end
|
||||
results
|
||||
end
|
||||
|
||||
def path
|
||||
@base
|
||||
end
|
||||
end # class VimRubyInstaller::BackupDir
|
||||
end # class VimRubyInstaller
|
||||
|
||||
#
|
||||
# * * * M A I N * * *
|
||||
#
|
||||
|
||||
begin
|
||||
$options = {
|
||||
:backup => false,
|
||||
:target_dir => nil,
|
||||
:windows => false
|
||||
}
|
||||
|
||||
op = OptionParser.new do |p|
|
||||
p.banner = %{
|
||||
vim-ruby-install.rb: Install the vim-ruby configuration files
|
||||
|
||||
About:
|
||||
* Detects the Vim user and system-wide preferences directories
|
||||
* User to confirm before proceeding
|
||||
* User may specify other directory
|
||||
* Takes config files from current directory or from vim-ruby gem
|
||||
* Writes files with correct permissions and line endings
|
||||
|
||||
Usage:
|
||||
direct: ruby bin/vim-ruby-install.rb [options]
|
||||
gem: vim-ruby-install.rb [options]
|
||||
|
||||
Options:
|
||||
}.gsub(/^ /, '')
|
||||
p.on('-b', '--backup', 'Backup existing runtime files') do |value|
|
||||
$options[:backup] = value
|
||||
end
|
||||
p.on('-d DIR', '--directory', 'Install into given directory') do |dir|
|
||||
$options[:target_dir] = dir
|
||||
end
|
||||
p.on('-w', '--windows', 'Install into Windows directories') do |value|
|
||||
$options[:windows] = value
|
||||
end
|
||||
p.on('-h', '--help', 'Show this message') do
|
||||
puts p
|
||||
exit
|
||||
end
|
||||
p.on_tail %{
|
||||
Notes:
|
||||
|
||||
* "Direct" usage means unpacking a vim-ruby tarball and running this
|
||||
program from the vim-ruby directory.
|
||||
|
||||
* The convenient alternative is to use RubyGems:
|
||||
gem install vim-ruby
|
||||
vim-ruby-install.rb
|
||||
|
||||
* The --windows option is designed for forcing an install into the
|
||||
Windows (gvim) configuration directory; useful when running from
|
||||
Cygwin or MinGW.
|
||||
|
||||
* This installer is quite new (2004-09-20). Please report bugs to
|
||||
gsinclair@soyabean.com.au.
|
||||
}.gsub(/^ /, '')
|
||||
end
|
||||
op.parse!(ARGV)
|
||||
|
||||
if not ARGV.empty?
|
||||
raise "invalid argument: #{ARGV[0]}"
|
||||
end
|
||||
|
||||
source_dir = Env.determine_source_directory
|
||||
if source_dir.nil?
|
||||
raise "Can't find source directory."
|
||||
end
|
||||
|
||||
target_dir = TargetDirectory.finder.find_target_directory
|
||||
if not File.directory?(target_dir)
|
||||
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
|
||||
puts
|
||||
puts "Installation aborted."
|
||||
exit
|
||||
end
|
||||
end
|
||||
|
||||
VimRubyInstaller.new(source_dir, target_dir).install
|
||||
|
||||
rescue
|
||||
|
||||
raise if $DEBUG
|
||||
$stderr.puts
|
||||
$stderr.puts $!.message
|
||||
$stderr.puts "Try 'ruby #{$0} --help' for detailed usage."
|
||||
exit 1
|
||||
|
||||
end
|
||||
|
||||
# vim: nowrap sw=2 sts=2 ts=8 ff=unix ft=ruby:
|
39
sources_non_forked/vim-ruby/compiler/eruby.vim
Normal file
39
sources_non_forked/vim-ruby/compiler/eruby.vim
Normal file
@ -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:
|
35
sources_non_forked/vim-ruby/compiler/rake.vim
Normal file
35
sources_non_forked/vim-ruby/compiler/rake.vim
Normal file
@ -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:
|
33
sources_non_forked/vim-ruby/compiler/rspec.vim
Normal file
33
sources_non_forked/vim-ruby/compiler/rspec.vim
Normal file
@ -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:
|
45
sources_non_forked/vim-ruby/compiler/ruby.vim
Normal file
45
sources_non_forked/vim-ruby/compiler/ruby.vim
Normal file
@ -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:
|
33
sources_non_forked/vim-ruby/compiler/rubyunit.vim
Normal file
33
sources_non_forked/vim-ruby/compiler/rubyunit.vim
Normal file
@ -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:
|
40
sources_non_forked/vim-ruby/doc/ft-ruby-omni.txt
Normal file
40
sources_non_forked/vim-ruby/doc/ft-ruby-omni.txt
Normal file
@ -0,0 +1,40 @@
|
||||
RUBY *ft-ruby-omni*
|
||||
|
||||
Completion of Ruby code requires that Vim be built with |+ruby|.
|
||||
|
||||
Ruby completion will parse your buffer on demand in order to provide a list of
|
||||
completions. These completions will be drawn from modules loaded by "require"
|
||||
and modules defined in the current buffer.
|
||||
|
||||
The completions provided by CTRL-X CTRL-O are sensitive to the context:
|
||||
|
||||
CONTEXT COMPLETIONS PROVIDED ~
|
||||
|
||||
1. Not inside a class definition Classes, constants and globals
|
||||
|
||||
2. Inside a class definition Methods or constants defined in the class
|
||||
|
||||
3. After '.', '::' or ':' Methods applicable to the object being
|
||||
dereferenced
|
||||
|
||||
4. After ':' or ':foo' Symbol name (beginning with "foo")
|
||||
|
||||
Notes:
|
||||
- Vim will load/evaluate code in order to provide completions. This may
|
||||
cause some code execution, which may be a concern. This is no longer
|
||||
enabled by default, to enable this feature add >
|
||||
let g:rubycomplete_buffer_loading = 1
|
||||
<- In context 1 above, Vim can parse the entire buffer to add a list of
|
||||
classes to the completion results. This feature is turned off by default,
|
||||
to enable it add >
|
||||
let g:rubycomplete_classes_in_global = 1
|
||||
< to your vimrc
|
||||
- In context 2 above, anonymous classes are not supported.
|
||||
- In context 3 above, Vim will attempt to determine the methods supported by
|
||||
the object.
|
||||
- Vim can detect and load the Rails environment for files within a rails
|
||||
project. The feature is disabled by default, to enable it add >
|
||||
let g:rubycomplete_rails = 1
|
||||
< to your vimrc
|
||||
|
||||
vim:tw=78:sw=4:ts=8:ft=help:norl:
|
64
sources_non_forked/vim-ruby/doc/ft-ruby-syntax.txt
Normal file
64
sources_non_forked/vim-ruby/doc/ft-ruby-syntax.txt
Normal file
@ -0,0 +1,64 @@
|
||||
RUBY *ruby.vim* *ft-ruby-syntax*
|
||||
|
||||
There are a number of options to the Ruby syntax highlighting.
|
||||
|
||||
1. Ruby operators |ruby_operators|
|
||||
2. Whitespace errors |ruby_space_errors|
|
||||
3. Folds |ruby_fold|
|
||||
4. Reducing expensive operations |ruby_no_expensive| |ruby_minlines|
|
||||
|
||||
|
||||
1. Ruby operators *ruby_operators*
|
||||
|
||||
Ruby operators can be highlighted.
|
||||
|
||||
This is enabled by defining "ruby_operators": >
|
||||
|
||||
:let ruby_operators = 1
|
||||
<
|
||||
|
||||
2. Whitespace errors *ruby_space_errors*
|
||||
|
||||
Whitespace errors can be highlighted by defining "ruby_space_errors": >
|
||||
|
||||
:let ruby_space_errors = 1
|
||||
<
|
||||
|
||||
This will highlight trailing whitespace and tabs preceded by a space character
|
||||
as errors. This can be refined by defining "ruby_no_trail_space_error" and
|
||||
"ruby_no_tab_space_error" which will ignore trailing whitespace and tabs after
|
||||
spaces respectively.
|
||||
|
||||
3. Folds *ruby_fold*
|
||||
|
||||
Folds can be enabled by defining "ruby_fold": >
|
||||
|
||||
:let ruby_fold = 1
|
||||
<
|
||||
|
||||
This will set the value |foldmethod| to "syntax" locally to the current buffer
|
||||
or window, which will enable syntax-based folding when editing Ruby filetypes.
|
||||
|
||||
4. Reducing expensive operations *ruby_no_expensive*
|
||||
|
||||
By default, the "end" keyword is colorized according to the opening statement
|
||||
of the block it closes. While useful, this feature can be expensive; if you
|
||||
experience slow redrawing (or you are on a terminal with poor color support)
|
||||
you may want to turn it off by defining the "ruby_no_expensive" variable: >
|
||||
|
||||
:let ruby_no_expensive = 1
|
||||
<
|
||||
In this case the same color will be used for all control keywords.
|
||||
|
||||
*ruby_minlines*
|
||||
|
||||
If you do want this feature enabled, but notice highlighting errors while
|
||||
scrolling backwards, which are fixed when redrawing with CTRL-L, try setting
|
||||
the "ruby_minlines" variable to a value larger than 50: >
|
||||
|
||||
:let ruby_minlines = 100
|
||||
<
|
||||
Ideally, this value should be a number of lines large enough to embrace your
|
||||
largest class or module.
|
||||
|
||||
vim:tw=78:sw=4:ts=8:ft=help:norl:
|
61
sources_non_forked/vim-ruby/doc/vim-ruby.txt
Normal file
61
sources_non_forked/vim-ruby/doc/vim-ruby.txt
Normal file
@ -0,0 +1,61 @@
|
||||
*vim-ruby.txt*
|
||||
|
||||
1. Ruby motions |ruby-motion|
|
||||
2. Ruby text objects |ruby-text-objects|
|
||||
|
||||
==============================================================================
|
||||
1. Ruby motions *ruby-motion*
|
||||
|
||||
Vim provides motions such as |[m| and |]m| for jumping to the start or end of
|
||||
a method definition. Out of the box, these work for curly-bracket languages,
|
||||
but not for ruby. The |vim-ruby| plugin enhances these motions, by making them
|
||||
also work on ruby files.
|
||||
|
||||
*ruby-]m*
|
||||
]m Go to start of next method definition.
|
||||
|
||||
*ruby-]M*
|
||||
]M Go to end of next method definition.
|
||||
|
||||
*ruby-[m*
|
||||
[m Go to start of previous method definition.
|
||||
|
||||
*ruby-[M*
|
||||
[M Go to end of previous method definition.
|
||||
|
||||
*ruby-]]*
|
||||
]] Go to start of next module or class definition.
|
||||
|
||||
*ruby-][*
|
||||
][ Go to end of next module or class definition.
|
||||
|
||||
*ruby-[[*
|
||||
[[ Go to start of previous module or class definition.
|
||||
|
||||
*ruby-[]*
|
||||
[] Go to end of previous module or class definition.
|
||||
|
||||
==============================================================================
|
||||
2. Ruby text objects *ruby-text-objects*
|
||||
|
||||
Vim's |text-objects| can be used to select or operate upon regions of text
|
||||
that are defined by structure. The |vim-ruby| plugin adds text objects for
|
||||
operating on methods and classes.
|
||||
|
||||
*ruby-v_am* *ruby-am*
|
||||
am "a method", select from "def" until matching "end"
|
||||
keyword.
|
||||
|
||||
*ruby-v_im* *ruby-im*
|
||||
im "inner method", select contents of "def"/"end" block,
|
||||
excluding the "def" and "end" themselves.
|
||||
|
||||
*ruby-v_aM* *ruby-aM*
|
||||
aM "a class", select from "class" until matching "end"
|
||||
keyword.
|
||||
|
||||
*ruby-v_iM* *ruby-iM*
|
||||
iM "inner class", select contents of "class"/"end"
|
||||
block, excluding the "class" and "end" themselves.
|
||||
|
||||
vim:tw=78:sw=4:ts=8:ft=help:norl:
|
@ -0,0 +1,16 @@
|
||||
[1, [2,
|
||||
[3],
|
||||
3],
|
||||
4]
|
||||
|
||||
[1, [2,
|
||||
3],
|
||||
4]
|
||||
|
||||
[1, {2 =>
|
||||
3},
|
||||
4]
|
||||
|
||||
[1, f(2,
|
||||
3),
|
||||
4]
|
62
sources_non_forked/vim-ruby/ftdetect/ruby.vim
Normal file
62
sources_non_forked/vim-ruby/ftdetect/ruby.vim
Normal file
@ -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:
|
102
sources_non_forked/vim-ruby/ftplugin/eruby.vim
Normal file
102
sources_non_forked/vim-ruby/ftplugin/eruby.vim
Normal file
@ -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:
|
395
sources_non_forked/vim-ruby/ftplugin/ruby.vim
Normal file
395
sources_non_forked/vim-ruby/ftplugin/ruby.vim
Normal file
@ -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:
|
82
sources_non_forked/vim-ruby/indent/eruby.vim
Normal file
82
sources_non_forked/vim-ruby/indent/eruby.vim
Normal file
@ -0,0 +1,82 @@
|
||||
" 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
|
||||
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:
|
537
sources_non_forked/vim-ruby/indent/ruby.vim
Normal file
537
sources_non_forked/vim-ruby/indent/ruby.vim
Normal file
@ -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:
|
24
sources_non_forked/vim-ruby/spec/indent/arguments_spec.rb
Normal file
24
sources_non_forked/vim-ruby/spec/indent/arguments_spec.rb
Normal file
@ -0,0 +1,24 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "multi-line arguments" do
|
||||
assert_correct_indenting <<-EOF
|
||||
User.new(
|
||||
:first_name => 'Some',
|
||||
:second_name => 'Guy'
|
||||
)
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
User.new(:first_name => 'Some',
|
||||
:second_name => 'Guy')
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
User.new(
|
||||
:first_name => 'Some',
|
||||
:second_name => 'Guy'
|
||||
)
|
||||
EOF
|
||||
end
|
||||
end
|
42
sources_non_forked/vim-ruby/spec/indent/basic_spec.rb
Normal file
42
sources_non_forked/vim-ruby/spec/indent/basic_spec.rb
Normal file
@ -0,0 +1,42 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "if-clauses" do
|
||||
assert_correct_indenting <<-EOF
|
||||
if foo
|
||||
bar
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
if foo
|
||||
bar
|
||||
else
|
||||
baz
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
bar if foo
|
||||
something_else
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "heredocs" do
|
||||
assert_correct_indenting <<-EOF
|
||||
def one
|
||||
two = <<-THREE
|
||||
four
|
||||
THREE
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
def one
|
||||
two = <<THREE
|
||||
four
|
||||
THREE
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
69
sources_non_forked/vim-ruby/spec/indent/blocks_spec.rb
Normal file
69
sources_non_forked/vim-ruby/spec/indent/blocks_spec.rb
Normal file
@ -0,0 +1,69 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "'do' indenting" do
|
||||
assert_correct_indenting <<-EOF
|
||||
do
|
||||
something
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
def foo
|
||||
a_hash = {:do => 'bar'}
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
def foo(job)
|
||||
job.do!
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "blocks with multiline parameters" do
|
||||
assert_correct_indenting <<-EOF
|
||||
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
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "case-insensitive matching" do
|
||||
@vim.set 'ignorecase'
|
||||
assert_correct_indenting <<-EOF
|
||||
module X
|
||||
Class.new do
|
||||
end
|
||||
end
|
||||
EOF
|
||||
@vim.set 'ignorecase&'
|
||||
end
|
||||
|
||||
specify "blocks with tuple arguments" do
|
||||
assert_correct_indenting <<-EOF
|
||||
proc do |(a, b)|
|
||||
puts a
|
||||
puts b
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
proc do |foo, (a, b), bar|
|
||||
puts a
|
||||
puts b
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
proc do |(a, (b, c)), d|
|
||||
puts a, b
|
||||
puts c, d
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
142
sources_non_forked/vim-ruby/spec/indent/continuations_spec.rb
Normal file
142
sources_non_forked/vim-ruby/spec/indent/continuations_spec.rb
Normal file
@ -0,0 +1,142 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "arrays" do
|
||||
assert_correct_indenting <<-EOF
|
||||
foo = [one,
|
||||
two,
|
||||
three]
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "tricky string interpolation" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/75 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
puts %{\#{}}
|
||||
puts "OK"
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
while true
|
||||
begin
|
||||
puts %{\#{x}}
|
||||
rescue ArgumentError
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuations after round braces" do
|
||||
assert_correct_indenting <<-EOF
|
||||
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
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuations after assignment" do
|
||||
assert_correct_indenting <<-EOF
|
||||
variable =
|
||||
if condition?
|
||||
1
|
||||
else
|
||||
2
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
variable = # evil comment
|
||||
case something
|
||||
when 'something'
|
||||
something_else
|
||||
else
|
||||
other
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuations after hanging comma" do
|
||||
assert_correct_indenting <<-EOF
|
||||
array = [
|
||||
:one,
|
||||
].each do |x|
|
||||
puts x.to_s
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "string interpolation" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/93 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
command = %|\#{file}|
|
||||
settings.log.info("Returning: \#{command}")
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "closing bracket not on its own line" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/81 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
one { two >>
|
||||
three }
|
||||
four
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "lonesome single parenthesis in a method definition" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/130 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
def bar(
|
||||
baz
|
||||
)
|
||||
return baz+1
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "brackets on their own line, followed by a comma" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/124 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
bla = {
|
||||
:one => [
|
||||
{:bla => :blub}
|
||||
],
|
||||
:two => (
|
||||
{:blub => :abc}
|
||||
),
|
||||
:three => {
|
||||
:blub => :abc
|
||||
},
|
||||
:four => 'five'
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "string with an and#" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/108 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
outside_block "and#" do
|
||||
inside_block do
|
||||
end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuation with a symbol at the end" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/132 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
foo = :+
|
||||
# Next indents correctly
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "continuation with a hanging comma" do
|
||||
# See https://github.com/vim-ruby/vim-ruby/issues/139 for details
|
||||
assert_correct_indenting <<-EOF
|
||||
thing :foo
|
||||
thing 'a',
|
||||
'b'
|
||||
EOF
|
||||
end
|
||||
end
|
@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "end constructs" do
|
||||
assert_correct_indenting <<-EOF
|
||||
f do
|
||||
g { def h; end }
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
if foo
|
||||
bar ; end
|
||||
something_else
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
if bar ; end
|
||||
something_else
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
foo do
|
||||
foo = 3 . class
|
||||
foo = lambda { class One; end }
|
||||
foo = lambda { |args| class One; end }
|
||||
foo = bar; class One; end
|
||||
end
|
||||
EOF
|
||||
end
|
||||
end
|
66
sources_non_forked/vim-ruby/spec/indent/nesting_spec.rb
Normal file
66
sources_non_forked/vim-ruby/spec/indent/nesting_spec.rb
Normal file
@ -0,0 +1,66 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "nested blocks" do
|
||||
assert_correct_indenting <<-EOF
|
||||
var.func1(:param => 'value') do
|
||||
var.func2(:param => 'value') do
|
||||
puts "test"
|
||||
end
|
||||
end
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
var.func1(:param => 'value') {
|
||||
var.func2(:param => 'value') {
|
||||
foo({ bar => baz })
|
||||
puts "test one"
|
||||
puts "test two"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
var.
|
||||
func1(:param => 'value') {
|
||||
var.func2(:param => 'value') {
|
||||
puts "test"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "nested hashes" do
|
||||
assert_correct_indenting <<-EOF
|
||||
foo, bar = {
|
||||
:bar => {
|
||||
:one => 'two',
|
||||
:five => 'six'
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
foo,
|
||||
bar = {
|
||||
:bar => {
|
||||
:foo => { 'bar' => 'baz' },
|
||||
:one => 'two',
|
||||
:three => 'four'
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "nested blocks with a continuation and function call inbetween" do
|
||||
assert_correct_indenting <<-EOF
|
||||
var.
|
||||
func1(:param => 'value') {
|
||||
func1_5(:param => 'value')
|
||||
var.func2(:param => 'value') {
|
||||
puts "test"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
end
|
||||
end
|
46
sources_non_forked/vim-ruby/spec/indent/splat_spec.rb
Normal file
46
sources_non_forked/vim-ruby/spec/indent/splat_spec.rb
Normal file
@ -0,0 +1,46 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe "Indenting" do
|
||||
specify "splats with blocks in square brackets" do
|
||||
assert_correct_indenting <<-EOF
|
||||
x = Foo[*
|
||||
y do
|
||||
z
|
||||
end
|
||||
]
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
x = Foo[* # with a comment
|
||||
y do
|
||||
z
|
||||
end
|
||||
]
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "splats with blocks in assignment" do
|
||||
assert_correct_indenting <<-EOF
|
||||
x = *
|
||||
array.map do
|
||||
3
|
||||
end
|
||||
EOF
|
||||
end
|
||||
|
||||
specify "splats with blocks in round brackets" do
|
||||
assert_correct_indenting <<-EOF
|
||||
x = Foo(*y do
|
||||
z
|
||||
end)
|
||||
EOF
|
||||
|
||||
assert_correct_indenting <<-EOF
|
||||
x = Foo(
|
||||
*y do
|
||||
z
|
||||
end
|
||||
)
|
||||
EOF
|
||||
end
|
||||
end
|
44
sources_non_forked/vim-ruby/spec/spec_helper.rb
Normal file
44
sources_non_forked/vim-ruby/spec/spec_helper.rb
Normal file
@ -0,0 +1,44 @@
|
||||
require 'tmpdir'
|
||||
require 'vimrunner'
|
||||
|
||||
module Support
|
||||
def assert_correct_indenting(string)
|
||||
whitespace = string.scan(/^\s*/).first
|
||||
string = string.split("\n").map { |line| line.gsub /^#{whitespace}/, '' }.join("\n").strip
|
||||
|
||||
File.open 'test.rb', 'w' do |f|
|
||||
f.write string
|
||||
end
|
||||
|
||||
@vim.edit 'test.rb'
|
||||
@vim.normal 'gg=G'
|
||||
@vim.write
|
||||
|
||||
IO.read('test.rb').strip.should eq string
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |config|
|
||||
include Support
|
||||
|
||||
config.before(:suite) do
|
||||
VIM = Vimrunner.start_gvim
|
||||
VIM.prepend_runtimepath(File.expand_path('../..', __FILE__))
|
||||
end
|
||||
|
||||
config.after(:suite) do
|
||||
VIM.kill
|
||||
end
|
||||
|
||||
config.around(:each) do |example|
|
||||
@vim = VIM
|
||||
|
||||
# cd into a temporary directory for every example.
|
||||
Dir.mktmpdir do |dir|
|
||||
Dir.chdir(dir) do
|
||||
@vim.command("cd #{dir}")
|
||||
example.call
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
74
sources_non_forked/vim-ruby/syntax/eruby.vim
Normal file
74
sources_non_forked/vim-ruby/syntax/eruby.vim
Normal file
@ -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:
|
369
sources_non_forked/vim-ruby/syntax/ruby.vim
Normal file
369
sources_non_forked/vim-ruby/syntax/ruby.vim
Normal file
@ -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*\>\%(\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:
|
Reference in New Issue
Block a user