Skip to content

Commit 23c06ee

Browse files
committed
show proper build option only in menu (if db not found)
1 parent ed26a57 commit 23c06ee

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

autoload/codequery.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ let g:c_family_filetype_list =
66
\ ['c', 'h', 'cpp', 'cxx', 'cc', 'hpp', 'hxx', 'hh']
77

88

9-
let s:supported_filetypes = g:c_family_filetype_list +
9+
let g:codequery_supported_filetype_list = g:c_family_filetype_list +
1010
\ ['python', 'javascript', 'go', 'ruby', 'java', 'c', 'cpp']
1111

1212

1313
let s:menu_subcommands = [ 'Unite' ]
1414

1515

1616
function! s:check_filetype(filetype) abort
17-
if index(s:supported_filetypes, a:filetype) == -1
17+
if index(g:codequery_supported_filetype_list, a:filetype) == -1
1818
return 0
1919
endif
2020
return 1

autoload/codequery/menu.vim

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,24 @@ function! codequery#menu#use_unite_menu(magic) abort
4040
let menu_goto_magic = [['▷ Open Magic Menu ▸', 'CodeQueryMenu Unite Magic']]
4141
let menu_goto_full = [['▷ Open Full Menu ▸', 'CodeQueryMenu Unite Full']]
4242

43+
" DB not found => remove unnecessary items from menu
44+
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 . '")']]
49+
let menu_function_cmds = []
50+
let menu_class_cmds = []
51+
let menu_other_cmds = []
52+
let menu_delimiter = []
53+
let menu_db_cmds = []
54+
let menu_goto_magic = []
55+
let menu_goto_full = []
56+
if index(g:codequery_supported_filetype_list, &filetype) == -1
57+
let menu_show_qf += [['# Not Supported Filetype: [' . &filetype . ']', '']]
58+
endif
59+
endif
60+
4361
if a:magic
4462
if &filetype ==# 'qf'
4563
call codequery#menu#patch_unite_magic_menu_from_qf(menu_frequent_cmds,

0 commit comments

Comments
 (0)