pythoncomplete does not work when "from XXX import YYY"

90 views
Skip to first unread message

mattn

unread,
Jul 21, 2011, 8:09:36 AM7/21/11
to vim...@googlegroups.com
Hi list.

when type '.' at following code, pythoncomplete does not work.
----------
from httplib import HTTPConnection
def autocomplete_in_function():
  h = HTTPConnection
  h.
----------

pythoncomplete does not check "from XXX import YYY" as "import".
Below is a patch. Please check and include.

BTW) I guess that it have better to check it as "^from\s+" or "^import\s+".

diff -r 1d1065c2e7fa runtime/autoload/python3complete.vim
--- a/runtime/autoload/python3complete.vim Wed Jul 20 18:29:39 2011 +0200
+++ b/runtime/autoload/python3complete.vim Thu Jul 21 21:04:26 2011 +0900
@@ -297,12 +297,12 @@
         str = ""
         if len(self.docstr) > 0: str += '"""'+self.docstr+'"""\n'
         for l in self.locals:
-            if l.startswith('import'): str += l+'\n'
+            if l.startswith('import') or l.startswith('from'): str += l+'\n'
         str += 'class _PyCmplNoType:\n    def __getattr__(self,name):\n        return None\n'
         for sub in self.subscopes:
             str += sub.get_code()
         for l in self.locals:
-            if not l.startswith('import'): str += l+'\n'
+            if not l.startswith('import') and not l.startswith('from'): str += l+'\n'
 
         return str
 
diff -r 1d1065c2e7fa runtime/autoload/pythoncomplete.vim
--- a/runtime/autoload/pythoncomplete.vim Wed Jul 20 18:29:39 2011 +0200
+++ b/runtime/autoload/pythoncomplete.vim Thu Jul 21 21:04:26 2011 +0900
@@ -315,12 +315,12 @@
         str = ""
         if len(self.docstr) > 0: str += '"""'+self.docstr+'"""\n'
         for l in self.locals:
-            if l.startswith('import'): str += l+'\n'
+            if l.startswith('import') or l.startswith('from'): str += l+'\n'
         str += 'class _PyCmplNoType:\n    def __getattr__(self,name):\n        return None\n'
         for sub in self.subscopes:
             str += sub.get_code()
         for l in self.locals:
-            if not l.startswith('import'): str += l+'\n'
+            if not l.startswith('import') and not l.startswith('from'): str += l+'\n'
 
         return str
 

Bram Moolenaar

unread,
Jul 21, 2011, 4:29:23 PM7/21/11
to mattn, vim...@googlegroups.com, Aaron Griffin

Mattn wrote:

> Hi list.
>
> when type '.' at following code, pythoncomplete does not work.
> ----------
> from httplib import HTTPConnection
> def autocomplete_in_function():
> h = HTTPConnection
> h.
> ----------
>
> pythoncomplete does not check "from XXX import YYY" as "import".
> Below is a patch. Please check and include.

Let me copy the maintainer on this.


--
A vacation is a period of travel during which you find that you
took twice as many clothes and half as much money as you needed.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Yasuhiro MATSUMOTO

unread,
Jul 22, 2011, 1:04:20 PM7/22/11
to vim...@googlegroups.com
ok, attached the patch.

> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>

--
- Yasuhiro Matsumoto

pythoncomplete-fix.diff
Reply all
Reply to author
Forward
0 new messages