python omni complete for current project

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

python omni complete for current project

gearheart
hi

how can i make omni to complete function names and variables in current file/project?
(at the moment it works only for standard modules like sys)

for example:

class aaa(object):
     def __init__(self):
          self.name = 'sdfsdfsdf'

    def func(self):
           self.     # and here invoke omnicomplete and get "name", "__class__" and so on.



Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: python omni complete for current project

Tony Mechelynck

On 15/07/08 14:09, Владимир Сидоренко wrote:

> hi
>
> how can i make omni to complete function names and variables in current
> file/project?
> (at the moment it works only for standard modules like sys)
>
> for example:
>
> class aaa(object):
> def __init__(self):
> self.name <http://self.name> = 'sdfsdfsdf'
>
> def func(self):
> self. # and here invoke omnicomplete and get "name", "__class__" and so on.
>
>
>
> Thanks.

I don't know Python, but have you got Exuberant Ctags installed? Have
you tried to use it to generate a tagfile for your Python source?

Best regards,
Tony.
--
This is an unauthorized cybernetic announcement.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: python omni complete for current project

gearheart
hi
yes, i have ctags and it works partially when tags are generated.
So you mean i have to regenerate tags for ,y sources every time smth i changed?

2008/7/15 Tony Mechelynck <[hidden email]>:

On 15/07/08 14:09, Владимир Сидоренко wrote:
> hi
>
> how can i make omni to complete function names and variables in current
> file/project?
> (at the moment it works only for standard modules like sys)
>
> for example:
>
> class aaa(object):
> def __init__(self):
> self.name <http://self.name> = 'sdfsdfsdf'
>
> def func(self):
> self. # and here invoke omnicomplete and get "name", "__class__" and so on.
>
>
>
> Thanks.

I don't know Python, but have you got Exuberant Ctags installed? Have
you tried to use it to generate a tagfile for your Python source?

Best regards,
Tony.
--
This is an unauthorized cybernetic announcement.




--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: python omni complete for current project

Tony Mechelynck

On 16/07/08 09:24, Владимир Сидоренко wrote:
> hi
> yes, i have ctags and it works partially when tags are generated.
> So you mean i have to regenerate tags for ,y sources every time smth i
> changed?

Not necessarily every time -- depending on how the tags file is built,
for small changes Vim will probably be able to find anything mentioned
in the tags file (if it still exists of course) even if it has somewhat
moved (tagfiles with search commands are better in this respect than
tagfiles with actual line numbers). For large changes it is better to
regenerate the tags file so that labels you added or removed will be
taken into account.

You may want to look into the ctags documentation if you have it (on
Unix/Linux it's usually installed as "man ctags"; on Windows I don't
know), so you can tweak your ctags command to your heart's delight.

There are several programs named ctags in circulation; Exuberant Ctags
is the best. If you have it, "ctags --version" will proudly boast it to you.


Best regards,
Tony.
--
The more we disagree, the more chance there is that at least one of us
is right.

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: python omni complete for current project

Cyril Slobin-4
>  On 16/07/08 09:24, Владимир Сидоренко wrote:

> yes, i have ctags and it works partially when tags are generated.
> So you mean i have to regenerate tags for ,y sources every time smth i
> changed?

Don't mix tag completion and omni completion. The first is based on
static analysis of your code by ctags program which runs, er, when you
run it. The second is based on dynamic "on the fly" evaluation of your
code. The main problem of the second approach is that you probably
want not most of your code to be executed while you are just editing
it. Therefore the completer code does it's best to evaluate only the
safe parts of the code written so far. In particular, it is able to
note your methods on the fly, but not your data fields. Consider:

class aaa(object):

    name = "abcd"

    def foo(self):
        return self.name

    def bar(self):
        print self.

At this point both "foo" and "bar" are suggested as possible
completions, but "name" isn't. If you like to dig into mix of
vimscript and python code, you can find the completion logic into
autoload/pythoncomplete.vim file. And, just in case, the omni
completion is triggered by <Ctrl-X><Ctrl-O> keys.

--
http://slobin.pp.ru/ `When I use a word,' Humpty Dumpty said,
<[hidden email]> `it means just what I choose it to mean'

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---