Skip to content

infalmo/inline-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inline C++

Makes C++ code embedded in Rust files pleasant to work with.

If you keep C++ source inside a Rust string — VS Code normally paints the whole thing as one flat string color, and nothing formats it. This extension fixes both: tag the string with /* cpp */ and its contents get real C++ syntax highlighting, plus optional clang-format on save.

const KERNEL: &str = r#" /* cpp */
    __global__ void k(float *x) {
        x[threadIdx.x] *= 2.0f;
    }
"#;

Add "rust-analyzer.semanticHighlighting.strings.enable": false to your VS Code settings, otherwise the Rust language plugin colors the whole string itself and covers up the C++ highlighting. Also optionally, if you'd like the embedded C++ tidied up automatically every time you save, turn on the inlineCpp.formatOnSave setting to run clang-format from path.

About

Syntax highlighting and clang-format for C++ inside `/* cpp */` marked Rust raw strings.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors