Skip to content

emacsmirror/cppinsights

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cppinsights.el

EMACS GitHub License MELPA

An Emacs package that integrates with C++ Insights, a tool that transforms C++ source code into its expanded form, revealing the details the compiler sees after applying language features like templates, operator overloading, and lambda functions.

Description

This package allows you to run C++ Insights directly from within Emacs, displaying the transformed code in a separate buffer. It helps C++ developers understand how the compiler interprets their code, making it easier to debug complex C++ features and learn about the language's inner workings.

Installation

Prerequisites

Before using this package, you need to install the C++ Insights command-line tool:

Windows

  1. Install WSL (Windows Subsystem for Linux)
  2. Follow the Ubuntu instructions below within WSL

macOS

Using Homebrew:

brew install cmake llvm
git clone https://github.com/andreasfertig/cppinsights.git
cd cppinsights
mkdir build && cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_CXX_COMPILER=clang++ ..
make
sudo make install

Ubuntu/Debian

sudo apt-get install cmake clang libclang-dev llvm
git clone https://github.com/andreasfertig/cppinsights.git
cd cppinsights
mkdir build && cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
make
sudo make install

Arch Linux

Using AUR:

pamac install cppinsights

Package Installation

With Straight

(use-package cppinsights
  :straight (:host github :repo "chrischen3121/cppinsights.el")
  :commands cppinsights-run
  :custom
  ;; Customize variables as needed
  (cppinsights-binary "insights")  ;; Path to the insights binary
  (cppinsights-extra-args '("-std=c++17"))  ;; Additional arguments to pass to C++ Insights
  :bind
  ;; Add keybinding for cppinsights-run
  (:map c++-mode-map
        ("C-c c i" . cppinsights-run)))

With Doom Emacs

In packages.el:

(package! cppinsights
  :recipe (:host github :repo "chrischen3121/cppinsights.el"))

In config.el:

(use-package! cppinsights
  :commands cppinsights-run
  :custom
  (cppinsights-program "insights")  ;; Path to the insights binary
  (cppinsights-clang-opts '("-O0" "-std=c++17"))  ;; Additional arguments to pass to internal clang
  :init
  ;; Add keybinding for cppinsights-run
  (map! :map c++-mode-map
        :desc "Run C++ Insights" "C-c i" #'cppinsights-run))

With package-vc-install (Emacs 30+ built-in)

(package-vc-install '(cppinsights :url "https://github.com/chrischen3121/cppinsights.el"))

Usage

  1. Open a C++ file in Emacs
  2. Run M-x cppinsights-run to process the current file
  3. A new buffer will open showing the transformed code

You can customize the package by:

  • M-x customize-group RET cppinsights RET

Key Bindings

You can add a key binding to your Emacs configuration:

(keymap-set c++-mode-map "C-c c i" #'cppinsights-run)

About

Integration with cppinsights tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Emacs Lisp 100.0%