nvim: ftplugin/autoload: C: Run gst-indent on save

This commit is contained in:
Sanchayan Maity 2021-05-02 19:08:41 +05:30
parent 893b06defb
commit d7c2ca6e43
2 changed files with 14 additions and 0 deletions

View file

@ -18,3 +18,12 @@ 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()

View file

@ -0,0 +1,5 @@
function! c#format_with_gst_indent() abort
let file = expand('%:p')
silent execute "!gst-indent " . file
silent execute "e" . file
endfunction