mirror of
https://github.com/jdonaldson/vaxe
synced 2024-09-16 13:44:03 +02:00
add flow support
This commit is contained in:
parent
9ae27351d6
commit
98b90c37c5
4 changed files with 134 additions and 3 deletions
|
@ -14,6 +14,8 @@ endfunction
|
|||
function! vaxe#CurrentTarget()
|
||||
if exists("g:vaxe_lime_target")
|
||||
return "g:vaxe_lime_target"
|
||||
elseif exists("g:vaxe_flow_target")
|
||||
return "g:vaxe_flow_target"
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
|
@ -222,6 +224,8 @@ endfunction
|
|||
function! vaxe#AutomaticHxml()
|
||||
if exists ("g:vaxe_lime")
|
||||
call vaxe#lime#ProjectLime(g:vaxe_lime)
|
||||
elseif exists ("g:vaxe_flow")
|
||||
call vaxe#flow#ProjectFlow(g:vaxe_flow)
|
||||
elseif exists('g:vaxe_hxml')
|
||||
call vaxe#ProjectHxml(g:vaxe_hxml)
|
||||
else
|
||||
|
@ -238,7 +242,7 @@ function! vaxe#DefaultHxml(...)
|
|||
unlet b:vaxe_hxml
|
||||
endif
|
||||
|
||||
"First check if an hxml/lime was passed explicitly
|
||||
"First check if an hxml/lime/flow was passed explicitly
|
||||
if a:0 > 0 && a:1 != ''
|
||||
if match(a:1,'\.hxml$')
|
||||
let b:vaxe_hxml = a:1
|
||||
|
@ -246,8 +250,10 @@ function! vaxe#DefaultHxml(...)
|
|||
let g:vaxe_lime = a:1
|
||||
elseif match(a:1,'\.lime$' )
|
||||
let g:vaxe_lime = a:1
|
||||
elseif match(a:1,'\.flow$' )
|
||||
let g:vaxe_flow = a:1
|
||||
endif
|
||||
else " check if there's a lime in the parent roots...
|
||||
else " check if there's a lime/flow in the parent roots...
|
||||
let base_build = vaxe#util#ParentSearch(
|
||||
\ g:vaxe_default_parent_search_patterns
|
||||
\ , fnamemodify(expand("%"),":p:h"))
|
||||
|
@ -268,6 +274,9 @@ function! vaxe#DefaultHxml(...)
|
|||
elseif base_build =~ '\.xml'
|
||||
let b:vaxe_lime = base_build
|
||||
call vaxe#lime#BuildLimeHxml(b:vaxe_lime)
|
||||
elseif base_build =~ '\.flow'
|
||||
let b:vaxe_flow = base_build
|
||||
call vaxe#flow#BuildFlowHxml(b:vaxe_flow)
|
||||
else
|
||||
let b:vaxe_hxml = base_build
|
||||
endif
|
||||
|
@ -331,6 +340,9 @@ function! vaxe#SetCompiler()
|
|||
endif
|
||||
let build_command = "cd " . escaped_wd . " && "
|
||||
\."lime ".build_verb." ". g:vaxe_lime_target . " 2>&1"
|
||||
elseif exists("g:vaxe_flow") || exists("b:vaxe_flow")
|
||||
let build_command = "cd " . escaped_wd . " && "
|
||||
\."haxelib run flow build " . g:vaxe_flow_target . " 2>&1"
|
||||
else
|
||||
let vaxe_hxml = vaxe#CurrentBuild()
|
||||
let escaped_hxml = fnameescape(vaxe_hxml)
|
||||
|
|
103
autoload/vaxe/flow.vim
Normal file
103
autoload/vaxe/flow.vim
Normal file
|
@ -0,0 +1,103 @@
|
|||
function! vaxe#flow#Targets(...)
|
||||
return s:flow_targets
|
||||
endfunction
|
||||
|
||||
function! vaxe#flow#ProjectFlow(...)
|
||||
if exists('g:vaxe_flow')
|
||||
unlet g:vaxe_flow
|
||||
endif
|
||||
let g:vaxe_working_directory = getcwd()
|
||||
|
||||
if a:0 > 0 && a:1 != ''
|
||||
let g:vaxe_flow = expand(a:1,':p')
|
||||
else
|
||||
let flows = split(glob("**/*.flow"),'\n')
|
||||
|
||||
if len(flows) == 0
|
||||
echoerr "No flow/openfl project files found in current working directory"
|
||||
return
|
||||
endif
|
||||
|
||||
let base_flow = vaxe#util#InputList("Select flow", flows)
|
||||
|
||||
if base_flow !~ "^\([a-zA-Z]:\)\=[/\\]"
|
||||
let base_flow = getcwd() . '/' . base_flow
|
||||
endif
|
||||
|
||||
echomsg 'Project flow selected: ' . base_flow
|
||||
|
||||
let g:vaxe_flow = base_flow
|
||||
endif
|
||||
if !filereadable(g:vaxe_flow)
|
||||
echoerr "Project flow file not valid, please create one."
|
||||
return
|
||||
endif
|
||||
call vaxe#flow#BuildFlowHxml(g:vaxe_flow)
|
||||
call vaxe#SetCompiler()
|
||||
return g:vaxe_flow
|
||||
endfunction
|
||||
|
||||
function! vaxe#flow#Clean(...)
|
||||
if (a:0 && a:1 != '')
|
||||
let target = split(a:1)[0]
|
||||
else
|
||||
let target = g:vaxe_flow_target
|
||||
endif
|
||||
let command = "flow clean ".target
|
||||
call vaxe#Log(command)
|
||||
call s:Sys(command)
|
||||
endfunction
|
||||
|
||||
"A simple system function that first changes directory to the current vaxe
|
||||
"working directory
|
||||
function! s:Sys(cmd)
|
||||
call system("cd ".g:vaxe_working_directory." && ".a:cmd)
|
||||
endfunction
|
||||
|
||||
function! vaxe#flow#BuildFlowHxml(flow)
|
||||
let base_hxml = a:flow.".hxml"
|
||||
|
||||
if !strlen(g:vaxe_flow_target)
|
||||
call vaxe#flow#Target(a:flow)
|
||||
endif
|
||||
|
||||
let g:vaxe_working_directory = fnamemodify(a:flow, ":p:h")
|
||||
let cdcmd = 'cd "'.fnameescape(g:vaxe_working_directory).'" && '
|
||||
|
||||
"create the flow.hxml if not present
|
||||
if !filereadable(base_hxml)
|
||||
" pipe flow display to an hxml for completions
|
||||
let escape_base = fnameescape(base_hxml)
|
||||
call s:Sys(" echo '# THIS FILE IS AUTOGENERATED BY VAXE, ANY EDITS ARE DISCARDED' " . " > " . escape_base)
|
||||
call s:Sys(" haxelib run flow info " . g:vaxe_flow_target . " --hxml "
|
||||
\. " >> " . escape_base )
|
||||
endif
|
||||
|
||||
let b:vaxe_hxml = base_hxml
|
||||
" let g:vaxe_hxml = b:vaxe_hxml " don't set a global projet var by default
|
||||
endfunction
|
||||
|
||||
"Sets the target. If target is missing it asks the user. Also updates the
|
||||
"makeprg compiler command
|
||||
function! vaxe#flow#Target(flow, ...)
|
||||
let g:vaxe_flow_target = ''
|
||||
if a:0 > 1 && a:2 != ''
|
||||
let g:vaxe_flow_target = a:2
|
||||
else
|
||||
let g:vaxe_flow_target = vaxe#util#InputList("Select flow Target", s:flow_targets)
|
||||
let g:vaxe_flow_target = split(g:vaxe_flow_target, ":")[0]
|
||||
endif
|
||||
call vaxe#flow#BuildFlowHxml(a:flow)
|
||||
call vaxe#SetCompiler()
|
||||
endfunction
|
||||
|
||||
" A list of all the flow targets
|
||||
let s:flow_targets = [ "android : Create Google Android applications"
|
||||
\, "web : Create HTML5 webgl applications"
|
||||
\, "ios : Create Apple iOS applications"
|
||||
\, "linux --arch 32 : Create Linux 32-bit applications"
|
||||
\, "linux --arch 64 : Create Linux 64-bit applications"
|
||||
\, "mac --arch 32 : Create Apple Mac OS X 32-bit applications"
|
||||
\, "mac --arch 64 : Create Apple Mac OS X 64-bit applications"
|
||||
\, "windows --arch 32 : Create Microsoft Windows 32-bit applications"
|
||||
\, "windows --arch 64 : Create Microsoft Windows 64-bit applications"]
|
1
ftdetect/flow.vim
Normal file
1
ftdetect/flow.vim
Normal file
|
@ -0,0 +1 @@
|
|||
autocmd BufNewFile,BufRead *.flow set filetype=flow.javascript
|
|
@ -21,6 +21,16 @@ command -nargs=? -complete=customlist,vaxe#lime#Targets LimeClean
|
|||
command -nargs=? -complete=customlist,vaxe#lime#Targets LimeUpdate
|
||||
\ call vaxe#lime#Update(<q-args>)
|
||||
|
||||
" Flow commands
|
||||
command -nargs=? -complete=file ProjectFlow
|
||||
\ call vaxe#flow#ProjectFlow(<q-args>)
|
||||
|
||||
command -nargs=? -complete=customlist,vaxe#flow#Targets FlowTarget
|
||||
\ call vaxe#flow#Target(<q-args>)
|
||||
|
||||
command -nargs=? -complete=customlist,vaxe#flow#Targets FlowClean
|
||||
\ call vaxe#flow#Clean(<q-args>)
|
||||
|
||||
" Completion Server Commands
|
||||
command VaxeStopCompletionServer call vaxe#KillCacheServer()
|
||||
command VaxeStartCompletionServer call vaxe#StartCacheServer()
|
||||
|
@ -76,14 +86,19 @@ let g:vaxe_lime_test_on_build = C('g:vaxe_lime_test_on_build', 1)
|
|||
let g:vaxe_lime_target = C('g:vaxe_lime_target',"")
|
||||
let g:vaxe_lime_completion_target = C('g:vaxe_lime_completion_target', 'flash')
|
||||
|
||||
" flow options
|
||||
let g:vaxe_flow_target = C('g:vaxe_flow_target', "")
|
||||
let g:vaxe_flow_completion_target = C('g:vaxe_flow_completion_target', 'web')
|
||||
|
||||
" default build options
|
||||
let g:vaxe_prefer_hxml = C('g:vaxe_prefer_hxml', "build.hxml")
|
||||
let g:vaxe_prefer_lime = C('g:vaxe_prefer_lime', "*.lime")
|
||||
let g:vaxe_prefer_flow = C('g:vaxe_prefer_flow', "*.flow")
|
||||
let g:vaxe_prefer_openfl = C('g:vaxe_prefer_openfl', "project.xml")
|
||||
let g:vaxe_prefer_first_in_directory = C('g:vaxe_prefer_first_in_directory', 1)
|
||||
let g:vaxe_default_parent_search_patterns
|
||||
\= C('g:vaxe_default_parent_search_patterns'
|
||||
\, [g:vaxe_prefer_lime, g:vaxe_prefer_openfl, g:vaxe_prefer_hxml, "*.hxml"])
|
||||
\, [g:vaxe_prefer_lime, g:vaxe_prefer_flow, g:vaxe_prefer_openfl, g:vaxe_prefer_hxml, "*.hxml"])
|
||||
|
||||
" Supported 3rd party plugin options
|
||||
let g:vaxe_enable_airline_defaults = C('g:vaxe_enable_airline_defaults', 1)
|
||||
|
|
Loading…
Reference in a new issue