7

To illustrate my question, here is a simple example of how Omnicomplete is acting on my machine:

name = "Bob"
na<C-x><C-o>      gives-----> name
name.<C-x><C-o>   gives-----> (correct dropdown menu of methods for string)
prin<C-x><C-o>    gives-----> (-- Omni completion (^O^N^P) Pattern not found)

I was expecting the last line to expand to print or print( or something like that. Is this the correct behavior (Omnicomplete only does method completion for python/3)? If so, would function completion in the last case above be an example of what snippets are for?

I am using MacVim in the terminal with tmux. My :version says VIM 8.0. I have +python/dyn and +python3/dyn features. My ~/.vimrc has this line (among others):

autocmd FileType python set omnifunc=python3complete#Complete

Right now, I'm only editing python3 files, so I think omnifunc=python3... is okay.

Semi-related SO post: Problem with Vim omnicomplete and system Python

EDIT: I may have a workaround, though I don't know how to implement it.

Observe that:

 import builtins
 builtins.pr<C-x><C-o>   gives-----> (dropdown menu with print() and property()    )
 builtins.pri<C-x><C-o>  gives-----> (autocompletes to builtins.print(             )

Can this action with <C-x><C-o> be replicated without writing import builtins and using a builtins object? Perhaps a <C-x><C-o> search assumes builtins. if the string preceding <C-x><C-o> has no . in it?

I'm all ears for any suggestions.

Community
  • 1
  • 1
user4396386
  • 423
  • 8
  • 15

2 Answers2

2

Just set Omni Completion like it is recommended in the Vim Wiki and it will work for all languages:

filetype plugin on
set omnifunc=syntaxcomplete#Complete
maxmoon
  • 43
  • 5
0

have you tried to use the following for the omnifunc:

autocmd FileType python set omnifunc=syntaxcomplete#Complete
padawin
  • 4,230
  • 15
  • 19