Note: I'm under the impression I've already given these information here or on SO... IOW, other answers and solutions may be available there.
I have the :GOTOIMPL
(and :MOVEIMPL
) commands in lh-cpp that generates empty function definitions from function declarations -- but one at the time.
The implementation in the main branch has several limitations (no support for templates, C array parameters (who use them anyway? ;), ...). This initial implementation is closely related to a 2 decades old tip in vim.wikia. It contains a lot of :substitute/regex
calls to handle comments, parameters, extract return types, function names, scopes (ns::ns::cls::cls
...), ignore some keywords (virtual
, override
, static
...) and so on. That's why I won't describe it here.
The improved version resides in a gotoimpl_with_libclang
branch, it depends on another plugin of mine (vim-clang; branch V2Upgrade), which in turn depends on the Python bindings of libclang. Most of the complex cases are now handled. I've haven't tried (yet) to support trailing return types though.
PS: At the moment, the v2 of MOVEIMPL
command has a few issues that I haven't taken the time to tackle. (I'd like to extract the formatting used in function declarations to reproduce it).