support python 3

This commit is contained in:
Justin Donaldson 2016-07-16 21:08:05 -07:00
parent a134e61a55
commit 2b70dfa3b2
4 changed files with 26 additions and 9 deletions

View file

@ -150,7 +150,7 @@ endfunction
" A function suitable for omnifunc
function! vaxe#HaxeComplete(findstart, base)
" ERROR: no python
if !has("python")
if !has("python") && !has("python3")
echoerr 'Vaxe requires python for completions'
return []
endif
@ -543,7 +543,7 @@ function! vaxe#JumpToDefinition()
let complete_output = s:RawCompletion(b:vaxe_hxml, extra)
" execute the python completion script in autoload/vaxe.py
call vaxe#Log(complete_output)
py locations('complete_output','output')
exec g:vaxe_py . "locations('complete_output','output')"
let output_str = join(output, '\n')
lexpr(output_str)
endfunction
@ -633,9 +633,9 @@ function! s:FormatDisplayCompletion(base)
call vaxe#Log('compiler output: ' . complete_output)
" execute the python completion script in autoload/vaxe.py
py complete('complete_output','output'
execute g:vaxepy . "complete('complete_output','output'
\, 'a:base', 'g:vaxe_completion_alter_signature'
\, 'g:vaxe_completion_collapse_overload')
\, 'g:vaxe_completion_collapse_overload')"
call vaxe#Log("display elements: " . len(output))
for o in output

View file

@ -14,7 +14,11 @@ if (!run_once)
" Utility variable that stores the directory that this script resides in
"Load the first time a haxe file is opened
let s:plugin_path = escape(expand('<sfile>:p:h') . '/../python/', '\')
exe 'pyfile '.s:plugin_path.'/vaxe.py'
if has("python3")
exe 'py3file '.s:plugin_path.'/vaxe.py'
elseif has("python")
exe 'pyfile '.s:plugin_path.'/vaxe.py'
endif
" load special configuration for vim-airline if it exists
if (exists("g:loaded_airline") && g:vaxe_enable_airline_defaults )

View file

@ -4,6 +4,12 @@ endif
let g:loaded_vaxe_plugin = 1
if has("python3")
let g:vaxepy = ":python3 "
elseif has("python")
let g:vaxepy = ":python "
endif
command -nargs=? -complete=file DefaultHxml call vaxe#DefaultHxml(<q-args>)
command -nargs=? -complete=file ProjectHxml call vaxe#ProjectHxml(<q-args>)
command VaxeToggleLogging let g:vaxe_logging = !g:vaxe_logging
@ -145,3 +151,5 @@ if (g:vaxe_enable_acp_defaults)
call add(g:acp_behavior['haxe'] , vaxe_entry)
endif

View file

@ -1,4 +1,10 @@
import vim, re, HTMLParser
import vim, re
try:
import HTMLParser
except:
from html.parser import HTMLParser
import xml.etree.ElementTree as ET
import json
@ -55,7 +61,7 @@ def complete(complete_output_var, output_var, base_var , alter_var, collapse_var
return { 'word': word, 'info': info, 'kind': kind
,'menu': menu, 'abbr': abbr, 'dup':1 }
completes = map(fieldxml2completion, fields)
completes = [fieldxml2completion(f) for f in fields]
elif len(types) > 0: # function type completion
otype = types[0].text.strip()
h = HTMLParser.HTMLParser()
@ -87,7 +93,6 @@ def complete(complete_output_var, output_var, base_var , alter_var, collapse_var
for c in completes:
if dict_complete[c['abbr']] > 1:
c['menu'] = "@:overload " + c['menu']
vim.command("let " + output_var + " = " + json.dumps(completes))
# simple script to grab lists of locations from display-mode completions
@ -107,7 +112,7 @@ def alter_signature(sig):
paren = 0
last_string = ''
final_expr = ''
for i in xrange(len(sig)):
for i in range(len(sig)):
c = sig[i]
if c == "(":
paren += 1