Skip to content

Loading…

ruby completion #97

Open
vheon opened this Issue · 4 comments

3 participants

@vheon

Hi. I just started studying ruby, so I decided to give a try to vim-ruby mainly for the syntax highlighting and the indent, but since it also include a ruby completion function, why would not give it a try?

As I understand the completion provided by that function should be pretty much the same as the irb completion right?

I just installed vim-ruby plugin using pathogen but given this code:

class Person
  attr_accessor :fname, :lname

  def initialize(fname, lname)
    @fname = fname
    @lname = lname
  end

  def to_s
    "#{@lname}, #{@fname}"
  end

  def self.find_by_fname (fname)
    found = nil
    ObjectSpace.each_object (Person) { |o|
      found = o if o.name == fname
    }
    found
  end
end

person = Person.<C-X><C-O>

I recive this message:

-- Omni completion (^O^N^P) Pattern not found

that is my setup:

uname -a
Darwin starkBox.local 11.4.0 Darwin Kernel Version 11.4.0: Mon Apr  9 19:32:15 PDT 2012; root:xnu-1699.26.8~1/RELEASE_X86_64 x86_64

MacVim :version

:version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Apr 10 2012 01:00:28)
MacOS X (unix) version
Included patches: 1-390
Compiled by vheon@starkBox.local
Huge version with MacVim 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()
 +fullscreen -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 +mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg +odbeditor
+path_extra +perl +persistent_undo +postscript +printer +profile +python -python3
+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 +transparency +user_commands
+vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu
+windows +writebackup -X11 -xfontset +xim -xsmp -xterm_clipboard -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragma
s -pipe  -DMACOS_X_UNIX -no-cpp-precomp  -g -O2 -arch x86_64 -U_FORTIFY_SOURCE -D_FORTIFY_S
OURCE=1     -I/System/Library/Frameworks/Tcl.framework/Headers  -D_REENTRANT=1  -D_THREAD_S
AFE=1  -D_DARWIN_C_SOURCE=1
Linking: gcc   -L.   -L.        -arch x86_64 -L/usr/local/lib -o Vim -framework Cocoa -fram
ework Carbon      -lncurses -liconv -framework Cocoa    -fstack-protector -L/usr/local/lib
 -L/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc -framewo
rk Python  -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -framework
 Ruby 

my vim setup is here

Is something wrong?

@segfault
Vim-Ruby member

Give something like this a try:

    autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
    autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
    autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1    

If I remember correctly for security reasons I disable a lot by default.

@AndrewRadev
Vim-Ruby member

@vheon, these settings seem to do the trick for the given code on my machine. Could you let us know whether they help in your setup, so we could close the issue?

@vheon

@AndrewRadev I tried with that setup but if I add another method to that class and i try to complete, that method is not in the list...

@AndrewRadev
Vim-Ruby member

Sadly, I can't assist with that. My knowledge of how omnicompletion works is limited at best. I'll leave this issue open for @segfault.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.