123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- let s:cpo_save=&cpo
- set cpo&vim
-
-
- function! lh#command#verbose(level)
- let s:verbose = a:level
- endfunction
-
- function! s:Verbose(expr)
- if exists('s:verbose') && s:verbose
- echomsg a:expr
- endif
- endfunction
-
- function! lh#command#debug(expr)
- return eval(a:expr)
- endfunction
-
-
-
-
-
-
-
-
- function! lh#command#Fargs2String(aList)
- if empty(a:aList) | return '' | endif
-
- let quote_char = a:aList[0][0]
- let res = a:aList[0]
- call remove(a:aList, 0)
- if quote_char !~ '["'."']"
- return res
- endif
-
- let end_string = '[^\\]\%(\\\\\)*'.quote_char.'$'
- while !empty(a:aList) && res !~ end_string
- let res .= ' ' . a:aList[0]
- call remove(a:aList, 0)
- endwhile
- return res
- endfunction
-
-
-
-
-
-
-
-
-
-
- let s:data_id = 0
- function! s:SaveData(Data)
- if has_key(a:Data, "command_id")
-
- return a:Data.command_id
- else
- let s:Data{s:data_id} = a:Data
- let id = s:data_id
- let s:data_id += 1
- let a:Data.command_id = id
- return id
- endif
- endfunction
-
-
- function! lh#command#complete(ArgLead, CmdLine, CursorPos)
- let tmp = substitute(a:CmdLine, '\s*\S*', 'Z', 'g')
- let pos = strlen(tmp)
- if 0
- call confirm( "AL = ". a:ArgLead."\nCL = ". a:CmdLine."\nCP = ".a:CursorPos
- \ . "\ntmp = ".tmp."\npos = ".pos
- \, '&Ok', 1)
- endif
-
- if 2 == pos
-
- return s:commands
- elseif 3 == pos
-
- if -1 != match(a:CmdLine, '^BTW\s\+echo')
- return s:functions . "\n" . s:variables
- elseif -1 != match(a:CmdLine, '^BTW\s\+\%(help\|?\)')
- elseif -1 != match(a:CmdLine, '^BTW\s\+\%(set\|add\)\%(local\)\=')
-
-
-
-
- let files = s:FindFilter('*')
- let files = substitute(files,
- \ '\(^\|\n\).\{-}compiler[\\/]BTW[-_\\/]\(.\{-}\)\.vim\>\ze\%(\n\|$\)',
- \ '\1\2', 'g')
- return files
- elseif -1 != match(a:CmdLine, '^BTW\s\+remove\%(local\)\=')
-
- return substitute(s:FiltersList(), ',', '\n', 'g')
- endif
- endif
-
- echoerr 'BTW: unespected parameter ``'. a:ArgLead ."''"
- return ''
- endfunction
-
- function! s:BTW(command, ...)
-
- if 'set' == a:command | let g:BTW_build_tool = a:1
- if exists('b:BTW_build_tool')
- let b:BTW_build_tool = a:1
- endif
- elseif 'setlocal' == a:command | let b:BTW_build_tool = a:1
- elseif 'add' == a:command | call s:AddFilter('g', a:1)
- elseif 'addlocal' == a:command | call s:AddFilter('b', a:1)
- " if exists('b:BTW_filters_list') " ?????
-
-
- elseif 'remove' == a:command | call s:RemoveFilter('g', a:1)
- elseif 'removelocal' == a:command | call s:RemoveFilter('b', a:1)
- elseif 'rebuild' == a:command
- elseif 'echo' == a:command | exe "echo s:".a:1
-
- elseif 'reloadPlugin' == a:command
- let g:force_reload_BuildToolsWrapper = 1
- let g:BTW_BTW_in_use = 1
- exe 'so '.s:sfile
- unlet g:force_reload_BuildToolsWrapper
- unlet g:BTW_BTW_in_use
- return
- elseif a:command =~ '\%(help\|?\)'
- call s:Usage()
- return
- endif
- call s:ReconstructToolsChain()
- endfunction
-
-
-
-
- function! s:FindSubcommand(definition, subcommand)
- for arg in a:definition.arguments
- if arg.name == a:subcommand
- return arg
- endif
- endfor
- throw "NF"
- endfunction
-
- function! s:execute_function(definition, params)
- if len(a:params) < 1
- throw "(lh#command) Not enough arguments"
- endif
- let l:Fn = a:definition.action
- echo "calling ".string(l:Fn)
- echo "with ".string(a:params)
-
- call l:Fn(a:params)
- endfunction
-
- function! s:execute_sub_commands(definition, params)
- try
- if len(a:params) < 1
- throw "(lh#command) Not enough arguments"
- endif
- let subcommand = s:FindSubcommand(a:definition, a:params[0])
- call remove(a:params, 0)
- call s:int_execute(subcommand, a:params)
- catch /NF.*/
- throw "(lh#command) Unexpected subcommand `".a:params[0]."'."
- endtry
- endfunction
-
- function! s:int_execute(definition, params)
- echo "params=".string(a:params)
- call s:execute_{a:definition.arg_type}(a:definition, a:params)
- endfunction
-
- function! s:execute(definition, ...)
- try
- let params = copy(a:000)
- call s:int_execute(a:definition, params)
- catch /(lh#command).*/
- echoerr v:exception . " in `".a:definition.name.' '.join(a:000, ' ')."'"
- endtry
- endfunction
-
- function! lh#command#new(definition)
- let cmd_name = a:definition.name
-
- let id = s:SaveData(a:definition)
- exe "command! -nargs=* ".cmd_name." :call s:execute(s:Data".id.", <f-args>)"
- endfunction
-
-
-
- let &cpo=s:cpo_save
-
|