https://github.com/marc0x71/cmake-simple.nvim
Simple NeoVim plugin for CMake/CTest integration
https://github.com/marc0x71/cmake-simple.nvim
Last synced: about 2 months ago
JSON representation
Simple NeoVim plugin for CMake/CTest integration
- Host: GitHub
- URL: https://github.com/marc0x71/cmake-simple.nvim
- Owner: marc0x71
- License: mit
- Created: 2024-11-01T18:29:00.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-11-23T19:00:50.000Z (6 months ago)
- Last Synced: 2024-11-23T20:17:39.871Z (6 months ago)
- Language: Lua
- Homepage:
- Size: 399 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmake-simple.nvim
Simple NeoVim plugin for CMake/CTest integration
## Motivation
If you are looking for a simple solution to run CMake/CTest commands without opening a new terminal and also run targets and tests in debug (with `nvim-dap`), this plugin might be for you! 😎It's **simple** to make life **simple**, and it's useful enough to make it essential 😀
## Description
`CMakeSimple` is a NeoVim plugin that will allow you (easily) to manage your workflow with CMake and CTest directly from your **favorite** editor.
You will be able to perform the configure of `CMake` project simply by pressing a button, as well as compile your project or maybe run your tests thanks to the help of `CTest`.
You will also be able to debug your tests, and even your applications, directly from NeoVim thanks to the help of `nvim-dap`, or perform the compilation of your code **automagically** when you save your changes!
**So what are you waiting for? Install it and enjoy!**
## Requirements
This plugin requires:
- [`fidget.nvim`](https://github.com/j-hui/fidget.nvim) to show notification messages and execution progress.
- [`nvim-dap`](https://github.com/mfussenegger/nvim-dap) for debugging targets and tests
- [`treesitter`](https://github.com/nvim-treesitter/nvim-treesitter) for tests source code analysis
- [`telescope`](https://github.com/nvim-telescope/telescope.nvim) used for UI selections
- [`plenary`](https://github.com/nvim-lua/plenary.nvim) used also for unit testsYou also must have `cmake` and `ctest` installed on your local machine
## Installation
You can use your preferred package manager, the following example is based on [`lazy.nvim`](https://github.com/folke/lazy.nvim):
```lua
{
'marc0x71/cmake-simple.nvim',
name = "cmake-simple",
dependencies = {
{
"j-hui/fidget.nvim",
config = function()
require("fidget").setup({
notification = {
window = {
winblend = 0,
},
}
})
end,
},
},
lazy = false,
opts = {
build_folder = "build",
jobs = 2,
dap_adapter = "gdb",
clean_first = false,
show_command_logs = false,
auto_build = false
},
keys = {
{ 'mc', 'CMakeConfigure', desc = "Configure project" },
{ 'mb', 'CMakeBuild', desc = "Build project" },
{ 'mC', 'CMakeClean', desc = "Clean project" },
{ 'ml', 'CMakeLog', desc = "Show last log" },
{ 'mt', 'CTestCases', desc = "Show tests" },
{ 'mL', 'CMakeToogleCommandLog', desc = "Toogle command log window" },
{ 'mr', 'CMakeRun', desc = "Execute target" },
{ 'md', 'CMakeDebug', desc = "Execute target in debug" },
{ 'mT', 'CRunTestCases', desc = "Execute all tests" },
{ 'ms', 'CMakeSettings', desc = "Change CMakeSimple settings" },
{ 'mS', 'CMakeSelectConfType', desc = "Select CMake configuration type" }
}
}
```## Configuration
`cmake-simple` comes with the following default configuration:
```lua
{
-- Path used to build the CMake project
build_folder = "build",
-- How many jobs can be used for building and running all tests
jobs = 2,
-- The dap adapter used for debugging
dap_adapter = "gdb",
-- Clean targets before build
clean_first = false,
-- Show always cmake command log window
show_command_logs = false,
-- Automatically build project if a source file has been changed
auto_build = false
}
```You can overwrite using `setup` function or via `opts` if you are using [`lazy.nvim`](https://github.com/folke/lazy.nvim):
## Available Commands
|Command|Description|
|-|-|
|CMakeInit|Initialize CMake project and reset selected presets. CMakeLists.txt *must be* present in he current folder. This command is executed automatically when current folder change|
|CMakeConfigure|Execute `cmake` command to configure the project|
|CMakeBuild|Execute `cmake` command to build the project|
|CMakeClean|Execute `cmake` command to clean the project|
|CMakeLog|Show last execution log|
|CTestCases|Show found test cases (show next paragraph for available shortcuts)|
|CMakeToogleCommandLog|Hide/Show log windows when `cmake` command is executed |
|CRunTestCases|Run all CTest test cases|
|CMakeRun|Run target|
|CMakeDebug|Run target in debug (using DAP)|
|CMakeSettings|Change CMakeSimple setting for current project|
|CMakeSelectConfType|Select CMake configuration type|## CTest
Using `cmake-simple` you can easly execute test using the following keyboard shortcut in the `CTestCases` command :
- `R` - execute all tests
- `r` - execute selected test
- `d` - debug selected test
- `l` - show last log of selected test
- `` - go to the source code of selected test
- `` - refresh testcases without changing selected test preset
- `q` or `` - close the testcases windowCurrently only for the following test framework is supported the "go-to" feature:
- [`GTest`](https://github.com/google/googletest)
- [`Catch2`](https://github.com/catchorg/Catch2)## Status line
If you are using ['lualine.nvim'](https://github.com/nvim-lualine/lualine.nvim) you can add an indicator
that will show if the project has been build or not, for example:
```lua
return {
'nvim-lualine/lualine.nvim',
dependencies = {'nvim-tree/nvim-web-devicons'},
config = function()
...
local cmakesimple = require 'cmake-simple'
require('lualine').setup({
...
sections = {
lualine_x = {
{
cmakesimple.build_status,
cond = cmakesimple.build_status_available
}
}
}
...
})
end
}
```## Troubleshooting
If this plugin isn't working, feel free to make an issue or a pull request.