From 8af54476a85cc0670ed0e1525266b4936721b967 Mon Sep 17 00:00:00 2001 From: Stefan Liebl Date: Wed, 5 Feb 2025 13:57:39 +0100 Subject: [PATCH] add vim-bash-completion to complete MakeCmd --- pack/plugins/opt/vim-bash-completion | 1 + vimfiles.stefan/plugin/toptica.vim | 51 ++++++++-------------------- vimfiles.stefan/vimrc | 1 + 3 files changed, 16 insertions(+), 37 deletions(-) create mode 160000 pack/plugins/opt/vim-bash-completion diff --git a/pack/plugins/opt/vim-bash-completion b/pack/plugins/opt/vim-bash-completion new file mode 160000 index 0000000..5f81662 --- /dev/null +++ b/pack/plugins/opt/vim-bash-completion @@ -0,0 +1 @@ +Subproject commit 5f8166213359dabdcb5e36d892c410fef14cacbf diff --git a/vimfiles.stefan/plugin/toptica.vim b/vimfiles.stefan/plugin/toptica.vim index c4b2bb3..b06edb2 100644 --- a/vimfiles.stefan/plugin/toptica.vim +++ b/vimfiles.stefan/plugin/toptica.vim @@ -251,7 +251,7 @@ function! s:ProjectSet(project_type, project_base_dir) function! s:DeviceFirmwareUpdate() call s:Make('kill', 'bang') call s:Make('flash', 'bang') - call s:Make('run', 'bang') + call s:Make('start', 'bang') endfunction command! DeviceDebug call s:DeviceDebug(0) @@ -266,42 +266,6 @@ endfunction " ==== " Make " ==== -function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos) - let CmdList = split(a:CmdLine) - let tasks = [] - let tasks += split(system(s:invoke.' --complete --')) - if len(CmdList) > 1 - let last_task = CmdList[-1] - if a:ArgLead[0] == '-' || a:ArgLead == '' && last_task[0] == '-' - let last_task = CmdList[-2] - let last_opt = CmdList[-1] - elseif a:ArgLead != '' && a:ArgLead[0] != '-' && len(CmdList) > 2 - let last_task = CmdList[-3] - let last_opt = CmdList[-2] - endif - " Expand option - if count(tasks, last_task) > 0 - let tasks += split(system(s:invoke.' --complete -- '.last_task.' -')) - endif - if exists('last_opt') - " Expand values of option - let helptext = systemlist(s:invoke.' '.last_task.' --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 tasks += values - endif - endif - endif - endif - if a:ArgLead != '' - " Filter option if started to type - call filter(tasks, 'v:val =~ "^'. a:ArgLead .'"') - endif - return tasks -endfunction function! s:Make(args, async_mode) call asyncrun#quickfix_toggle(10, 1) @@ -331,6 +295,19 @@ function! s:Make(args, async_mode) execute 'AsyncRun -mode='.a:async_mode.' -save=2 -program=make @ '.l:args endfunction +" Tab-completion is done with plugin vim-bash-completion +let $BASH_COMPLETION_DIR = '/home/stefan/.invoke' +let invoke_completion_file = $BASH_COMPLETION_DIR.'/bash_completion' +if !filereadable(invoke_completion_file) + call system('invoke --print-completion-script bash > '.invoke_completion_file) +endif +function! GetAllMakeCompletions(ArgLead, CmdLine, CursorPos) + let l:words = split(a:CmdLine) + let l:words[0] = 'invoke' + let l:command = join(l:words) + return bash#complete(l:command) +endfunction + function! s:Call_and_log(cmd) echom a:cmd let r = system(a:cmd) diff --git a/vimfiles.stefan/vimrc b/vimfiles.stefan/vimrc index a563bda..4b772b8 100644 --- a/vimfiles.stefan/vimrc +++ b/vimfiles.stefan/vimrc @@ -51,6 +51,7 @@ packadd! tagbar packadd! tcomment packadd! termdebug packadd! vimagit +packadd! vim-bash-completion packadd! vim-clang-format packadd! vim-textidote packadd! VisIncr