|
1 | 1 | "pythoncomplete.vim - Omni Completion for python |
2 | 2 | " Maintainer: Aaron Griffin <[email protected]> |
3 | | -" Version: 0.6 |
4 | | -" Last Updated: 14 May 2006 |
| 3 | +" Version: 0.7 |
| 4 | +" Last Updated: 19 Oct 2006 |
| 5 | +" |
| 6 | +" Changes |
| 7 | +" TODO: |
| 8 | +" User defined docstrings aren't handled right... |
| 9 | +" 'info' item output can use some formatting work |
| 10 | +" Add an "unsafe eval" mode, to allow for return type evaluation |
| 11 | +" Complete basic syntax along with import statements |
| 12 | +" i.e. "import url<c-x,c-o>" |
| 13 | +" Continue parsing on invalid line?? |
| 14 | +" |
| 15 | +" v 0.7 |
| 16 | +" * Fixed function list sorting (_ and __ at the bottom) |
| 17 | +" * Removed newline removal from docs. It appears vim handles these better in |
| 18 | +" recent patches |
5 | 19 | " |
6 | 20 | " v 0.6: |
7 | 21 | " * Fixed argument completion |
|
15 | 29 | " It was a bugfix version on top of 0.3. This is a complete |
16 | 30 | " rewrite. |
17 | 31 | " |
18 | | -" Changes |
19 | | -" TODO: |
20 | | -" User defined docstrings aren't handled right... |
21 | | -" 'info' item output can use some formatting work |
22 | | -" Add an "unsafe eval" mode, to allow for return type evaluation |
23 | 32 |
|
24 | 33 | if !has('python') |
25 | 34 | echo "Error: Required vim compiled with +python" |
@@ -82,7 +91,24 @@ def vimcomplete(context,match): |
82 | 91 | try: |
83 | 92 | import vim |
84 | 93 | def complsort(x,y): |
85 | | - return x['abbr'] > y['abbr'] |
| 94 | + try: |
| 95 | + xa = x['abbr'] |
| 96 | + ya = y['abbr'] |
| 97 | + if xa[0] == '_': |
| 98 | + if xa[1] == '_' and ya[0:2] == '__': |
| 99 | + return xa > ya |
| 100 | + elif ya[0:2] == '__': |
| 101 | + return -1 |
| 102 | + elif y[0] == '_': |
| 103 | + return xa > ya |
| 104 | + else: |
| 105 | + return 1 |
| 106 | + elif ya[0] == '_': |
| 107 | + return -1 |
| 108 | + else: |
| 109 | + return xa > ya |
| 110 | + except: |
| 111 | + return 0 |
86 | 112 | cmpl = Completer() |
87 | 113 | cmpl.evalsource('\n'.join(vim.current.buffer),vim.eval("line('.')")) |
88 | 114 | all = cmpl.get_completions(context,match) |
@@ -117,11 +143,7 @@ class Completer(object): |
117 | 143 | except: dbg("locals: %s, %s [%s]" % (sys.exc_info()[0],sys.exc_info()[1],l)) |
118 | 144 |
|
119 | 145 | def _cleanstr(self,doc): |
120 | | - return doc.replace('"',' ')\ |
121 | | - .replace("'",' ')\ |
122 | | - .replace('\n',' ')\ |
123 | | - .replace('\r',' ')\ |
124 | | - .replace('',' ') |
| 146 | + return doc.replace('"',' ').replace("'",' ') |
125 | 147 |
|
126 | 148 | def get_arguments(self,func_obj): |
127 | 149 | def _ctor(obj): |
|
0 commit comments