diff --git a/nvim/.config/nvim/after/ftplugin/c.vim b/nvim/.config/nvim/after/ftplugin/c.vim index 54fbeee..a1cf433 100644 --- a/nvim/.config/nvim/after/ftplugin/c.vim +++ b/nvim/.config/nvim/after/ftplugin/c.vim @@ -18,3 +18,12 @@ nmap e (quickr_cscope_egrep) nmap f (quickr_cscope_files) nmap i (quickr_cscope_includes) nmap a (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() diff --git a/nvim/.config/nvim/autoload/c.vim b/nvim/.config/nvim/autoload/c.vim new file mode 100644 index 0000000..389dbaf --- /dev/null +++ b/nvim/.config/nvim/autoload/c.vim @@ -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