summaryrefslogtreecommitdiff
path: root/.vim/cscope.vim
blob: 53e4dd91c3df97913c8ce63f715e4d6021055b9b (plain)
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
if has("cscope")
        set cscopetag
        set csto=0
        if $CSCOPE_DB != ""
                cs add $CSCOPE_DB
        else
                let dirs = split($PWD, '/')
                let paths = ['/']
                for d in dirs
                        let paths = add(paths, paths[len(paths) - 1] . d . '/')
                endfor

                for d in reverse(paths)
                        let cscope_file = d . "/cscope.out"
                        if filereadable(cscope_file)
                                execute('cs add ' . cscope_file)
                                break
                        endif
                endfor
        endif

        set cscopeverbose

        nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>e :cs find e <C-R>=expand("<cfile>")<CR><CR>
        nmap <C-\>f :cs find f <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
        nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
        nmap <C-\>S :cs find t struct <C-R>=expand("<cword>")<CR> {<CR>

        nmap <C-@>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
        nmap <C-@>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
        nmap <C-@>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@>S :vert scs find t struct <C-R>=expand("<cword>")<CR> {<CR>

        nmap <C-@><C-@>s :scs find s <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>g :scs find g <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>c :scs find c <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>t :scs find t <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>e :scs find e <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
        nmap <C-@><C-@>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
        nmap <C-@><C-@>d :scs find d <C-R>=expand("<cword>")<CR><CR>
        nmap <C-@><C-@>S :scs find t struct <C-R>=expand("<cword>")<CR> {<CR>
endif