Package Control

The official Sublime Text package manager.

CppAssistant

Sublime Text 4 C++ assistant: smart STL completions, Chinese diagnostics, goto-def, jiangly formatting

By chenmoulaile
Created August 26, 2026, last updated December 5, 2026.

NovOctSepAugJulJunMayAprMarFebJan Dec2025 Nov 2026-W49 | installs: 4 | removals: 1 | upgrades: 2 2026-W49 | installs: 4 | removals: 1 | upgrades: 2 2026-W49 | installs: 4 | removals: 1 | upgrades: 2 2026-W48 | installs: 7 | removals: 4 | upgrades: 4 2026-W48 | installs: 7 | removals: 4 | upgrades: 4 2026-W48 | installs: 7 | removals: 4 | upgrades: 4 2026-W47 | installs: 4 | removals: 1 | upgrades: 9 2026-W47 | installs: 4 | removals: 1 | upgrades: 9 2026-W47 | installs: 4 | removals: 1 | upgrades: 9 2026-W46 | installs: 4 | removals: 1 | upgrades: 5 2026-W46 | installs: 4 | removals: 1 | upgrades: 5 2026-W46 | installs: 4 | removals: 1 | upgrades: 5 2026-W45 | installs: 4 | removals: 0 | upgrades: 2 2026-W45 | installs: 4 | removals: 0 | upgrades: 2 2026-W45 | installs: 4 | removals: 0 | upgrades: 2 2026-W44 | installs: 6 | removals: 3 | upgrades: 3 2026-W44 | installs: 6 | removals: 3 | upgrades: 3 2026-W44 | installs: 6 | removals: 3 | upgrades: 3 2026-W43 | installs: 5 | removals: 2 | upgrades: 0 2026-W43 | installs: 5 | removals: 2 | upgrades: 0 2026-W43 | installs: 5 | removals: 2 | upgrades: 0 2026-W42 | installs: 0 | removals: 0 | upgrades: 0 2026-W42 | installs: 0 | removals: 0 | upgrades: 0 2026-W42 | installs: 0 | removals: 0 | upgrades: 0 048 WeeklyInstalls 048 WeeklyUpgrades 2026-W49 | upgrades: 2 2.3.8 / 2.3.7 2026-W47 | upgrades: 9 2.3.6 / 2.3.5 / ... 2.3.6 / 2.3.5 / 2.3.4 2026-W46 | upgrades: 5 2.3.3 / 2.3.2 / ... 2.3.3 / 2.3.2 / 2.3.1 / 2.3.0 2026-W45 | upgrades: 2 2.2.1 / 2.2.0 / ... 2.2.1 / 2.2.0 / 2.1.1 / 2.1.0 2026-W44 | upgrades: 3 2.0.0 2026-W43 | upgrades: 0 1.8.0 / 1.7.1 2026-W42 | upgrades: 0 1.7.0 2026-W40 1.6.2 2026-W39 1.6.1 / 1.6.0 / ... 1.6.1 / 1.6.0 / 1.5.2 / 1.5.1 / 1.5.0 / 1.4.1 / 1.4.0 2026-W36 1.3.4 / 1.3.2 / ... 1.3.4 / 1.3.2 / 1.3.1 / 1.3.0 2026-W35 1.2.3 / 1.2.2 / ... 1.2.3 / 1.2.2 / 1.2.1 / 1.2.0 / 1.1.0 / 1.0.0
Installations: recent average 4 per week, 34 in total
Installations minus removals
Upgrades

Links

Versions

2.3.8 (>ST4000) ·
2026-12-05 18:28

More

CppAssistant

English · 简体中文

Package Control Package Control Downloads Latest release GitHub Actions License Sublime Text

C++ assistance for Sublime Text 4 — pure-Python completion by default, with an optional real clangd engine. Tuned for competitive programming (OI / ICPC / CSP-S).

CppAssistant works the moment you install it, with no background daemon: completion comes from an incremental pure-Python engine plus a curated STL/CP database. If you want compiler-grade semantics, switch completion_engine to auto or clangd; the built-in LSP client then drives clangd for you.


🆕 What's new in 2.3.5

Change Why it matters
Lint no longer spawns g++ per keystroke Instant check debounce 20 → 150 ms, compiler 100 → 350 ms; results stay cached per text hash
No compile for half-typed members a.pu stops flashing has no member named 'pu'
Parse Error ... Unexpected character fixed Multi-line completion details were handed to Sublime's JSON/HTML details renderer; they are single-line now

Full history: CHANGELOG.md.


🏆 Why OIers like it

Feature Benefit in a contest
bits/stdc++.h PCH acceleration Warm diagnostics in ~200 ms, member completion in ~10–20 ms
Array bounds checking Catches int a[10]; a[10] = 1 instantly
Template parameter deduction vector<int> v; v. → push_back(int), not push_back(value_type)
PBDS without the header trivia tree / gp_hash_table completions insert ext/pb_ds/* for you
CP-specific database __int128, __gnu_pbds, C++20 ranges, C-lib I/O
Full-width punctuation fix , in code is a stray '\357' error; one keystroke fixes every occurrence in code
Diagnostic one-click copy Ctrl+Shift+C → paste the error into a group chat or search
Jiangly-style formatting 4 spaces, K&R, 100 columns — the contest standard
Template packs Geometry, Graph, DS, Strings, Math — bundled, installed on demand
Snippet tab stops $0, $1, ${1:default} navigation in every template
Bilingual diagnostics Chinese / English / both, switchable without rerunning the compiler
Menu localization CppAssistant: Toggle Menu Language translates this plugin's own menus

✨ Features

🎯 Completion

🔍 Diagnostics

🧭 Navigation

⚡ Editing, actions and formatting

📦 Templates and snippets

🌐 Localization


🚀 Quick start

  1. Install the package (Package Control, git clone or the .sublime-package release asset — see Installation below).
  2. Open a .cpp file and start typing. Completion appears with no setup.
  3. Press F12 to jump to a definition, Shift+Alt+F to format.
  4. Put the file next to a compile_commands.json (or just a local g++/clangd on PATH) to get compiler-grade answers.

A five-line example of what the popup shows for vector<int> v; v.:

push_back     void push_back(int)                 · O(1)     [STL]
at            int at(size_type) const             · O(1)     [STL]
find          iterator find(const int&)           · O(n)     [STL]

And for a PBDS ordered set:

order_of_key      size_type order_of_key(const int&) const   · O(log n)
find_by_order     iterator find_by_order(size_t)             · O(log n)

📦 Installation

  1. Ctrl+Shift+P → Package Control: Install Package
  2. Search CppAssistant → install

Git clone

# Windows
cd "%APPDATA%\Sublime Text\Packages"
git clone https://github.com/chenmoulaile/Sublime-CppAssistant CppAssistant

# Linux / macOS
cd ~/.config/sublime-text/Packages
git clone https://github.com/chenmoulaile/Sublime-CppAssistant CppAssistant

Manual package

Download CppAssistant.sublime-package from the latest release, drop it into Packages/ (or Installed Packages/), and restart Sublime Text.


⌨️ Commands

Navigation

Command Purpose
CppAssistant: Go to Definition Jump to definition (F12)
CppAssistant: Find References References grouped by file
CppAssistant: Call Hierarchy Incoming / outgoing calls
CppAssistant: Type Hierarchy Base and derived classes
CppAssistant: Rename Symbol Project-wide rename
CppAssistant: Code Actions Quick fixes and refactors

Editing

Command Purpose
CppAssistant: Format Document (jiangly style) Format the whole file
CppAssistant: Format Selection Format selected lines
CppAssistant: Fix Full-width Punctuation ,;:() → ,;:() in code only

Diagnostics

Command Purpose
CppAssistant: Show Diagnostics Diagnostics panel
CppAssistant: Copy Diagnostic Copy the current diagnostic
CppAssistant: Diagnostic Language - … English / Chinese / both
CppAssistant: Language - … Menu bar + completion + diagnostics at once
CppAssistant: Diagnostic Engine - … compiler / clangd / libclang
CppAssistant: Completion Engine - … builtin (pure Python) / auto / clangd
CppAssistant: Toggle Inline Error Phantoms Inline messages on/off
CppAssistant: Completion Engine Status Which engine answered, and why

Templates and settings

Command Purpose
CppAssistant: Browse Templates Preview and insert a snippet
CppAssistant: Install Template Pack Install a bundled pack
CppAssistant: Manage Templates Enable / disable installed packs
CppAssistant: Create User Snippet Create from the selection
CppAssistant: Manage User Snippets Open / rename / recycle
CppAssistant: Import Snippets Import from JSON
CppAssistant: Validate Settings Report values Sublime ignores
CppAssistant: Toggle Menu Language Menu EN ↔ ZH
Preferences: CppAssistant Settings Edit settings

⌨️ Key bindings

Ctrl+Shift+C (Copy Diagnostic) is bound out of the box in the shipped Default.sublime-keymap; override it in your User keymap if it conflicts with your own setup. The remaining bindings ship in Example.sublime-keymap — copy the entries you want into your User keymap.

Keys Command
F12 Go to Definition
Shift+F12 Find References
Shift+Alt+F Format Document
Ctrl+Alt+F Format Selection
Ctrl+. Code Actions
Ctrl+Alt+R Rename Symbol
Ctrl+Alt+D Show Diagnostics
Ctrl+Shift+C Copy Diagnostic
Ctrl+Alt+, Fix Full-width Punctuation

⚙️ Settings

Open Preferences: CppAssistant Settings, or edit Packages/User/CppAssistant.sublime-settings. Every key is documented inline in the shipped settings file; run CppAssistant: Validate Settings to catch values Sublime would otherwise ignore.

Engines

Setting Default Description
enable_completions true Completion master switch
completion_engine "builtin" builtin = pure Python, no clangd, no libclang; auto = clangd when on PATH; clangd = always, with status-bar diagnostics
builtin_uses_libclang false Let builtin mode use libclang when it is already warm
enable_fast_engine true FastEngine for same-file symbols
enable_libclang_engine true Allow libclang at all (master switch)
libclang_path "" libclang path; empty = auto-discover
libclang_pch true Build bits/stdc++.h PCH
libclang_completion true Merge libclang completion when warm
libclang_goto true Use libclang for cross-file F12
clangd_binary "" clangd executable; empty = PATH
clangd_args [] Extra clangd arguments
clangd_completion_wait_ms 0 Synchronous wait for clangd; 0 = never block
enable_clangd_style_completion true true = fuzzy LSP style, false = strict prefix

Completion behaviour

Setting Default Description
auto_insert_includes true Insert #include when a completion is accepted
cpp_auto_insert_pbds_includes true Insert ext/pb_ds/* for PBDS completions
show_status_hint true Status bar: engine, call signature, argument index
enable_hover true clangd hover popup
enable_signature_help true Signature help inside call parentheses

Diagnostics

Setting Default Description
enable_linting true Diagnostics master switch
lint_engine "compiler" compiler, clangd or libclang
instant_basic_check true Millisecond bracket/punctuation check
lint_debounce 0.1 Idle seconds before the compiler check
lint_timeout 12 Compiler timeout in seconds
enable_pch true Build the bits/stdc++.h PCH cache
show_phantoms true Inline diagnostic messages
display_language "en" en, zh or both
menu_language "en" en or zh; follows display_language
cxx_standard "c++14" Standard for checks and clangd
compiler_path "" Compiler executable; empty = PATH
compiler_extra_args [] Extra compiler arguments
include_paths [] Extra header directories
suppress_unused_warnings true Add -Wno-unused-variable etc.
diagnostic_filters [] Warning codes to suppress

Formatting

Setting Default Description
indent_width 4 Indent width for the built-in formatter
format_on_save false Format the document before saving
clang_format_path "" clang-format executable
clang_format_style jiangly config clang-format style string

🔧 How it works

Completion pipeline

  1. clangd (primary) — async JSON-RPC over stdio, compile_commands.json generated and cached per file, fallback flags from your settings.
  2. FastEngine (fallback) — incremental lexer + tolerant parser, scope-aware symbols, template deduction, array bounds; answers in single-digit milliseconds and also backs F12 and the instant check.
  3. libclang (optional) — ctypes, PCH-accelerated, used only when the translation unit is already warm.
  4. Built-in database — STL members, CP types (__int128, __gnu_pbds), C++20 ranges/views/concepts, all with English and Chinese descriptions.
  5. User snippets and template packs — always first in the popup, with tab stops and origin labels.

Diagnostics engines

Engine Speed Notes
Instant basic check < 10 ms Brackets, punctuation, strings, #include, #if
Compiler ~300 ms (PCH) Full syntax, -Wall, PCH cache
clangd ~50 ms Live LSP diagnostics, no compiler process
libclang ~200 ms Precise cross-file locations, no compiler process

F12 resolution order

  1. FastEngine same-file (scope-aware ranking)
  2. Other open files
  3. Included headers / include_paths, recursively
  4. libclang cross-file (when warm)
  5. Standard-library symbol → header mapping

📋 Requirements

The plugin source is Python 3.3 compatible (older ST4 hosts) and runs on 3.14 in current builds. A .python-version file in the package root pins the host: 3.8 selects Python 3.14 on build 4205+ and Python 3.8 on earlier 4050+ builds. No third-party Python packages are required.


🧪 Development

# Full test suite (213 tests)
python -m unittest discover -s tests -v

# libclang tests (opt-in, needs libclang + clang++)
CA_TEST_LIBCLANG_PCH=1 python -m unittest tests.test_semantic_engine -v

# Lint / types (same commands as CI)
flake8 . --select=E9,F63,F7,F82
mypy --ignore-missing-imports --python-version 3.10 cppassistant/ CppAssistant.py

Modules

File Responsibility
CppAssistant.py Sublime integration: commands, events, diagnostics, formatting, hierarchy, settings UI
cppassistant/ca_clangd.py Minimal LSP client: JSON-RPC, completion/hover/signature/rename/code actions/references/hierarchy
cppassistant/ca_fast.py FastEngine: incremental lexer, tolerant parser, symbol index, call context
cppassistant/ca_engine.py Legacy engine: type environment, member signatures, formatting fallbacks, compiler output parsing
cppassistant/ca_semantic.py Optional libclang ctypes engine with PCH acceleration
cppassistant/ca_stdlib_data.py STL/CP completion data, PBDS namespace, C++20 subset, translations
cppassistant/ca_template_packs.py Bundled template pack catalogue, XML generation, installation
cppassistant/ca_user_snippets.py User .sublime-snippet loader with caching and origin labels
cppassistant/ca_fixes.py Full-width punctuation scanner/rewriter (code regions only)
cppassistant/ca_config.py Settings schema validation
cppassistant/ca_filters.py Diagnostic filter normalization
cppassistant/ca_menu_language.py Menu translation overlay generator

CI runs flake8, mypy, the unit tests on Python 3.9 / 3.10 / 3.12 / 3.14, the libclang tests, and builds the .sublime-package on every tag.


🐛 Troubleshooting

Issue Solution
All commands grayed out / menus dead Two causes. (1) CppAssistant is listed in ignored_packages in Preferences.sublime-settings — remove it and restart; a package cannot un-ignore itself. (2) You are still on 2.2.1 or older: those packages shipped no .python-version, so current ST4 builds put them on the disabled Python 3.3 host and never load the Python side. Upgrade to 2.3.1+ (Package Control: Upgrade Package), or drop CppAssistant.sublime-package from the latest release into Installed Packages/
clangd not found Install clangd (pacman -S mingw-w64-x86_64-clang, apt install clangd, brew install llvm) or set clangd_binary
F12 does nothing Check the key binding in Example.sublime-keymap, or run the command from the palette
Enter inserts a newline Sublime default. Add { "keys": ["enter"], "command": "insert", "args": {"characters": "\n"}, "context": [{ "key": "auto_complete_visible" }] } to your user keymap
Formatting does nothing Install clang-format or set clang_format_path; the built-in fallback only handles basic indentation
Code actions / rename / hierarchy do nothing They need clangd. Save the file first and check Completion Engine Status
bits/stdc++.h still reports missing PBDS PBDS headers are inserted automatically now; if you disabled cpp_auto_insert_pbds_includes, add ext/pb_ds/* manually
Full-width fix skipped my comment Intentional: only code regions are rewritten, so Chinese punctuation in comments and strings survives
Diagnostics stopped Restart Sublime Text and check the console for [CppAssistant] messages
libclang not found Install LLVM / MSYS2 / Xcode, or set libclang_path; the compiler engine takes over automatically
libclang PCH unused Needs a clang++ matching libclang's major.minor on PATH
Settings seem ignored Run CppAssistant: Validate Settings — invalid values are reported in the output panel

📄 License

MIT © chenmoulaile

🙏 Acknowledgments

Results

Packages