mirror of
1
0
Fork 0
This commit is contained in:
Luc Ma 2022-12-03 11:26:11 +01:00 committed by GitHub
commit 4bc5e7deb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 96 additions and 0 deletions

View File

@ -146,6 +146,102 @@ map <leader>p :cp<cr>
autocmd BufReadPost quickfix nnoremap <buffer> <CR> <CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Cscope/Vim key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if has("cscope")
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" check cscope for definition of a symbol before checking ctags
" set to 1 if you want the reverse check order.
set csto=0
" add any cscope database in current directory
if filereadable("cscope.out")
cs add cscope.out
" else add the database pointed to by environment variable
elseif $CSCOPE_DB != ""
cs add $CSCOPE_DB
endif
" show msg when any other cscope db added
set cscopeverbose
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" The following maps all invoke one of the following cscope search types:
"
" 's' symbol: find all references to the token under cursor
" 'g' global: find global definition(s) of the token under cursor
" 'c' calls: find all calls to the function name under cursor
" 't' text: find all instances of the text under cursor
" 'e' egrep: egrep search for the word under cursor
" 'f' file: open the filename under cursor
" 'i' includes: find files that include the filename under cursor
" 'd' called: find functions that function under cursor calls
"
" Using CTRL-\ as the starting keys for these maps, as it's unlikely
" that you need its default mapping (CTRL-\'s default use is as part
" of CTRL-\ CTRL-N typemap, which basically just does the same thing
" as hitting 'escape').
"
" If you don't like using CTRL-\, you can change some or all of these
" maps to use other keys. One likely candidate is 'CTRL-_' (which also
" maps to CTRL-/, which is easier to type). By default it is used to
" switch between Hebrew and English keyboard mode.
"
" To do the navigation, hit 'CTRL-\', followed by one of the cscope
" search types above (s,g,c,t,e,f,i,d). The result of your cscope
" search will be displayed in the current window. You can use CTRL-T
" to go back to where you were before the search.
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let b:cscope_mapping_start_key = '<C-_>'
exe 'nmap '.b:cscope_mapping_start_key.'s :cs find s <C-R>=expand("<cword>")<CR><CR>'
exe 'nmap '.b:cscope_mapping_start_key.'g :cs find g <C-R>=expand("<cword>")<CR><CR>'
exe 'nmap '.b:cscope_mapping_start_key.'c :cs find c <C-R>=expand("<cword>")<CR><CR>'
exe 'nmap '.b:cscope_mapping_start_key.'t :cs find t <C-R>=expand("<cword>")<CR><CR>'
exe 'nmap '.b:cscope_mapping_start_key.'e :cs find e <C-R>=expand("<cword>")<CR><CR>'
exe 'nmap '.b:cscope_mapping_start_key.'f :cs find f <C-R>=expand("<cfile>")<CR><CR>'
exe 'nmap '.b:cscope_mapping_start_key.'i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>'
exe 'nmap '.b:cscope_mapping_start_key.'d :cs find d <C-R>=expand("<cword>")<CR><CR>'
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"
" These key maps use multiple keystrokes (2 or 3 keys). If you find that
" vim keeps timing you out before you can complete them, try changing
" your timeout settings as explained below.
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" By default Vim will only wait 1 second for each keystroke in a mapping.
" You may find that too short with the above typemaps. If so, you should
" either turn off mapping timeouts via 'notimeout'.
"
"set notimeout
" Or, you can keep timeouts, by uncommenting the timeoutlen line below,
" with your own personal favorite value (in milliseconds):
set timeoutlen=4000
" Either way, since mapping timeout settings by default also set the
" timeouts for multicharacter 'keys codes' (like <F1>), you should also
" set ttimeout and ttimeoutlen: otherwise, you will experience strange
" delays as vim waits for a keystroke after you hit ESC (it will be
" waiting to see if the ESC is actually part of a key code like <F1>).
set ttimeout
" Personally a tenth of a second works well for key code timeouts. If you
" experience problems and have a slow terminal or network connection,
" set it higher. If you don't set ttimeoutlen, the value for timeoutlen
" (default: 1000 = 1 second, which is sluggish) is used.
set ttimeoutlen=100
endif
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""