vim-jp/issues — Issue #78: pythonの補完が効かない
Author: mattn
Created: 2011-10-13 01:27:23+00:00
State: open

既にパッチ送付済みの物ですが、忘れない為に。

runtime/autoload/pythoncomplete.vim
runtime/autoload/python3complete.vim

で`import`した物からコード補完出きるのですが

import foo

だけしか対応していなくて

from bar import foo

によるコード補完が効かないという問題。

```diff
diff -r f530aef0d959 runtime/autoload/python3complete.vim
--- a/runtime/autoload/python3complete.vim	Wed Oct 12 22:02:14 2011 +0200
+++ b/runtime/autoload/python3complete.vim	Thu Oct 13 10:23:04 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 f530aef0d959 runtime/autoload/pythoncomplete.vim
--- a/runtime/autoload/pythoncomplete.vim	Wed Oct 12 22:02:14 2011 +0200
+++ b/runtime/autoload/pythoncomplete.vim	Thu Oct 13 10:23:04 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

```