Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is VIM omni-completion really so limited? Or am I missing something?

Ruby:

file = File.new("some.txt", "r")
lines = file.readlines

Omni-completion tests

file.readl
   ---------
   readline     <- PASSED
   readlines
   ---------

"hola".capital
   ---------
   capitalize   <- PASSED
   capitalize!
   ---------

lines.
                <-- FAILED (no suggestions)

lines[0].capital
                <-- FAILED (no suggestions)

I tried Python as well, and it worked in similar way. So it looks like omni-completion can't be used for real development, as it fails on pretty simple cases?

Am I missing some thing? May be the intellisense can be improved some how for Ruby/Python?

like image 455
alex2k8 Avatar asked Jan 28 '11 03:01

alex2k8


People also ask

What is Omni completion Vim?

Omni completion using a tags file will complete the names of defined constants, functions, classes and other names from included and other external files. Omni completion scripts can be written to support other languages, and to customize behavior. : help new-omni-completion :help compl-omni.

Does vim have code completion?

Vim text editor supports autocompletion for the standard text files by default. Also, when configured properly, Vim enables an autocomplete feature for files with code in the languages it recognizes.


1 Answers

The issue is that Vim does not know if line is a String, an Array or some other Class. There is no deep syntactical analysis in Vim. Vim has no idea of scope, if a variable or method has been defined, etc.

It is only suggesting similar words. So yes, Vim is more limited than an IDE in this aspect. This is also why Eclipse can suggest errors as you typed them, and Vim can't.

Vim is much more basic: in a way, everything is text, and not necessarily seen as "code".

So you are right this is one of Vim limitation.

There are some plugins to work around those limitations (omnicpp is using ctags to determine the scope of some methods) but they are often developed on a per-language basis and there is no silver bullet.

like image 196
Xavier T. Avatar answered Oct 01 '22 00:10

Xavier T.