Skip to content

Commit 10a5f63

Browse files
authored
Merge pull request #9 from devjoe/build-db-async-in-vim8
Build db async in vim8
2 parents 23d8c24 + 0c1f8da commit 10a5f63

3 files changed

Lines changed: 26 additions & 15 deletions

File tree

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ This Vim plugin is built on top of the great tool [CodeQuery](https://github.com
6262
> * Use Vim8's new features to enhance usability.
6363
> * ~~Do lazy-loading.~~
6464
> * Test it.
65+
> * Doc it.
6566
>
6667
> Completeness: 92%
6768
> Current Version: v0.8
@@ -100,17 +101,15 @@ echo mkdir mv cut find awk stat git(optional)
100101
* Use your favorite plugins manager: [pathogen](https://github.com/tpope/vim-pathogen), [Vundle](https://github.com/VundleVim/Vundle.vim), [Plug](https://github.com/junegunn/vim-plug), [NeoBundle](https://github.com/Shougo/neobundle.vim), [Dein](https://github.com/Shougo/dein.vim), ...
101102
* Take Plug as an example:
102103
```vim
103-
" Recommemded => it helps vim-codequery to build DB asynchrously without blocking Vim
104-
Plug 'tpope/vim-dispatch'
105-
106-
" Recommemded => if you don't have an :Ack (or :Ag) liked command => install it !
107-
Plug 'mileszs/ack.vim'
108-
109-
" Highly Recommemded => if you want to use my custom Unite menu
110-
Plug 'Shougo/unite.vim'
111-
112-
" The Must Have One
104+
" Required
105+
Plug 'Shougo/unite.vim'
113106
Plug 'devjoe/vim-codequery'
107+
108+
" Optional (if your vim version < 8.0)
109+
Plug 'tpope/vim-dispatch'
110+
111+
" Optional (if you don't have an :Ack (or :Ag) liked command)
112+
Plug 'mileszs/ack.vim'
114113
```
115114

116115
<br>

autoload/codequery.vim

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,24 @@ function! codequery#make_codequery_db(args) abort
130130
continue
131131
endif
132132

133-
" TODO: Rewrite it when Vim8 is coming
134-
" ----------------------------------------------------------------
135-
if exists(':Start')
133+
if v:version >= 800
134+
echom 'Making ...'
135+
let mydict = {'db_path': db_path,
136+
\'callback': function("codequery#db#make_db_callback")}
137+
let options = {'out_io': 'null',
138+
\'exit_cb': mydict.callback}
139+
let s:build_job = job_start(['/bin/sh', '-c', shell_cmd], options)
140+
let timer = timer_start(500,
141+
\{-> execute("call job_status(s:build_job)","")},
142+
\{'repeat': 60})
143+
elseif exists(':Start')
136144
silent execute 'Start! -title=Make_CodeQuery_DB -wait=error ' . shell_cmd
137145
redraw!
138-
echom 'Making ' . db_path ' => Run :CodeQueryViewDB to Check Status'
146+
echom 'Making ... ' . db_path ' => Run :CodeQueryViewDB to Check Status'
139147
else
140148
silent execute '!' . shell_cmd
141149
redraw!
142150
endif
143-
" ----------------------------------------------------------------
144151
endfor
145152
call s:restore_cwd()
146153
endfunction

autoload/codequery/db.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ function! codequery#db#find_db_path(filetype) abort
3636
endfunction
3737

3838

39+
function! codequery#db#make_db_callback(job, status) dict
40+
echom 'Done! (' . self.db_path . ')'
41+
endfunction
42+
43+
3944
function! codequery#db#construct_python_db_build_cmd(db_path) abort
4045
let find_cmd = 'find . -iname "*.py" > python_cscope.files'
4146
let pycscope_cmd = 'pycscope -f "python_cscope.out" -i python_cscope.files'

0 commit comments

Comments
 (0)