martuscellifaria/ahoicpp.nvim

github github
project
stars 2
issues 0
subscribers 1
forks 0
CREATED

UPDATED


AhoiCpp

License: MIT Neovim

A.H.O.I. Labs (Alex's Heavily Opinionated Interfaces) presents you AhoiCpp.

AhoiCpp is an opinionated way to start cross platform C++ projects in Neovim. AhoiCpp lets you create classes, libraries and your own app entrypoint with the respective build process.

Dependencies

AhoiCpp assumes you have a C++ 23 capable compiler (I use g++ 14.3.0 on my development environment), cmake, git and python installed. If not, you should do it first. Of course you have to have Neovim as well, version 0.11 or higher is recommended, since some vim.api and vim.fn functions are new.

 

Installation

Using lazy.nvim

{
    'martuscellifaria/ahoicpp.nvim',
    config = function()
      require('ahoicpp').setup()
    end,
}

Manual Installation

Clone the repository and add it to your Neovim runtime path:

git clone https://github.com/martuscellifaria/ahoicpp.nvim ~/.config/nvim/pack/plugins/start/ahoicpp.nvim

 

Usage

Default Keymaps

Command Description
<leader>cph Opens the about/help menu from AhoiCpp
<leader>cpa Creates C++ application with respective CMake files and scripts
<leader>cpm Creates C++ class within modules directory and add CMake files
<leader>cpd Creates C++ class within custom named directory and add CMake files
<leader>cpe Clones external Git repository to the externals directory of the C++ project
<leader>cpt Toggles autocompilation at module and/or app creation (enabled by default)
<leader>cpc Compiles the current C++ project

Configuration

AhoiCpp provides a configurable interface. The default follows:

{
    autocompile_on_create = true,
    keymaps = {
        group_c  = "<leader>c",
        group_cp = "<leader>cp", 
        help = "<leader>cph",
        create_app = "<leader>cpa",
        create_module = "<leader>cpm",
        create_module_dir = "<leader>cpd",
        clone_external = "<leader>cpe",
        toggle_autocompile = "<leader>cpt",
        compile = "<leader>cpc",
    },
}

You are also able to override the keymap bindings, for example:

{
    'martuscellifaria/ahoicpp.nvim',
    config = function()
      require('ahoicpp').setup({keymaps = {compile = "<leader>cc",}})
    end,
}

Project structure

After running <leader>cpa YourApp:

YourApp/
├── .ahoicpp
├── .gitignore
├── CMakeLists.txt
├── AhoiCppProject.cmake
├── build.py
├── App/
│   ├── CMakeLists.txt
│   ├── src/
│   │   └── YourApp.cpp
│   └── version.h.in (or version.rc.in)
├── Modules/           (created when you add modules)
└── externals/         (created for Git dependencies)
    └── README.md

Demo

Creating and getting your first C++ app compiled

AhoiCpp short demo 1

Adding new classes to your project

AhoiCpp short demo 2

Adding external dependencies from git repositories

AhoiCpp short demo 3

Check Health

For health status of AhoiCpp, you can always run :checkhealth ahoicpp from the Neovim command line.

Troubleshooting

Error Solution
"AhoiCpp is not initialized" Run <leader>cpa first
"Python not found" Install Python and ensure it's in PATH
Compilation fails Check build/build.log

License

MIT (see LICENSE for details)