diff --git a/README.md b/README.md
index e40091a..f87826e 100644
--- a/README.md
+++ b/README.md
@@ -5,10 +5,7 @@
> Choose what you want to know! 😼
```vim
-" Open menu
-:CodeQueryMenu Unite Full
-
-" Or query directly
+" query directly
:CodeQuery Definition get_user_id
```
@@ -203,7 +200,6 @@ Plug 'mileszs/ack.vim'
| M | `:CodeQueryAgain Member` | |
| P | `:CodeQueryAgain Parent` | |
| D | `:CodeQueryAgain Child` | |
-| m | `:CodeQueryMenu Unite Magic` | |
| q | `:cclose` | |
| \ | `:CodeQueryFilter` | |
| p | `p` | Preview |
@@ -220,46 +216,9 @@ Plug 'mileszs/ack.vim'
" This command can also be used to **patch** standard Quickfix.
```
-
-#### 4. Open Menu
-
-Currently, vim-codequery only provides [Unite](https://github.com/Shougo/unite.vim) menu because I love it ⭐. There are two types of menu:
-
-* **Full Unite menu**
-
-```vim
-:CodeQueryMenu Unite Full
-
-" The string between :: and :: is the word under cursor
-" [F] means this action is for 'function variable only'
-" [C] is for 'class variable only'
-```
-
-
-* **Magic Unite menu**
-
-```vim
-:CodeQueryMenu Unite Magic
-
-" This menu changes dynamically:
-" 1. If the word under your cursor begins with a capital letter (possible be class): show [C] actions
-" 2. vice versa (possible be function): show [F] actions
-" 3. Show reasonable actions within Quickfix
-```
-
-
## Tips
-#### Open Menu
-```vim
-nnoremap c :CodeQueryMenu Unite Full
-nnoremap ; :CodeQueryMenu Unite Magic
-
-" Or enable typing (to search menu items) by default
-nnoremap \ :CodeQueryMenu Unite MagicA
-```
-
#### Query
```vim
nnoremap :CodeQuery Symbol
@@ -322,8 +281,7 @@ let g:codequery_build_go_db_cmd = '...'
let g:codequery_build_java_db_cmd = '...'
let g:codequery_build_c_db_cmd = '...'
```
-
-
+
#### Others
```vim
" You can disable key binding within quickfix
@@ -384,7 +342,6 @@ Thank all for working on these great projects!
* [CodeQuery](https://github.com/ruben2020/codequery)
* [Starscope](https://github.com/eapache/starscope)
* [PyCscope](https://github.com/portante/pycscope)
-* [Unite.vim](https://github.com/Shougo/unite.vim)
* [dispatch.vim](https://github.com/tpope/vim-dispatch)
* [ack.vim](https://github.com/mileszs/ack.vim)
* [vim-addon-qf-layout](https://github.com/MarcWeber/vim-addon-qf-layout)
diff --git a/autoload/codequery.vim b/autoload/codequery.vim
index 973c6ff..661ea02 100644
--- a/autoload/codequery.vim
+++ b/autoload/codequery.vim
@@ -7,10 +7,7 @@ let g:c_family_filetype_list =
let g:codequery_supported_filetype_list = g:c_family_filetype_list +
- \ ['python', 'javascript', 'go', 'ruby', 'java', 'c', 'cpp']
-
-
-let s:menu_subcommands = [ 'Unite' ]
+ \ ['python', 'javascript', 'go', 'ruby', 'java', 'c', 'cpp', 'erlang']
function! s:check_filetype(filetype) abort
@@ -38,17 +35,11 @@ function! s:save_cwd() abort
endfunction
-function! s:restore_cwd()
- execute 'lcd ' . g:codequery_cwd
- let g:codequery_cwd = ''
-endfunction
-
" =============================================================================
" Entries
-
function! codequery#run_codequery(args) abort
call s:save_cwd()
if !s:check_filetype(&filetype)
@@ -66,7 +57,6 @@ function! codequery#run_codequery(args) abort
let g:codequery_querytype = 1
let g:codequery_db_path = ''
if !s:set_db()
- call s:restore_cwd()
if g:codequery_trigger_build_db_when_db_not_found
execute 'CodeQueryMakeDB ' . &filetype
endif
@@ -86,7 +76,6 @@ function! codequery#run_codequery(args) abort
let word = codequery#query#get_final_query_word(iword, cword)
if empty(word)
echom 'Invalid Args: ' . a:args
- call s:restore_cwd()
return
endif
@@ -94,10 +83,8 @@ function! codequery#run_codequery(args) abort
else
echom 'Wrong Subcommand !'
endif
- call s:restore_cwd()
endfunction
-
function! codequery#make_codequery_db(args) abort
call s:save_cwd()
let args = split(a:args, ' ')
@@ -130,6 +117,8 @@ function! codequery#make_codequery_db(args) abort
let shell_cmd = codequery#db#construct_go_db_build_cmd(db_path)
elseif ft ==? 'java'
let shell_cmd = codequery#db#construct_java_db_build_cmd(db_path)
+ elseif ft ==? 'erlang'
+ let shell_cmd = codequery#db#construct_erlang_db_build_cmd(db_path)
elseif index(g:c_family_filetype_list, ft) != -1
let shell_cmd = codequery#db#construct_c_db_build_cmd(db_path)
else
@@ -137,7 +126,13 @@ function! codequery#make_codequery_db(args) abort
continue
endif
- if v:version >= 800
+ if has('nvim')
+ echom 'Making DB ...'
+ let mydict = {'db_path': db_path,
+ \'callback': function("codequery#db#make_db_callback")}
+ let callbacks = {'on_exit': mydict.callback}
+ let s:build_job = jobstart(['/bin/sh', '-c', shell_cmd], callbacks)
+ elseif v:version >= 800
echom 'Making DB ...'
let mydict = {'db_path': db_path,
\'callback': function("codequery#db#make_db_callback")}
@@ -156,7 +151,6 @@ function! codequery#make_codequery_db(args) abort
redraw!
endif
endfor
- call s:restore_cwd()
endfunction
@@ -185,7 +179,6 @@ function! codequery#view_codequery_db(args) abort
execute '!echo "\n(' . db_path . ') is update at: " && stat -f "\%Sm" ' . db_path
endfor
- call s:restore_cwd()
endfunction
@@ -214,30 +207,8 @@ function! codequery#move_codequery_db_to_git_hidden_dir(args) abort
echom 'Git Dir Not Found or (' . db_name . ') Not Found'
endif
endfor
- call s:restore_cwd()
endfunction
-
-function! codequery#show_menu(args) abort
- let args = split(a:args, ' ')
- let args_num = len(args)
-
- if args_num > 0 && index(s:menu_subcommands, args[0]) != -1
- if args[0] ==# 'Unite'
- if args_num > 1 && args[1] ==# 'Magic'
- let magic_menu = 1
- else
- let magic_menu = 0
- endif
- call codequery#menu#use_unite_menu(magic_menu)
- return
- endif
- endif
-
- echom 'Wrong Subcommands! Try: ' . join(s:menu_subcommands, ', ')
-endfunction
-
-
function! codequery#run_codequery_again_with_different_subcmd(args) abort
let args = split(a:args, ' ')
let args_num = len(args)
@@ -251,7 +222,6 @@ function! codequery#run_codequery_again_with_different_subcmd(args) abort
endif
endfunction
-
" modify from someone's .vimrc
function! codequery#filter_qf_results(args) abort
let args = split(a:args, ' ')
diff --git a/autoload/codequery/db.vim b/autoload/codequery/db.vim
index 3801e69..64a1fdf 100644
--- a/autoload/codequery/db.vim
+++ b/autoload/codequery/db.vim
@@ -2,7 +2,6 @@
" Entries
-" `lcd` brings side effect !!
function! codequery#db#find_db_path(filetype) abort
if index(g:c_family_filetype_list, a:filetype) != -1
let db_name = 'c_family.db'
@@ -10,25 +9,21 @@ function! codequery#db#find_db_path(filetype) abort
let db_name = a:filetype . '.db'
endif
- let lookup_path = findfile(expand('%:p:h') . '/' . db_name, '.')
+ let lookup_path = findfile(getcwd() .'/'. db_name, '.')
if !empty(lookup_path)
- lcd %:p:h
return lookup_path
endif
- lcd %:p:h
let git_root_dir = systemlist('git rev-parse --show-toplevel')[0]
if !v:shell_error
let lookup_path = findfile(git_root_dir . '/' . db_name, '.')
if !empty(lookup_path)
- execute 'lcd ' . git_root_dir
return lookup_path
else
let lookup_path = findfile(git_root_dir . '/.git/codequery/' .
\ db_name, '.')
if !empty(lookup_path)
- execute 'lcd ' . git_root_dir
return lookup_path
endif
endif
@@ -36,8 +31,8 @@ function! codequery#db#find_db_path(filetype) abort
endfunction
-function! codequery#db#make_db_callback(job, status) dict
- echom 'Done! (' . self.db_path . ')'
+function! codequery#db#make_db_callback(job, data, status) dict
+ echom 'Build codequery db Done!'
endfunction
@@ -77,7 +72,6 @@ function! codequery#db#construct_javascript_db_build_cmd(db_path) abort
return exists('g:codequery_build_javascript_db_cmd') ? g:codequery_build_javascript_db_cmd : shell_cmd
endfunction
-
function! codequery#db#construct_ruby_db_build_cmd(db_path) abort
let starscope_cmd = 'starscope --force-update -e ctags -e cscope **/*.rb'
let rename_cmd = 'mv tags ruby_tags && mv cscope.out ruby_cscope.out'
@@ -142,7 +136,7 @@ function! codequery#db#construct_c_db_build_cmd(db_path) abort
\ 'find . -iname "*.hxx" >> c_cscope.files && ' .
\ 'find . -iname "*.hh" >> c_cscope.files'
let cscope_cmd = 'cscope -cbk -i c_cscope.files -f c_cscope.out'
- let ctags_cmd = 'ctags --fields=+i -n -R -f "c_tags" -L c_cscope.files'
+ let ctags_cmd = 'ctags --fields=+afmikKlnsStz -N -R --languages=+c++,c -f "c_tags" -L c_cscope.files'
let cqmakedb_cmd = 'cqmakedb -s "' . a:db_path . '" -c c_cscope.out' .
\ ' -t c_tags -p'
let shell_cmd = find_cmd . ' && ' .
diff --git a/autoload/codequery/menu.vim b/autoload/codequery/menu.vim
deleted file mode 100644
index edfc1bc..0000000
--- a/autoload/codequery/menu.vim
+++ /dev/null
@@ -1,118 +0,0 @@
-" =============================================================================
-" Entries
-
-
-scriptencoding utf-8
-
-
-function! codequery#menu#patch_unite_magic_menu_from_qf(fre_cmds, fun_cmds, cla_cmds) abort
- call map(a:fre_cmds, '[substitute(v:val[0], "Find", "Switch To", "g"), v:val[1]]')
- call map(a:fun_cmds, '[substitute(v:val[0], "Find", "Switch To", "g"), v:val[1]]')
- call map(a:cla_cmds, '[substitute(v:val[0], "Find", "Switch To", "g"), v:val[1]]')
- call map(a:fre_cmds, '[v:val[0], substitute(v:val[1], "CodeQuery", "CodeQueryAgain", "")]')
- call map(a:fun_cmds, '[v:val[0], substitute(v:val[1], "CodeQuery", "CodeQueryAgain", "")]')
- call map(a:cla_cmds, '[v:val[0], substitute(v:val[1], "CodeQuery", "CodeQueryAgain", "")]')
- call insert(a:fre_cmds, ['▷ Filter', 'call feedkeys(":CodeQueryFilter ")'], 0)
-endfunction
-
-
-
-function! codequery#menu#use_unite_menu(magic) abort
- let cword = codequery#query#get_valid_cursor_word()
- let menu_frequent_cmds = [['▷ Find Symbol', 'CodeQuery Symbol'],
- \['▷ Find Text', 'CodeQuery Text']]
- let menu_function_cmds = [['▷ Find Function Def. [F]', 'CodeQuery Definition'],
- \['▷ Find Call [F]', 'CodeQuery Call'],
- \['▷ Find Caller [F]', 'CodeQuery Caller'],
- \['▷ Find Callee [F]', 'CodeQuery Callee']]
- let menu_class_cmds = [['▷ Find Class Def. [C]', 'CodeQuery Class'],
- \['▷ Find Class Member [C]', 'CodeQuery Member'],
- \['▷ Find Parent [C]', 'CodeQuery Parent'],
- \['▷ Find Child [C]', 'CodeQuery Child']]
- let menu_other_cmds = [['▷ List Function', 'CodeQuery FunctionList'],
- \['▷ List Imports', 'CodeQuery FileImporter']]
- let menu_delimiter = [['* ------------------------- *', '']]
- let menu_db_cmds = [['▷ Make DB', 'call feedkeys(":CodeQueryMakeDB ")'],
- \['▷ View DB', 'call feedkeys(":CodeQueryViewDB ")'],
- \['▷ Move DB', 'call feedkeys(":CodeQueryMoveDBToGitDir ")']]
- let menu_show_qf = [['▷ Show QF ▲', 'CodeQueryShowQF'],
- \['▷ Hide QF ▼', 'cclose']]
- let menu_goto_magic = [['▷ Open Magic Menu ▸', 'CodeQueryMenu Unite Magic']]
- let menu_goto_full = [['▷ Open Full Menu ▸', 'CodeQueryMenu Unite Full']]
-
- " DB not found => remove unnecessary items from menu
- let db_path = codequery#db#find_db_path(&filetype)
- if empty(db_path) && &filetype !=# 'qf'
- let menu_frequent_cmds = [['▷ Find Text', g:codequery_find_text_cmd]]
- let menu_function_cmds = []
- let menu_class_cmds = []
- let menu_other_cmds = []
- let menu_delimiter = []
- let menu_db_cmds = [['▷ Make DB', 'call feedkeys(":CodeQueryMakeDB ' . &filetype . '")']]
- let menu_goto_magic = []
- let menu_goto_full = []
- if index(g:codequery_supported_filetype_list, &filetype) == -1
- let menu_show_qf += [['# Not Supported Filetype: [' . &filetype . ']', '']]
- endif
- endif
-
- if a:magic
- if &filetype ==# 'qf'
- call codequery#menu#patch_unite_magic_menu_from_qf(menu_frequent_cmds,
- \ menu_function_cmds,
- \ menu_class_cmds)
- let menu_other_cmds = []
- let menu_goto_full = []
- if exists('g:codequery_last_query_word')
- let cword = g:codequery_last_query_word
- endif
- endif
-
- let menu_description = 'CodeQuery Magic Menu'
- if g:codequery_enable_not_so_magic_menu
- let cmd_candidates = menu_frequent_cmds
- \ + menu_function_cmds
- \ + menu_class_cmds
- \ + menu_other_cmds
- \ + menu_show_qf
- \ + menu_goto_full
- elseif cword =~# '\C^[A-Z].*'
- let cmd_candidates = menu_frequent_cmds
- \ + menu_class_cmds
- \ + menu_other_cmds
- \ + menu_show_qf
- \ + menu_goto_full
- else
- let cmd_candidates = menu_frequent_cmds
- \ + menu_function_cmds
- \ + menu_other_cmds
- \ + menu_show_qf
- \ + menu_goto_full
- endif
- else
- if &filetype ==# 'qf'
- echom 'Can Not Open Full Menu In QF (Use Magic Menu)'
- return
- endif
- let menu_description = 'CodeQuery Full Menu'
- let cmd_candidates = menu_frequent_cmds
- \ + menu_function_cmds
- \ + menu_class_cmds
- \ + menu_other_cmds
- \ + menu_delimiter
- \ + menu_db_cmds
- \ + menu_delimiter
- \ + menu_show_qf
- \ + menu_goto_magic
- endif
-
- if !exists('g:unite_source_menu_menus')
- let g:unite_source_menu_menus = {}
- endif
- let g:unite_source_menu_menus.codequery = {
- \ 'description' : menu_description,
- \}
- let g:unite_source_menu_menus.codequery.command_candidates = cmd_candidates
- execute 'Unite -silent -prompt-visible -prompt=::' . cword
- \ . ':: menu:codequery'
-endfunction
diff --git a/autoload/codequery/query.vim b/autoload/codequery/query.vim
index 7c8cf24..bc8d8d5 100644
--- a/autoload/codequery/query.vim
+++ b/autoload/codequery/query.vim
@@ -112,11 +112,7 @@ endfunction
" Ref: MarcWeber's vim-addon-qf-layout
function! codequery#query#prettify_qf_layout_and_map_keys(results) abort
if &filetype !=# 'qf'
- if !empty(g:codequery_cwd)
- execute 'lcd ' . g:codequery_cwd
- endif
copen
- execute 'lcd ' . g:codequery_cwd
endif
" unlock qf to make changes
@@ -161,7 +157,6 @@ function! codequery#query#prettify_qf_layout_and_map_keys(results) abort
nnoremap P :CodeQueryAgain Parent
nnoremap D :CodeQueryAgain Child
- nnoremap m :CodeQueryMenu Unite Magic
nnoremap q :cclose
nnoremap \ :CodeQueryFilter
@@ -175,7 +170,6 @@ function! codequery#query#prettify_qf_layout_and_map_keys(results) abort
setlocal nomodified
endfunction
-
function! codequery#query#do_query(word) abort
if empty(a:word)
echom 'Invalid Search Term: ' . a:word
@@ -187,9 +181,6 @@ function! codequery#query#do_query(word) abort
" Find Text
if empty(grepformat)
- if g:codequery_find_text_from_current_file_dir == 1
- lcd %:p:h
- endif
silent execute grepprg
call codequery#query#prettify_qf_layout_and_map_keys(getqflist())
let g:codequery_last_query_word = a:word
@@ -197,7 +188,7 @@ function! codequery#query#do_query(word) abort
return
endif
- if v:version >= 800
+ if v:version >= 800 && !has('nvim')
echom 'Searching ... [' . a:word . ']'
let job_dict = {'is_append': g:codequery_append_to_qf ? 1 : 0,
diff --git a/plugin/codequery.vim b/plugin/codequery.vim
index adfb665..ebfe4d3 100644
--- a/plugin/codequery.vim
+++ b/plugin/codequery.vim
@@ -31,8 +31,6 @@ if !exists('g:codequery_enable_not_so_magic_menu')
let g:codequery_enable_not_so_magic_menu = 0
endif
-
-
" No need to init
"let g:codequery_build_python_db_cmd = ''
"let g:codequery_build_javascript_db_cmd = ''
@@ -56,7 +54,6 @@ command! -nargs=* CodeQueryMakeDB call codequery#make_codequery_db()
command! -nargs=* CodeQueryViewDB call codequery#view_codequery_db()
command! -nargs=* CodeQueryMoveDBToGitDir
\ call codequery#move_codequery_db_to_git_hidden_dir()
-command! -nargs=* CodeQueryMenu call codequery#show_menu()
command! -nargs=0 CodeQueryShowQF call
\ codequery#query#prettify_qf_layout_and_map_keys(getqflist())