-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdxr-ctags.vim
82 lines (72 loc) · 3.1 KB
/
dxr-ctags.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
set tags=dxr-ctags,./dxr-ctags;
" Performs the query we want using dxr-ctags.py, which updates dxr-ctags with
" only the matches we're interested in. Once this is done, we turn it over to
" vim's ctags support.
function PerformQuery(query_type, token)
let args = '-q '.a:query_type.' -f '.expand('%').' -l '.line('.').' -t '.a:token
let command = 'dxr-ctags.py '.args
call system(command)
endfunction
function PerformQueryContextFree(query_type, token)
let args = '-q '.a:query_type.' -t '.a:token
let command = 'dxr-ctags.py '.args
call system(command)
endfunction
function Dxtjump(query_type, token)
call PerformQuery(a:query_type, a:token)
exe "tjump ".a:token
endfunction
function Dxtjump_cf(query_type, token)
call PerformQueryContextFree(a:query_type, a:token)
exe "tjump ".a:token
endfunction
function Dxstjump(query_type, token)
call PerformQuery(a:query_type, a:token)
exe "stjump ".a:token
endfunction
function Dxstjump_cf(query_type, token)
call PerformQueryContextFree(a:query_type, a:token)
exe "stjump ".a:token
endfunction
function Dxvtjump(query_type, token)
call PerformQuery(a:query_type, a:token)
exe "vert stjump ".a:token
endfunction
function Dxvtjump_cf(query_type, token)
call PerformQueryContextFree(a:query_type, a:token)
exe "vert stjump ".a:token
endfunction
"
" The following key mappings are derived from 'gtags-cscope.vim', which were
" in turn derived from 'cscope_maps.vim'.
"
" normal command
:nmap <C-\>s :call Dxtjump('refs', expand("<cword>"))<CR>
:nmap <C-\>g :call Dxtjump('defs', expand("<cword>"))<CR>
:nmap <C-\>d :call Dxtjump('decls',expand("<cword>"))<CR>
:nmap <C-\>f :call Dxtjump('files',expand("<cfile>"))<CR>
" try harder
:nmap <C-\>S :call Dxtjump_cf('refs', expand("<cword>"))<CR>
:nmap <C-\>G :call Dxtjump_cf('defs', expand("<cword>"))<CR>
:nmap <C-\>D :call Dxtjump_cf('decls',expand("<cword>"))<CR>
:nmap <C-\>F :call Dxtjump_cf('files',expand("<cfile>"))<CR>
"" Using 'CTRL-]', the result is displayed in new horizontal window.
:nmap <C-]>s :call Dxstjump('refs', expand("<cword>"))<CR>
:nmap <C-]>g :call Dxstjump('defs', expand("<cword>"))<CR>
:nmap <C-]>d :call Dxstjump('decls',expand("<cword>"))<CR>
:nmap <C-]>f :call Dxstjump('files',expand("<cfile>"))<CR>
" try harder
:nmap <C-]>S :call Dxstjump_cf('refs', expand("<cword>"))<CR>
:nmap <C-]>G :call Dxstjump_cf('defs', expand("<cword>"))<CR>
:nmap <C-]>D :call Dxstjump_cf('decls',expand("<cword>"))<CR>
:nmap <C-]>F :call Dxstjump_cf('files',expand("<cfile>"))<CR>
"" Hitting CTRL-] *twice*, the result is displayed in new vertical window.
:nmap <C-]><C-]>s :call Dxvtjump('refs', expand("<cword>"))<CR>
:nmap <C-]><C-]>g :call Dxvtjump('defs', expand("<cword>"))<CR>
:nmap <C-]><C-]>d :call Dxvtjump('decls',expand("<cword>"))<CR>
:nmap <C-]><C-]>f :call Dxvtjump('files',expand("<cfile>"))<CR>
" try harder
:nmap <C-]><C-]>S :call Dxvtjump_cf('refs', expand("<cword>"))<CR>
:nmap <C-]><C-]>G :call Dxvtjump_cf('defs', expand("<cword>"))<CR>
:nmap <C-]><C-]>D :call Dxvtjump_cf('decls',expand("<cword>"))<CR>
:nmap <C-]><C-]>F :call Dxvtjump_cf('files',expand("<cfile>"))<CR>