77
88command ! -nargs =* -complete =customlist ,s: complete_function CodeQuery
99 \ call s: run_codequery (<q-args> )
10+ command ! -nargs =* -complete =customlist ,s: complete_function CodeQueryAgain
11+ \ call s: run_codequery_again_with_different_subcmd (<q-args> )
1012command ! -nargs =0 CodeQueryMakeDB call s: make_codequery_db ()
1113command ! -nargs =0 CodeQueryViewDB call s: view_codequery_db ()
1214command ! -nargs =0 CodeQueryMoveDBToGitDir
@@ -180,6 +182,8 @@ function! s:do_grep(word)
180182 finally
181183 let &l: grepprg = l: grepprg_bak
182184 let &grepformat = l: grepformat_bak
185+ let s: last_query_word = a: word
186+ let s: last_query_fuzzy = s: fuzzy
183187 endtry
184188endfunction
185189
@@ -197,6 +201,16 @@ function! s:set_options(args)
197201endfunction
198202
199203
204+ function ! s: patch_unite_magic_menu_from_qf (fre_cmds, fun_cmds, cla_cmds)
205+ call map (a: fre_cmds , ' [substitute(v:val[0], "Find", "Switch To", "g"), v:val[1]]' )
206+ call map (a: fun_cmds , ' [substitute(v:val[0], "Find", "Switch To", "g"), v:val[1]]' )
207+ call map (a: cla_cmds , ' [substitute(v:val[0], "Find", "Switch To", "g"), v:val[1]]' )
208+ call map (a: fre_cmds , ' [v:val[0], substitute(v:val[1], "CodeQuery", "CodeQueryAgain", "")]' )
209+ call map (a: fun_cmds , ' [v:val[0], substitute(v:val[1], "CodeQuery", "CodeQueryAgain", "")]' )
210+ call map (a: cla_cmds , ' [v:val[0], substitute(v:val[1], "CodeQuery", "CodeQueryAgain", "")]' )
211+ endfunction
212+
213+
200214function ! s: use_unite_menu (magic )
201215 let cword = s: get_valid_cursor_word ()
202216 let menu_frequent_cmds = [[' ▷ Find Symbol' , ' CodeQuery' ]]
@@ -218,8 +232,17 @@ function! s:use_unite_menu(magic)
218232 let menu_goto_full = [[' ▷ <Open Full Menu>' , ' CodeQueryMenu Unite Full' ]]
219233
220234 if a: magic
235+ if &filetype == # ' qf'
236+ call s: patch_unite_magic_menu_from_qf (menu_frequent_cmds,
237+ \ menu_function_cmds,
238+ \ menu_class_cmds)
239+ let menu_other_cmds = []
240+ let menu_goto_full = []
241+ let cword = s: last_query_word
242+ endif
243+
221244 let menu_description = ' CodeQuery Smart Menu'
222- if cword = ~ ' \C^[A-Z].*'
245+ if cword = ~# ' \C^[A-Z].*'
223246 let cmd_candidates = menu_frequent_cmds
224247 \ + menu_class_cmds
225248 \ + menu_other_cmds
@@ -262,6 +285,7 @@ function! s:run_codequery(args)
262285 return
263286 endif
264287
288+ let s: last_query_word = ' '
265289 let s: fuzzy = 0
266290 let s: append_to_quickfix = 0
267291 let s: querytype = 1
@@ -390,6 +414,19 @@ function! s:show_menu(args)
390414endfunction
391415
392416
417+ function ! s: run_codequery_again_with_different_subcmd (args )
418+ let args = split (a: args , ' ' )
419+ let args_num = len (args )
420+ if ! empty (s: last_query_word ) && args_num > 0
421+ cclose
422+ let again_cmd = ' CodeQuery ' . args [0 ] . ' ' . s: last_query_word . ' '
423+ \ . (s: last_query_fuzzy ? ' -f' : ' ' )
424+ execute again_cmd
425+ else
426+ echom ' Wrong Subcommands!'
427+ endif
428+ endfunction
429+
393430
394431" =============================================================================
395432" Debugging
0 commit comments