Various fixes for pythoncomplete.vim#1
Open
meermanr wants to merge 7 commits intovim-scripts:masterfrom
Open
Conversation
added 5 commits
February 4, 2012 19:47
Prior to this patch opening parenthesis were not considered part of the current word, so a completion token such as ``myfunc(`` would never test positive for a trailing ``(``.
This patch fixes completion of parameters required by a class when creating a new instance. For example completing ``MyClass(`` should take the parameters from ``MyClass.__init__``. The ``_ctor`` closure within ``Completer.get_arguments`` always raised a NameError exception because the function signature named its incoming argument ``obj`` rather than ``class_ob``.
The test that determined if ``func_obj`` is a class did not cope with
meta-classes (which are both a class, and a type). Generally ``type()``
is not a robust way to reason about the Python objects, so this patch
replaces all checks of the form::
type(foo) == types.FooType
with calls to the ``inspect`` module, for instance::
inspect.isclass(foo)
inspect.ismethod(foo)
inspect.isfuction(foo)
Completed parameters are space and comma seperated, instead of just
being comma seperated. Old behaviour::
myfunc(a,b,c)
New behaviour::
myfunc(a, b, c)
This better matches common practice, and the exampels in PEP 8 [1]_. If
this upsets established users, a configuration variable could be created
to control it.
.. [1] http://www.python.org/dev/peps/pep-0008/
Author
|
Regarding my proposal to rename the script (to FWIW, I believe that |
This patch renames ``pythoncomplete.py`` to ``python_complete.py`` since
the latter is automatically loaded by Vim (tested with v7.3).
Using Vim's tracing feature (e.g. ``vim -Vtrace.log somefile.py``) I
discovered that Vim does not automatically load
``$HOME/.vim/ftplugin/pythoncomplete.vim`` without additional
configuration, it only considers the following::
Searching for
ftplugin/python.vim
ftplugin/python_*.vim
ftplugin/python/*.vim
in
$HOME/.vim
/var/lib/vim/addons
/usr/share/vim/vimfiles
/usr/share/vim/vim73
/usr/share/vim/vimfiles/after
/var/lib/vim/addons/after
$HOME/.vim/after
Note that the default distribution of Vim v7.3 [1]_ includes
`ftplugin/python.vim` which contains the following line::
setlocal omnifunc=pythoncomplete#Complete
This conflicts with the changed introduced in this patch, and is no longer
needed (since this script now sets 'omnifunc' itself).
.. [1] At least, it does on Ubuntu v11.10's "vim-runtime" package, version
"2:7.3.154+hg~74503f6ee649-2ubuntu3"
Until the stock `ftplugin/python.vim` drops its definition for 'omnifunc' `python_complete.vim` must be loaded after system defaults to ensure it is actually used. Should this version of `python_complete.vim` become the new stock version, users should install future updates into `$HOME/.vim/ftplugin`, since a guard at the top of the script will preventing existing definitions being replaced.
somini
added a commit
to somini/dotvim
that referenced
this pull request
Jan 21, 2016
It comes by default, but I hadn't exposed it in the SuperTab configuration. I better source/investigate a better omnicomplete function, such as: https://github.com/mjbrownie/pythoncomplete.vim vim-scripts/pythoncomplete#1 but for now, this will do. I'll have to search for a way to customize the preview window that appears on top of the window containing the pydoc for the corresponding function (Hot Damn! It's starting to look like a proper IDE).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please consider my commits for inclusion in pythoncomplete.vim. Most are bug fixes related to the completion of callable (function/class-constructor) parameters.
There are also 2x enhancements: parameter completion adds a space after commas, a newline at the end of the file (to stop git complaining).
I've also RENAMED the script from pythoncomplete.vim to python_complete.vim since the former is not automatically loaded by Vim (v7.3), but the latter is. Please see the commit log for my full justification.
And let me say thanks for producing such a useful script!