LeetCode|力扣 智能C++语法智能提示

为 [LeetCode(力扣)中国站](https://leetcode.cn) 提供增强版的 C++ 自动补全、悬浮提示与跳转功能,**纯前端实现、无需后端服务器**,助力更高效刷题!

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Autore
Onion_Big
Installazioni giornaliere
0
Installazioni totali
11
Valutazione
0 0 0
Versione
5.1.0
Creato il
27/06/2025
Aggiornato il
27/06/2025
Dimensione
7,68 KB
Licenza
MIT
Applica a

📦 LeetCode C++ IntelliSense Booster V5.1

LeetCode(力扣)中国站 提供增强版的 C++ 自动补全、悬浮提示与跳转功能,纯前端实现、无需后端服务器,助力更高效刷题!

✨ 功能亮点

  • C++ 智能补全:支持 vectorsortmemset 等常用函数/类/语法关键字的提示与 snippet 补全
  • 悬浮提示(Hover Doc):支持函数、类、关键字的英文说明
  • 变量类型提示:悬浮变量名自动显示其声明类型
  • 函数定义跳转Ctrl + ClickF12 可跳转至函数定义行(当前文件内)
  • ⚙️ 语言自适应:仅在语言为 C/C++ 时启用,避免干扰其他语言

🖥️ 使用方法

  1. 安装 Tampermonkey(油猴) 插件
  2. 添加本脚本
  3. 打开任一 LeetCode 中国题目页面
  4. 将语言切换为 C++,即可体验增强提示功能

🧠 示例功能展示

类型 示例 描述
补全提示 vector, sort 自动补全 + 参数 snippet
悬浮提示 memset 显示函数签名与参数说明
类型提示 arr, dp 悬浮变量显示:int arr[100]
跳转定义 dfs() 函数名 Ctrl+点击 / F12 定位到定义行

🔍 技术实现

  • 基于 Monaco Editor API
  • 使用正则表达式实时构建变量 / 函数索引表
  • 使用 onDidChangeContent() 实时监听文本更新
  • 无需后端、无需 LSP、纯 JavaScript 实现

🚧 注意事项

  • 当前版本 不支持跨文件跳转
  • 对变量类型推断支持有限,仅支持显式声明如 int x = 0;
  • 若需更强大的智能补全(如 clangd LSP 支持),建议结合 monaco-languageclient + lsp-ws-proxy

📌 更新记录

V5.1 更新内容:

  • 修复 onDidChangeModelContent 报错 → 正确使用 model.onDidChangeContent
  • 新增变量类型悬浮提示
  • 支持函数名点击跳转定义
  • 优化词典匹配效率,增强兼容性

如需更多功能(如 struct 支持、LSP 服务接入、参数签名提示),欢迎提 Issue 或 PR!