diff --git a/vimfiles.stefan/plugin/toptica.vim b/vimfiles.stefan/plugin/toptica.vim index 8ee94a8..3a2421d 100644 --- a/vimfiles.stefan/plugin/toptica.vim +++ b/vimfiles.stefan/plugin/toptica.vim @@ -143,14 +143,14 @@ function! s:ProjectSet(project_type, project_base_dir) let s:use_invoke = v:true set wildignore-=**/firmware/src/device-control/** set wildignore+=**/shg-firmware/** - " set titlestring=%<%t\ (%{expand('%:p:h')})%=compiler:\ %{Compiler_version()} + set titlestring=%<%t\ (%{expand('%:p:h')})%=project:\ %{g:project_type}\ \ \ \ compiler:\ %{Compiler_version()} let g:DeviceIP = 'dlc_pro__040083' call s:set_oselas_gcc() let g:termdebugger = '/opt/OSELAS.Toolchain-2022.10.2/arm-v7a-linux-gnueabihf/gcc-12.3.1-glibc-2.33-binutils-2.39-kernel-5.4-sanitized/bin/arm-v7a-linux-gnueabihf-gdb' let g:DebugRemote = v:true - command DlcproEmissionOn call s:DlcproEmission('1') - command DlcproEmissionOff call s:DlcproEmission('0') - command DlcproShutup call s:DlcproShutup() + command! DlcproEmissionOn call s:DlcproEmission('1') + command! DlcproEmissionOff call s:DlcproEmission('0') + command! DlcproShutup call s:DlcproShutup() elseif (g:project_type == 'dlcpro-old') let s:Program = '/device-control/device-control' let s:Elffile = s:Program @@ -166,9 +166,9 @@ function! s:ProjectSet(project_type, project_base_dir) let g:SshOpts = "" let g:SshOpts2 = "" call s:set_oselas_gcc() - command DlcproEmissionOn call s:DlcproEmission('1') - command DlcproEmissionOff call s:DlcproEmission('0') - command DlcproShutup call s:DlcproShutup() + command! DlcproEmissionOn call s:DlcproEmission('1') + command! DlcproEmissionOff call s:DlcproEmission('0') + command! DlcproShutup call s:DlcproShutup() elseif ((g:project_type == 'dlcpro-tui') || (g:project_type == 'dlcpro-tui-simulator')) let s:Program = '/user-interface/src/user-interface' let s:Elffile = s:Program @@ -184,7 +184,7 @@ function! s:ProjectSet(project_type, project_base_dir) let g:SshOpts2 = "" call s:set_oselas_gcc4() " command DlcproTuiStart execute('!cd user-interface/src && ../../../build/user-interface/src/user-interface&') - command DlcProTuiStart call s:DlcproTuiStart() + command! DlcProTuiStart call s:DlcproTuiStart() elseif (g:project_type == 'dlcpro-can') let s:Program = '/canopen/can-updater' let s:Elffile = s:Program @@ -353,7 +353,7 @@ function! s:ProjectSet(project_type, project_base_dir) let g:Program = g:ProjectBuildDir.s:Program let g:Elffile = g:ProjectBuildDir.s:Elffile endif - command! -complete=custom,GetAllMakeCompletions -nargs=* MakeCmd call s:Make('', 0) + command! -complete=customlist,GetAllMakeCompletions -nargs=* MakeCmd call s:Make('', 0) command! MakeTestBuild call s:MakeTestBuild() command! -nargs=* Ctest call s:Ctest('', 0) command! -nargs=* Ctest1 call s:Ctest1('', 0) @@ -382,7 +382,11 @@ function! s:ProjectSet(project_type, project_base_dir) function! s:DeviceFirmwareUpdate() if s:use_invoke - execute "!invoke -e flash-and-run --target-ip ".g:DeviceIP + let l:options = ' --project=dlcpro' + if g:new_compiler + let l:options .= ' --new-compiler' + endif + execute "!invoke -e flash-and-run --target-ip ".g:DeviceIP.l:options elseif (g:project_type == 'dlcpro-can') call s:DeviceUpdateProgramLinux() elseif ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor') || (g:project_type == 'pfd')) @@ -421,9 +425,40 @@ endfunction " ==== function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos) if s:use_invoke - let l:makegoals = split(system('invoke targets')) - let l:invoke_targets = ['--target'] - return join(l:makegoals + l:invoke_targets + glob(a:ArgLead.'*', 1, 1), "\n") + let CmdList = split(a:CmdLine) + let makegoals = [] + let makegoals += split(system('invoke -c ~/tools/invoke/'.g:project_type.'/tasks --complete --')) + if len(CmdList) > 1 + let last_goal = CmdList[-1] + if a:ArgLead[0] == '-' || a:ArgLead == '' && last_goal[0] == '-' + let last_goal = CmdList[-2] + let last_opt = CmdList[-1] + elseif a:ArgLead != '' && a:ArgLead[0] != '-' && len(CmdList) > 2 + let last_goal = CmdList[-3] + let last_opt = CmdList[-2] + endif + " Expand option + if count(makegoals, last_goal) > 0 + let makegoals += split(system('invoke -c ~/tools/invoke/'.g:project_type.'/tasks --complete -- '.last_goal.' -')) + endif + if exists('last_opt') + " Expand values of option + let helptext = systemlist('invoke -c ~/tools/invoke/'.g:project_type.'/tasks '.last_goal.' --help') + let i = match(helptext, last_opt) + if i > 0 + let values = [] + call substitute(helptext[i], '"\([^"]\+\)"', '\=add(values, submatch(1))', 'g') + if len(values) > 0 + let makegoals += values + endif + endif + endif + endif + if a:ArgLead != '' + " Filter option if started to type + call filter(makegoals, 'v:val =~ "^'. a:ArgLead .'"') + endif + return makegoals else return join(s:makegoals + s:makeopts + glob(a:ArgLead.'*', 1, 1), "\n") endif @@ -433,7 +468,7 @@ function! s:Make(args, async_mode) call asyncrun#quickfix_toggle(10, 1) if s:use_invoke " let l:makeprg = 'invoke -e build --project '.g:project_type - let l:makeprg = 'invoke -e build' + let l:makeprg = 'invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e build' if g:new_compiler let l:makeprg .= ' --new-compiler' endif @@ -477,7 +512,7 @@ function! s:Cmake(options, async_mode) let l:options .= ' --no-new-compiler' endif execute '!echo "invoke cmake '.l:options.'"' - execute 'AsyncRun -mode='.a:async_mode.' -save=2 @ invoke -e cmake '.l:options + execute 'AsyncRun -mode='.a:async_mode.' -save=2 @ invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e cmake '.l:options else if !isdirectory(g:ProjectBuildDir) call mkdir(g:ProjectBuildDir) @@ -630,7 +665,7 @@ endfunction function! s:DeviceStartGdbServer() if (g:project_type == 'pfd') call system('killall --quiet JLinkGDBServer') - call s:Call_and_log('invoke -e jlink&') + call s:Call_and_log('invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e jlink&') autocmd User TermdebugStopPost call system('killall --quiet JLinkGDBServer') sleep 1 elseif ((g:project_type == 'digifalc') || (g:project_type == 'servoboard') || (g:project_type == 'dl-motor')) @@ -690,14 +725,17 @@ endfunction let g:DlcproBasePath = "/jenkins/workspace/pro--firmware_release_1.9.0-DCESJ5C5R577IG5QFEWTML22UFDDZCJDGFLMDA4DCD3V2ZAGVEJA/source/" function! s:DeviceDebug(attach) if s:use_invoke - if v:DebugRemote - execute "!invoke -e gdb-server --target-ip=".g:DeviceIP + if g:DebugRemote + execute "!invoke -c ~/tools/invoke/'.g:project_type.'/tasks -e gdb-server --target-ip=".g:DeviceIP + autocmd! User TermdebugStartPre autocmd! User TermdebugStartPost autocmd! User TermdebugStopPost - autocmd User TermdebugStartPost call term_sendkeys('',"source gdb-connect.txt\n") + autocmd User TermdebugStartPost call term_sendkeys('',"cd .build/dlcpro-new\nsource ../../gdb-connect.txt\n") autocmd User TermdebugStopPost call system('pkill --full gdbserver') endif Termdebug + " Close Program window + execute '2hide' else if (a:attach == 0) " let r = s:DeviceFirmwareUpdate()