Git Product home page Git Product logo

vim-ruby's Introduction

Vim-ruby

This project contains Vim's runtime files for ruby support. This includes syntax highlighting, indentation, omnicompletion, and various useful tools and mappings.

Installation

See the file INSTALL.markdown for instructions.

You might also find useful setup tips in the github wiki: https://github.com/vim-ruby/vim-ruby/wiki/VimRubySupport

Usage

Ideally, vim-ruby should work "correctly" for you out of the box. However, ruby developers have varying preferences, so there are settings that control some of the details. You can get more information on these by using the native :help command:

Issues

If you have an issue or a feature request, it's recommended to use the github issue tracker: https://github.com/vim-ruby/vim-ruby/issues. Try the search box to look for an existing issue -- it might have already been reported.

If you don't have a github account or would rather contact us in a different way, you can find emails for individual maintainers in the CONTRIBUTORS file. They're also in the comment headers of the project's Vimscript files (syntax/ruby.vim, indent/ruby.vim, etc) under the label "Maintainer".

If you're not sure who the most relevant person to contact is for your particular issue, you can send an email to the release coordinator, Doug Kearns (dougkearns at gmail.com).

Contributing

Vim-ruby is a mature project, which is one way of saying it moves slowly and it can be a bit difficult to modify. It's far from impossible, but be warned that issues and PRs may take time to be handled. Partly, it's because we don't want to risk breaking Vim's core ruby support, partly because it takes a lot of time and energy to debug and fix things.

Contributing a fix for an issue would be very appreciated, even if it's a proof-of-concept to start a conversation. Be warned that we're definitely going to be conservative when considering changes to vim-ruby.

The code is tested using RSpec and Vimrunner. The tests are not exhaustive, but they should cover a wide variety of cases.

Project history

This project began in July 2003, when the current version of Vim was 6.2. It was migrated from CVS in August, 2008.

If you're curious about individual pre-git changes, you can read some of them in the (unmaintained) NEWS and/or ChangeLog files.

vim-ruby's People

Contributors

0x0dea avatar alexgenco avatar amarshall avatar andrewradev avatar bk2204 avatar bootleq avatar dkearns avatar dreyks avatar drn avatar gsinclair avatar ichimonji10 avatar isty001 avatar khamilowicz avatar kossnocorp avatar mattn avatar nelstrom avatar nerdrew avatar newellista avatar odcinek avatar panthomakos avatar ravicious avatar rolfb avatar roryokane avatar segfault avatar sencer avatar sergio1990 avatar tomdalling avatar tpope avatar urbanautomaton avatar wdjunaidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-ruby's Issues

i_CTRL-X_CTRL-U completion broken

Hello,

A few months ago, I remember that i_CTRL-X_CTRL-U completion used to work in filetype=ruby buffers. Now it throws an error:

E764: Option 'completefunc' is not set

And it gives me this prompt:

-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)

How can I solve this?

Thanks for your consideration.

More information

In Vim, :set ofu shows me:

omnifunc=rubycomplete#Complete

And I have the following code in my ~/.vim/after/ftplugin/ruby.vim file:

setlocal complete-=i

I am using the following Vim version with abfe860.

VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Sep 30 2011 03:25:32)
Included patches: 1-322
Compiled by ArchLinux
Big version with GTK2 GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con_gui +diff 
+digraphs +dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi 
+file_in_path +find_in_path +float +folding -footer +fork() +gettext 
-hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall 
+linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname 
+mouse +mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm 
-mouse_sysmouse +mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg 
+path_extra +perl +persistent_undo +postscript +printer -profile +python/dyn 
+python3/dyn +quickfix +reltime +rightleft +ruby +scrollbind +signs 
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
 +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim 
+xsmp_interact +xterm_clipboard -xterm_save 
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "/etc/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -pthread -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng14   -I/usr/local/include  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4  -D_FORTIFY_SOURCE=1      
Linking: gcc   -L. -Wl,--hash-style=gnu -Wl,--as-needed -rdynamic -Wl,-export-dynamic  -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -L/usr/local/lib -Wl,--as-needed -o vim   -pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0   -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -lncurses -lelf -lnsl    -lacl -lattr -lgpm -ldl    -Wl,-E -Wl,-rpath,/usr/lib/perl5/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -fstack-protector -L/usr/local/lib  -L/usr/lib/perl5/core_perl/CORE -lperl -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc    -lruby -lpthread -lrt -ldl -lcrypt -lm  -L/usr/lib   

Operator pending maps

Is there any reason the maps like [m are only defined for normal and visual modes? It would be nice to have those in operator-pending mode, too.

Issue with Ruby 1.9 Hash syntax

Using the new hash syntax, the colon characters do not get highlighted as symbols, e.g. with foo: bar, only foo is marked as a symbol.

Optional completfunc functionality

This is more a question rather than an issue.

Is there any global variable that would allow me to disable support for the completefunc functionality?

I'm using neocomplcache and it stops working as soon as I open a rails buffer. I commented the lines that added the support from my rails-vim installation, but I was wondering if it was to much trouble just to add that variable (cleaner) or if there was another way to accomplish this.

Cheers.

BTW: Awesome plugin.

ruby 1.9 style symbol hash key highlighting

In the render() line below, only the first symbol (text) is being highlighted as a symbol. The second symbol (layout) is being highlighted like a method-call.

class WelcomeController < ApplicationController
  def index
    render text: 'welcome', layout: true
  end
end

Please fix this. Thank you.

Continuation lines use tab and space mixtures

It appears that continuation lines will always use a mix of spaces and tabs (using the current tabstop width) to align text on successive lines. See:

class B
    foob(:a,
       :b,
       :c
      )
end

With a tabstop set to 4, the ":b" is indented one tab and 3 spaces.

It seems preferable to simply indent normally, and not mess with all this alignment business. The major problem is when tabstops are changed, the alignment gets all thrown off (the typical problem when aligning with tabs).

I am a huge vim noob, so if I've missed something basic in my futzing with various indentation options, please ignore this.

Thanks!

(confirmed against the latest dev version:
$gem list | grep vim
vim-ruby (2010.01.29)
)

Automatically indent on "else"

Shouldn't the indent file include 'else' in indentkeys?

Setting identkeys to include 'e' doesn't seem to work (at least for me in Vim 7.3). On the other hand, it seems to work if I change (just included '=else') the indentkeys line to:

setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue,==begin,==end

Also, why does indentkeys include the default "0{,0},0),0], ^F,o,O,e"? I agree that ^F, 'o' and 'O' are useful, but I couldn't understand the other ones nor I could test if they are working. Maybe I didn't understand the documentation correctly.

Indent fails with each..do leading with regex containing a hash ('#')

Here is a block of code with correct indentation:

text.scan(/#/).each do |match|
    line1
    line2
end

Here is how Ruby.vim indents the code:
text.scan(/#/).each do |match|
line1
line2
end

All lines subsequent to line2 are indented to the same level as line2.

The issue is caused by the hash (# usually means single line comment) symbol's presence in the regex.

Multiline regexes are not highlighted correctly

I don't know if this is possible to do, but if I have the following code:

foo = %r{
  something
  goes
  here
}x

more = {:stuff => "here"}

then everything after the %r{ is highlighted with the same thing.

Add "Vagrantfile" to ftdetect

Adding

" Vagrantfile
 au BufNewFile,BufRead [vV]agrantfile        set filetype=ruby

to the ftdetect file makes Vagrant uses happy. :)
Would be great.

indentation erb

<% @message_action_links_delimter ||= "" %>
<% if browse == 'inbox' %>
<%= link_to('save',
message_move_url(:id => message,
:folder => Message::FOLDER_SAVED),
:class => 'actionLinkLite smallText',
:method => 'post') + @message_action_links_delimter
-%>
<% end %>
<% if browse == 'saved' %>
<%= link_to('unsave',
message_move_url(:id => message,
:folder => Message::FOLDER_INBOX),
:class => 'actionLinkLite smallText',
:method => 'post') + @message_action_links_delimter)
-%>
<% end %>
<% if %>
<%= link_to('trash',
message_move_url(:id => message,
:folder => Message::FOLDER_TRASH),
:class => 'actionLinkLite smallText', :confirm => 'Are you sure?', :method => 'post') + (browse == "trash" || browse == "sent" ? @message_action_links_delimter : "") if browse != "trash" && browse != "sent" %>
<% end %>
<% if browse == "trash" %>
<%=
link_to('untrash',
message_move_url(:id => message,
:folder => Message::FOLDER_INBOX,
:from_url => url_for(params)),
:class => 'actionLinkLite smallText',
:method => 'post')
-%>
<% end %>
<% if browse == "trash" || browse == "sent" %>
<%= link_to('delete',
message_destroy_url(:id => message,
:from_url => url_for()),
:class => 'actionLinkLite smallText',
:confirm => 'Are you sure?', :method => 'post')
-%>

                                                                                                                              <% end %>

Brackets {} should be indented as do/end in blocks

Blocks started by { directly after another block are currently not indented. Observe the difference:

var.func1(:param => 'value') do
  var.func2(:param => 'value') do
    puts "test"
  end
end
var.func1(:param => 'value') {
  var.func2(:param => 'value') {
  puts "test"
}
}

This is with the d6f9955 release.

Indentation for lambdas is slightly off

For example,

render :partial => 'foo/bar',
  :collection => @bars.sort,
  :locals => {
    :delete_link => lambda {|rr|
      check_box_tag 'remove_bar_from_collection[]', bar.to_s
}
  }

While the indentation for the :locals hash is correct, it's somehow broken for the lambda.

Keywords within Ruby 1.9 style hash keys do not receive correct syntax

Writing hashes using the Ruby 1.9 hash key syntax with keywords as the key value do not properly get highlighted, e.g.

{ class: "hello", if: "world", def: "i am", include: "foo", case: "bar", end: "baz" }

are all incorrectly highlighted as keywords, rather than symbols. Further, this throws off the matching of end statements, e.g.

def hello
  { if: "world" }
end

where the end is paired with the if rather than the def.

Indentation of continuation lines incorrect

a and
  (b and
   c) and
   X

X is indented one character too far. This is because the code at the start of 3.4 returns the previous line’s indent, not the MSLs indent + &sw. This is because it prioritizes

a and
   b and
   c

over

a and
   b and
  c

The code should either take care to deal with parentheses messing up the indentation levels or simply indent two spaces and ignore the case where some fool has added more space than mandated by the indentation script.

.mobile.erb registered with eruby_subtype does not indent html correctly

Registered .mobile.erb as an html subtype by adding this in .vimrc:

:autocmd BufNewFile,BufRead *.mobile.erb let b:eruby_subtype = 'html'

Syntax highlighting works, but indenting only works in the erb parts, not in the html parts.

file.html.erb:

<% each do -%>
  <ul>
    <div>
      <% each do -%>
        <li>
          <span>
          </span>
        </li>
      <% end -%>
    </div>
  </ul>
<% end -%>

file.mobile.erb:

<% each do -%>
  <ul>
  <div>
  <% each do -%>
    <li>
    <span>
    </span>
    </li>
  <% end -%>
  </div>
  </ul>
<% end -%>

bug in rdoc syntax highlighting

The following is valid rdoc:

=begin rdoc
blah blah blah
=end rdoc

the pattern to match the end tag doesn't handle arguments to the =end.

here is a patch to fix this:

--- a/syntax/ruby.vim
+++ b/syntax/ruby.vim
@@ -271,7 +271,7 @@ syn keyword rubyTodo FIXME NOTE TODO OPTIMIZE XXX contained
syn match rubyComment "#." contains=rubySharpBang,rubySpaceError,rubyTodo,@spell
if !exists("ruby_no_comment_fold")
syn region rubyMultilineComment start="%(%(^\s
#.\n)@<!%(^\s#.\n))%((^\s#.*\

  • syn region rubyDocumentation start="^=begin\ze%(\s.)=$" end="^=end\s$" contains=ru
  • syn region rubyDocumentation start="^=begin\ze%(\s.)=$" end="^=end%(\s.)=$" con
    else
    syn region rubyDocumentation start="^=begin\s_$" end="^=end\s_$" contains=rubySpaceErro
    endif

lines after `private` should not be indented in all cases

E.g.

def foo
  puts :bar
end
private :foo

# nothing here should be intented

Basically, if private has any arguments, no following methods should be intented.

Ideally indentation after private should be optional entirely, as there isn't conformity in the community about how that should be.

indentation breaks on regex with bracket

x =~ /[/

The next line should indent below the x, but it advances all the way to the bracket. Balancing the brackets doesn't have this problem (x =~ /[]/).

This might be related to issue #2.

path is clobbered when opening ruby files

When I open a ruby file, anything I set in path is lost. It would be nice if the vim plugin would append to path.

Also, adding every gem to the path is slow. Maybe we could have a switch to disable this feature? Maybe just adding stdlib to the path would be better?

Thanks.

omnicompletion for ruby 1.8.7

I'm new to Wim but spent some time learning. I have ruby 1.8.7 and gvim 7.3.046 on win xp sp3. When you try to use the omni I get error in function 37_DefRuby: string 575, message E266 ... unable to load msvcrt-ruby191.dll

I have next string in .vimrc
...
syntax on
filetype plugin indent on
compiler ruby
au filetype ruby set omnifunc=rubycomplete#Complete
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
...

vim-ruby don't work with ruby less than 1.9.1, or I have insufficient configuration?

INSTALL file is outdated

Actually gem install vim-ruby does not work anymore. Could you please update this manual? I've onestly tried to follow it :)

Filetype detection for Thor

I'm using thor a lot these days. How about you guys? How about adding detection for Thorfiles? I'm trying to clean up my ~/.vimrc a little, so here is a fork with detection baked in.

ashley-woodard/vim-ruby@97bb76716955c9117a695a8d758e6ce452510efd

Vim-Ruby and Bundler

Thanks for the vim-ruby plugin !!

I use bundler on many projects. When a Gemfile references a development gem on my local disk, vim-ruby doesn't detect its path, and I can't jump to the gem using 'gf'.

This gist has a little script that generates the missing paths from Gemfile.lock. I thought this might be interesting to others who use vim-ruby.

https://gist.github.com/834215

Omnicompletion not working on Windows with vim 7.3 and Ruby 1.9.2

Attempting to use omnicompletion in Windows vim 7.3 in a ruby (.rb) file gives the following error:
NoMethodError: undefined method `line_number' for 15:Fixnum

If I try execute "ruby puts VIM::Buffer.current.line_number" as an ex command I can replicate the error. execute "ruby puts VIM::Buffer.current" returns 15.

"end" unindents too early.

Let's say I'm typing this code:
x = y
end_char = next

Immediately after typing "d" in end_char, the line incorrectly unindents.

vim-ruby should wait to see if the user really did enter the "end" keyword, or if he or she is just in the middle of typing an identifier that begins with "end".

rdoc break indent

module Apple
=begin rdoc
some docs
=end
class Banana
end
end

If module is after the rdoc, then it indents properly

Thank you for the ruby vim tools!

Very slow on first load

When I open a ruby file it takes a (relatively) very long while before Vim is fully loaded. I've been trying to see what could cause it with the --startuptime flag:

mvim --startuptime vim.out file.rb

In my situation loading the ruby indent file is taking a very long time. I was just wondering if others are experiencing this as well.

Here is some relevant output where you can see how long it takes to load and when it jumps on loading the indent file:

219.092  003.356  003.356: sourcing /Users/markmulder/.vim/syntax/ruby.vim
219.882  000.071  000.071: sourcing /usr/local/Cellar/macvim/7.3-57/MacVim.app/Contents/Resources/vim/runtime/syntax/ruby.vim
220.841  000.622  000.622: sourcing /Users/markmulder/.vim/indent/ruby.vim
221.398  000.054  000.054: sourcing /usr/local/Cellar/macvim/7.3-57/MacVim.app/Contents/Resources/vim/runtime/indent/ruby.vim
889.381  667.747  667.747: sourcing /Users/markmulder/.vim/ftplugin/ruby.vim
890.520  000.138  000.138: sourcing /usr/local/Cellar/macvim/7.3-57/MacVim.app/Contents/Resources/vim/runtime/ftplugin/ruby.vim

vim crash - Ruby completion

Hello,

I have just installed vim and I am having some issue making the ruby completion work. every time I try to use this function on some simple ruby code (a string) it just crashes my vim.

Is anyone else also having this issue?

Environment:
Windows 7 x64 (with latest patches)
rubyinstaller-1.9.3-p0.exe
DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe
gvim73_46.exe

Best regards,
Sebastian

Comment indentation within conditional blocks incorrect

Here is code with correct indentation:

#comment1
if
    dostuff1
#comment2
else if
    dostuff2
#comment3
else
    dostuff3
end

case
#comment1
when
    dostuff1
#comment2
when
    dostuff2
end

Here is how Ruby.vim indents the code:

#comment1
if
    dostuff1
    #comment2
else if
    dostuff2
    #comment3
else
    dostuff3
end


case
    #comment1
when
    dostuff1
    #comment2
when
    dostuff2
end

very slow insert mode in classes

  1. Start up Vim 7.2.
  2. Open any Ruby file that has a class definition + methods inside.
  3. Put your cursor inside the class definition and enter insert mode.
  4. Type some characters and observe a few-second delay before your input appears on the screen (i.e. things are unbearably slow!).
  5. Change the filetype to text (:setf text)
  6. Enter insert mode again and type some characters (they should appear on the screen instantly).
  7. Change the filetype to ruby (:setf ruby)
  8. Enter insert mode again and type some characters (they should appear on the screen instantly).

Changing the filetype to text and back to ruby again seems to unregister the culprit that's slowing down insert mode in Ruby files. Any idea what the real problem is, and how to fix it? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.