mm4cN/nvim-conan

github github
dependency-management
stars 8
issues 0
subscribers 1
forks 1
CREATED

UPDATED


๐ŸŒฟ nvim-conan

CI


โœจ Features

  • ๐Ÿงฑ Project Initialization
    Seamlessly set up your C/C++ projects with Conan integration.

  • ๐Ÿง  Command Palette via :Conan
    Use :Conan <subcommand> for interactive Conan actions:

    • install: Install dependencies
    • build: Build using Conan profiles
    • lock: Create or update lockfiles
    • sbom: Generate a CycloneDX SBOM from the resolved dependency graph
    • search: Search Conan cache or remotes
    • create: Package your recipe
    • export: Export the recipe
    • export_package: Export prebuilt packages
    • upload: Upload recipes to remotes (with Telescope-powered remote and ref selection!)
  • ๐Ÿ”ญ Telescope Integration
    Intuitive fuzzy-pickers for selecting remotes and cached packages before upload. Search results can also be added directly to a configured Python recipe.

  • โšก Neovim Native
    No Python wrappers. No frills. Pure Lua.

  • ๐Ÿ›ก๏ธ Safe Command Execution Conan commands are passed as argument lists rather than shell command strings.


โš™๏ธ Installation

Using lazy.nvim:

return {
  "mm4cN/nvim-conan",
  dependencies = {
    "nvim-telescope/telescope.nvim",
  },
}

๐Ÿ”ง Configuration

Default setup:

require("conan").setup()

This checks whether Conan is available, bootstraps config files, and provides :Conan commands.

On first use in a Conan project, an interactive wizard creates conan-config.json in the project root. The plugin also recognises .vscode/conan-config.json, so teams that keep project settings there do not need a duplicate file.

The automatic first-time configuration leaves Conan's optional build_policy unset. :Conan reconfigure accepts a free-form optional value such as missing or missing:zlib/*. A missing, empty, or blank value omits --build; otherwise, install, build, and create include --build=<value>.

All Conan terminal buffers are listed so they remain visible to buffer navigation and selectors such as CodeCompanion's #buffer. :Conan build additionally uses the stable name conan-build.

List-valued Conan configuration can be written as a JSON array without escaping its quotes:

{
  "conf": {
    "tools.build:cxxflags+": [
      "-fsanitize=address,undefined",
      "-fno-omit-frame-pointer"
    ]
  }
}

The array is passed to Conan as one literal -c argument. Pre-encoded string values remain supported for backwards compatibility. During :Conan reconfigure, list values can be entered using either JSON double quotes or the equivalent single-quoted form.

Create and export commands accept additional Conan arguments:

:Conan create [args...]
:Conan create --version=1.2.3
:Conan export [args...]
:Conan export --user=alice --channel=stable
:Conan export_package [args...]
:Conan export_package --output-folder=build/package --user=alice --channel=stable

They generate argv in this order:

conan create [recipe] [profiles] [optional build policy] [args...]
conan export [recipe] [args...]
conan export-pkg [recipe] [args...]

Additional arguments retain their original order, remain separate literal argv elements, and are passed directly to Conan without shell interpretation.

Generate a CycloneDX SBOM with Conan 2.26 or newer:

:Conan sbom
:Conan sbom 1.4
:Conan sbom 1.6 artifacts/sbom

The defaults are CycloneDX 1.6 and build/sbom. The command resolves the configured recipe with its profiles, options, conf, and lockfile, then writes sbom-cyclonedx-<version>.json through Conan's built-in SBOM deployer.

Command-line completion suggests configured remotes for the second search argument and for --remote/-r values. For create, export, and export_package, available flags are read from the installed Conan version's --help output and cached for the Neovim session.

In the :Conan search results, a selected package reference can be added to the configured Python recipe with:

<C-r>  append self.requires(...) to requirements()
<C-t>  append self.tool_requires(...) to build_requirements()
<C-o>  add resolved dependency options to default_options

If the target method does not exist, it is created at the end of the ConanFile class. These bindings are available only when conan-config.json selects an existing .py recipe. Ambiguous or malformed recipe structures are left unchanged and reported as errors.

The search preview resolves the selected reference with conan graph info and displays its current option values below the remote availability list. Results are cached while the picker remains open. <C-o> stores missing values as dependency patterns such as "zlib/*:shared": False. Existing values are preserved, and default_options is placed immediately before the first recipe method.

This is a breaking change for exports: :Conan export alice stable and :Conan export_package alice stable are no longer rewritten as user/channel flags. Pass explicit Conan flags instead, as shown in the examples above.


๐Ÿ“‹ Requirements

Neovim: 0.12 or higher

Lua: 5.1+ (included with Neovim)

Conan: 2.x โ€” installed manually and available on your PATH

Telescope.nvim: Required for search, upload, and interactive configuration pickers

Run :checkhealth conan to verify the required components are available.


๐Ÿงช Development

Install the test dependencies and run the headless Neovim test suite:

make deps
make test

Tests use mini.test with real Telescope and Plenary dependencies. Command construction is kept in the pure Lua conan.command_builder module so it can be tested without loading UI code.

Check or apply Lua formatting with StyLua:

make format-check
make format

๐Ÿ“š Documentation


๐Ÿ›ก License

This project is licensed under the MIT License.


Embrace the harmony of Neovim and Conan, orchestrated through Lua.