" Scanning included files when ^n is troublesome
setlocal complete-=i
setlocal path+=/usr/include/**
setlocal makeprg=ninja\ -C\ build

nnoremap <buffer> <LocalLeader>ct :AsyncDo ctags -R --fields=+nS --excmd=number .<CR>
nnoremap <buffer> <LocalLeader>cu :AsyncDo cscope -bqR<CR>
nnoremap <buffer> <LocalLeader>cr :cs reset<CR>

nmap <buffer> <silent> <LocalLeader>s  <Plug>(quickr_cscope_symbols)
nmap <buffer> <silent> <LocalLeader>g  <Plug>(quickr_cscope_global)
nmap <buffer> <silent> <LocalLeader>h  <Plug>(quickr_cscope_global_split)
nmap <buffer> <silent> <LocalLeader>v  <Plug>(quickr_cscope_global_vert_split)
nmap <buffer> <silent> <LocalLeader>d  <Plug>(quickr_cscope_functions)
nmap <buffer> <silent> <LocalLeader>c  <Plug>(quickr_cscope_callers)
nmap <buffer> <silent> <LocalLeader>t  <Plug>(quickr_cscope_text)
nmap <buffer> <silent> <LocalLeader>e  <Plug>(quickr_cscope_egrep)
nmap <buffer> <silent> <LocalLeader>f  <Plug>(quickr_cscope_files)
nmap <buffer> <silent> <LocalLeader>i  <Plug>(quickr_cscope_includes)
nmap <buffer> <silent> <LocalLeader>a  <Plug>(quickr_cscope_assignments)

" If we are working with any of the gstreamer projects in C, run gst-ident
" before saving. Assume gst-ident from gstreamer/tools/gst-indent has been
" made available in path.
"
" The '!' after autocmd is required without which, the command gets triggered
" multiple times. Basically, we clear the autocmd.
autocmd! BufWritePost */gst-*/*.c call c#format_with_gst_indent()
autocmd! BufWritePost */gstreamer-*/*.c call c#format_with_gst_indent()
