/
1KoT1
/
cpp_tools
Обзор
Документация
Войти
/
1KoT1
/
cpp_tools
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
plugin/cpp_tools.vim
110 строк
4 KB
Vasilii Pochkaenko
feat(create_class): implement adding a created class to cmake file
23 июн 2026, 00:28
23 июн 2026, 00:28
8527b34
Код
Авторство
О чём код?
if exists('g:loaded_cpp_tools') finish endif let g:loaded_cpp_tools = 1 " g:cpp_tools_project_root {{{1 " Type: |Funcref| or |String| " Default: 'getcwd' " Callable that returns the project root directory. " }}} if !exists('g:cpp_tools_project_root') let g:cpp_tools_project_root = 'getcwd' endif " g:cpp_tools_create_class_header_path {{{1 " Type: |Funcref| or |String| " Default: 'cpp_tools#HeaderPath' " Callable that returns the header (.h) path. Called with " [root, namespaces, class_name]. " See |cpp_tools#HeaderPath| (the default) for a reference implementation. " }}} if !exists('g:cpp_tools_create_class_header_path') let g:cpp_tools_create_class_header_path = 'cpp_tools#HeaderPath' endif " g:cpp_tools_create_class_source_path {{{1 " Type: |Funcref| or |String| " Default: 'cpp_tools#SourcePath' " Callable that returns the source (.cpp) path. Called with " [root, namespaces, class_name]. " See |cpp_tools#SourcePath| (the default) for a reference implementation. " }}} if !exists('g:cpp_tools_create_class_source_path') let g:cpp_tools_create_class_source_path = 'cpp_tools#SourcePath' endif " g:cpp_tools_create_class_fill_source {{{1 " Type: |Funcref| or |String| " Default: 'cpp_tools#FillSource' " Callable that writes the initial .cpp file. Called with " [path, namespaces, class_name]. " See |cpp_tools#FillSource| (the default) for a reference implementation. " }}} if !exists('g:cpp_tools_create_class_fill_source') let g:cpp_tools_create_class_fill_source = 'cpp_tools#FillSource' endif " g:cpp_tools_create_class_fill_header {{{1 " Type: |Funcref| or |String| " Default: 'cpp_tools#FillHeader' " Callable that writes the initial .h file. Called with " [path, namespaces, class_name]. " See |cpp_tools#FillHeader| (the default) for a reference implementation. " }}} if !exists('g:cpp_tools_create_class_fill_header') let g:cpp_tools_create_class_fill_header = 'cpp_tools#FillHeader' endif " g:cpp_tools_create_class_update_cmake {{{1 " Type: |Number| " Default: 1 " When non-zero, add the created .cpp file to a cmake target after " both .h and .cpp files are created. " }}} if !exists('g:cpp_tools_create_class_update_cmake') let g:cpp_tools_create_class_update_cmake = 1 endif " g:cpp_tools_cmake_build_dir {{{1 " Type: |Funcref| or |String| " Default: 'cpp_tools#cmake#BuildDir' " Callable that returns the cmake build directory. Called with " [{root}]. Result is cached per project root for the session. " See |cpp_tools#cmake#BuildDir()| (the default) for a reference " implementation. " }}} if !exists('g:cpp_tools_cmake_build_dir') let g:cpp_tools_cmake_build_dir = 'cpp_tools#cmake#BuildDir' endif " :CppToolsCreateClass {{{1 " :CppToolsCreateClass " " Create header and source files for a C++ class. " Calls |cpp_tools#CreateClass|. " " Input parameters: " The cursor must be on a line of the form: " > " create class [Namespaces] ClassName " < " create class Literal prefix (required). " Namespaces Nested C++ namespaces as ns1::ns2::... (optional; " any depth). Omit when the class is not in a namespace. " ClassName Class name (required; one identifier). " " Examples: " create class Widget " create class foo::bar Widget " " On success the line is removed from the buffer (saved when the buffer " has a file name and is |modifiable|). " " Behavior is configurable via these settings (each may be a |Funcref| " or an autoload function name): " |g:cpp_tools_create_class_header_path| — a name of a function which build a path to .h file " |g:cpp_tools_create_class_source_path| — a name of a function which build a path to .cpp file " |g:cpp_tools_create_class_fill_header| — a name of a function which initial a .h file content " |g:cpp_tools_create_class_fill_source| — a name of a function which initial a .cpp file content " |g:cpp_tools_project_root| — a name of a function which return a project root directory " |g:cpp_tools_create_class_update_cmake| — when non-zero, add .cpp to a cmake target " |g:cpp_tools_cmake_build_dir| — a name of a function which return cmake build directory " Aborts with an error if either target file already exists. " " }}} command! CppToolsCreateClass call cpp_tools#CreateClass()