Skip to content

Commit d2184b7

Browse files
committed
fix global variable scrope bug & add two options to enhance usability
1 parent 23c06ee commit d2184b7

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

autoload/codequery.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ function! codequery#run_codequery(args) abort
5353
call s:save_cwd()
5454
if !s:check_filetype(&filetype)
5555
echom 'Not Supported Filetype: ' . &filetype
56+
if g:codequery_auto_switch_to_find_text_for_wrong_filetype
57+
silent execute g:codequery_find_text_cmd
58+
call codequery#query#prettify_qf_layout_and_map_keys(getqflist())
59+
endif
5660
return
5761
endif
5862

@@ -63,6 +67,9 @@ function! codequery#run_codequery(args) abort
6367
let g:codequery_db_path = ''
6468
if !s:set_db()
6569
call s:restore_cwd()
70+
if g:codequery_trigger_build_db_when_db_not_found
71+
execute 'CodeQueryMakeDB ' . &filetype
72+
endif
6673
return
6774
endif
6875

@@ -131,7 +138,7 @@ function! codequery#make_codequery_db(args) abort
131138
endif
132139

133140
if v:version >= 800
134-
echom 'Making ...'
141+
echom 'Making DB ...'
135142
let mydict = {'db_path': db_path,
136143
\'callback': function("codequery#db#make_db_callback")}
137144
let options = {'out_io': 'null',

autoload/codequery/menu.vim

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,13 @@ function! codequery#menu#use_unite_menu(magic) abort
4242

4343
" DB not found => remove unnecessary items from menu
4444
let db_path = codequery#db#find_db_path(&filetype)
45-
if empty(db_path)
46-
let menu_frequent_cmds =
47-
\[['▷ Find Text', g:codequery_find_text_cmd],
48-
\ ['▷ Make DB', 'call feedkeys(":CodeQueryMakeDB ' . &filetype . '")']]
45+
if empty(db_path) && &filetype !=# 'qf'
46+
let menu_frequent_cmds = [['▷ Find Text', g:codequery_find_text_cmd]]
4947
let menu_function_cmds = []
5048
let menu_class_cmds = []
5149
let menu_other_cmds = []
5250
let menu_delimiter = []
53-
let menu_db_cmds = []
51+
let menu_db_cmds = [['▷ Make DB', 'call feedkeys(":CodeQueryMakeDB ' . &filetype . '")']]
5452
let menu_goto_magic = []
5553
let menu_goto_full = []
5654
if index(g:codequery_supported_filetype_list, &filetype) == -1

plugin/codequery.vim

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
" Copyright (c) 2016 excusemejoe
22
" MIT License
33

4+
5+
if exists('g:loaded_loaded_codequery')
6+
finish
7+
endif
8+
let g:loaded_codequery = 1
9+
10+
411
" =============================================================================
512
" Options
613

714
" Init with default value
8-
let g:codequery_find_text_cmd = 'Ack!'
9-
let g:codequery_find_text_from_current_file_dir = 0
15+
if !exists('g:codequery_find_text_cmd')
16+
let g:codequery_find_text_cmd = 'Ack!'
17+
endif
18+
if !exists('g:codequery_find_text_from_current_file_dir')
19+
let g:codequery_find_text_from_current_file_dir = 0
20+
endif
21+
if !exists('g:codequery_auto_switch_to_find_text_for_wrong_filetype')
22+
let g:codequery_auto_switch_to_find_text_for_wrong_filetype = 0
23+
endif
24+
if !exists('g:codequery_trigger_build_db_when_db_not_found')
25+
let g:codequery_trigger_build_db_when_db_not_found = 0
26+
endif
27+
1028

1129

1230
" No need to init

0 commit comments

Comments
 (0)