Compare commits
50
Commits
main
...
vscode-extension
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c6fea84d4 | ||
|
|
5c79902f70 | ||
|
|
2e5308e044 | ||
|
|
78b427b667 | ||
|
|
7faaac2aea | ||
|
|
c7011cc32e | ||
|
|
14a2470a12 | ||
|
|
4c7f41151a | ||
|
|
02e8c21118 | ||
|
|
b06a832472 | ||
|
|
25f970db7e | ||
|
|
44569ec26c | ||
|
|
70de478857 | ||
|
|
a6987f8877 | ||
|
|
2e9342b5fa | ||
|
|
9e7c8aafbd | ||
|
|
76213ccf0b | ||
|
|
dcedfdadff | ||
|
|
7597184909 | ||
|
|
3955ae8eca | ||
|
|
8598edb535 | ||
|
|
568fa4f2bf | ||
|
|
95a6375558 | ||
|
|
8fe8d51289 | ||
|
|
86a9513e51 | ||
|
|
9325cf327d | ||
|
|
e455235218 | ||
|
|
dd025016c3 | ||
|
|
31da360274 | ||
|
|
0ac3b2ab27 | ||
|
|
82ef21e816 | ||
|
|
00e25c1f69 | ||
|
|
f274a48f60 | ||
|
|
f75d34f64a | ||
|
|
2e10987982 | ||
|
|
c96a2de94c | ||
|
|
fd2254b2a8 | ||
|
|
db300977c2 | ||
|
|
f583062b4b | ||
|
|
84afb6bcb8 | ||
|
|
e8e11cffce | ||
|
|
d180b949f4 | ||
|
|
4a546d17bc | ||
|
|
12569f0afd | ||
|
|
155bed4ce9 | ||
|
|
78af67d1e0 | ||
|
|
9361992d11 | ||
|
|
d1b75d88c5 | ||
|
|
3887205ebb | ||
|
|
f4f798a4d0 |
No files matched your search
+3
-4
@@ -1,8 +1,9 @@
|
|||||||
/target/
|
/target/
|
||||||
/dist/
|
/dist/
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
.idea/
|
.idea/
|
||||||
.vscode/
|
# Editor settings at repo root only (keep vscode-extension/.vscode for F5)
|
||||||
|
/.vscode/
|
||||||
*.pdb
|
*.pdb
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.marqdo/
|
.marqdo/
|
||||||
@@ -11,8 +12,6 @@
|
|||||||
/public/index.html
|
/public/index.html
|
||||||
/public/pages/
|
/public/pages/
|
||||||
|
|
||||||
# VS Code extension lives on branch `vscode-extension` only (see doc/design/vscode-extension.md)
|
|
||||||
/vscode-extension/
|
|
||||||
|
|
||||||
# Python spike venv (local)
|
# Python spike venv (local)
|
||||||
spike/.venv/
|
spike/.venv/
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
.vscode-test/**
|
||||||
|
node_modules/**
|
||||||
|
out/**
|
||||||
|
*.vsix
|
||||||
|
npm-debug.log*
|
||||||
|
.DS_Store
|
||||||
Vendored
+18
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Run Extension",
|
||||||
|
"type": "extensionHost",
|
||||||
|
"request": "launch",
|
||||||
|
"args": [
|
||||||
|
"--extensionDevelopmentPath=${workspaceFolder}",
|
||||||
|
"${workspaceFolder}/.."
|
||||||
|
],
|
||||||
|
"outFiles": [
|
||||||
|
"${workspaceFolder}/out/**/*.js"
|
||||||
|
],
|
||||||
|
"preLaunchTask": "npm: watch"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+24
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "watch",
|
||||||
|
"problemMatcher": "$tsc-watch",
|
||||||
|
"isBackground": true,
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "never"
|
||||||
|
},
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "npm",
|
||||||
|
"script": "compile",
|
||||||
|
"problemMatcher": "$tsc",
|
||||||
|
"group": "build"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
.vscode/**
|
||||||
|
.vscode-test/**
|
||||||
|
src/**
|
||||||
|
tsconfig.json
|
||||||
|
node_modules/**
|
||||||
|
.gitignore
|
||||||
|
**/*.map
|
||||||
|
**/*.ts
|
||||||
|
!out/**/*.js
|
||||||
|
media/logo-source.*
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
# 架构(规范)
|
||||||
|
|
||||||
|
## 进程边界
|
||||||
|
|
||||||
|
```
|
||||||
|
┌─────────────────────────────┐
|
||||||
|
│ VS Code Extension Host │
|
||||||
|
│ · 语言配置 / TextMate │
|
||||||
|
│ · 命令、任务、Problems │
|
||||||
|
│ · (日后)LSP client │
|
||||||
|
│ · (日后)DAP client │
|
||||||
|
└─────────────┬───────────────┘
|
||||||
|
│ spawn / stdio
|
||||||
|
▼
|
||||||
|
┌─────────────────────────────┐
|
||||||
|
│ marqdo CLI(已安装) │
|
||||||
|
│ · run / catalog / debug │
|
||||||
|
│ · 诊断文案与行号真相 │
|
||||||
|
└─────────────────────────────┘
|
||||||
|
```
|
||||||
|
|
||||||
|
扩展 **不嵌入** Rust 解释器;分发上用户安装 CLI(或日后可选打包 sidecar,仍属后置决策)。
|
||||||
|
|
||||||
|
## 语言 id
|
||||||
|
|
||||||
|
- VS Code `languageId`: `marqdo`
|
||||||
|
- 文件:`*.mq.md`(必须保留 `.md` 后缀以便通用预览;用 `filename` / `filenamePattern` 关联,避免抢全部 Markdown)
|
||||||
|
|
||||||
|
## 与 Markdown 扩展共存
|
||||||
|
|
||||||
|
`.mq.md` 同时是 Markdown。策略:
|
||||||
|
|
||||||
|
1. **默认**用 Marqdo 语言模式(执行语义优先)。
|
||||||
|
2. 提供命令「以 Markdown 打开预览」调用内置 Markdown preview(不切换语言 id 也可预览时,优先不破坏高亮)。
|
||||||
|
3. 不禁用用户其它 Markdown 扩展;冲突时文档说明如何 `files.associations`。
|
||||||
|
|
||||||
|
## 诊断契约
|
||||||
|
|
||||||
|
CLI 用户可见失败:
|
||||||
|
|
||||||
|
```text
|
||||||
|
path:line:col: message
|
||||||
|
```
|
||||||
|
|
||||||
|
扩展将相对路径解析到工作区 URI,`severity` 为 0-based。与语言仓 P0 诊断模型一致。
|
||||||
|
|
||||||
|
## CLI 安装(扩展侧)
|
||||||
|
|
||||||
|
- 启动时(`onStartupFinished`)检测:**CLI 是否存在**、**版本是否 ≥ `marqdo.minCliVersion`(默认 0.1.0)**、**stdlib (`lib/`) 是否可用**。
|
||||||
|
- 任一不满足 → 提示用户,由其选择安装 / 打开 Releases / 不再询问。
|
||||||
|
- 安装物落到扩展 `globalStorage/cli/`,并写入 `marqdo.cliPath` / `marqdo.libPath`(spawn 时带 `MARQDO_LIB`)。
|
||||||
|
- 命令:`Marqdo: Install / Repair CLI`、`Marqdo: Check CLI Status`。
|
||||||
|
- 预编译自动安装以 **Windows x64** Release zip 为主。
|
||||||
|
|
||||||
|
## 调试(P3 → 现有入口)
|
||||||
|
- **已落地**:命令 `Marqdo: Open Debugger` 子进程启动 `marqdo debug --no-open`,再打开浏览器 / Simple Browser。
|
||||||
|
- **中期**:DAP 适配器包装现有 debug session API(`src/view/debug_api.rs` 语义),避免第三套断点模型。
|
||||||
|
|
||||||
|
## OKF / catalog(P3)
|
||||||
|
|
||||||
|
- 命令触发 `marqdo catalog <workspace> -o .marqdo`。
|
||||||
|
- 生成物已在语言仓 `.gitignore`(`.marqdo/`);扩展只负责调用与打开 `index.md` / `catalog.yaml`。
|
||||||
|
|
||||||
|
## 非目标(本阶段)
|
||||||
|
|
||||||
|
- 在扩展内实现完整树遍历 / 字节码
|
||||||
|
- 替代 `marqdo view` 静态站
|
||||||
|
- 强制用户登录或云服务
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
# 开发流程
|
||||||
|
|
||||||
|
## 环境
|
||||||
|
|
||||||
|
- Node.js 20+(LTS)
|
||||||
|
- VS Code 1.85+(`engines.vscode` 在 `package.json` 收紧)
|
||||||
|
- 本机已安装 **Marqdo CLI ≥ 0.1.0**(`marqdo --version`),用于 Run / catalog 集成
|
||||||
|
|
||||||
|
## 首次
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout vscode-extension
|
||||||
|
cd vscode-extension
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
**推荐**:用 VS Code / Cursor **打开 `vscode-extension/` 文件夹**(不要只开仓库根),再按 F5(「Run Extension」)。Extension Development Host 会带上上级语言仓,便于打开 `public/*.mq.md` 验收。
|
||||||
|
|
||||||
|
验证:Language Mode = Marqdo;命令面板搜 `Marqdo: Run File` / `Open Debugger`。
|
||||||
|
|
||||||
|
## 日常脚本(约定)
|
||||||
|
|
||||||
|
| npm script | 用途 |
|
||||||
|
|------------|------|
|
||||||
|
| `npm run compile` | `tsc -p .` → `out/` |
|
||||||
|
| `npm run watch` | 监视编译 |
|
||||||
|
| `npm run lint` | 日后 ESLint(先可空) |
|
||||||
|
| `npm run package` | `vsce package` 打 `.vsix`(发布前) |
|
||||||
|
|
||||||
|
尚未加入的脚本:落地 `package.json` 时按上表补齐,勿引入与 Marqdo 语言仓抢戏的重型框架。
|
||||||
|
|
||||||
|
## 改语法 / 高亮
|
||||||
|
|
||||||
|
1. 对照语言仓 `doc/design/markdown-mapping.md`(以 `main` 为准)。
|
||||||
|
2. 改 `syntaxes/*.tmLanguage.json`(或等价)。
|
||||||
|
3. 用 `tests/` 与 `public/` 下真实 `.mq.md` 肉眼验收(Extension Host 打开语言仓 worktree)。
|
||||||
|
|
||||||
|
## 改 CLI 集成
|
||||||
|
|
||||||
|
- 子进程调用 `marqdo`,cwd = 工作区根或文件目录(与 `marqdo run` 导入/`lib/` 解析一致)。
|
||||||
|
- 解析 stderr 的 `path:line:col: message` 写入 `DiagnosticCollection`。
|
||||||
|
- **禁止**在扩展内重新实现解释器。
|
||||||
|
|
||||||
|
## 提交与推送
|
||||||
|
|
||||||
|
只在 **`vscode-extension` 分支** 提交本目录:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git status # 确认在 vscode-extension
|
||||||
|
git add vscode-extension
|
||||||
|
git commit -m "…"
|
||||||
|
git push -u origin vscode-extension
|
||||||
|
```
|
||||||
|
|
||||||
|
不要把本目录合并进 `main`(`main` 的 `.gitignore` 会忽略它)。
|
||||||
|
|
||||||
|
## 验收清单(P0 / P1)
|
||||||
|
|
||||||
|
- [ ] `.mq.md` 打开后 Language Mode = Marqdo
|
||||||
|
- [ ] `#` / `*` / `**` / `>` / 表格 / 注释行有可区分着色
|
||||||
|
- [ ] 函数体内 `---` / `***`、空返回 `****` 不与普通 Markdown 粗体完全糊成一团(尽力)
|
||||||
|
- [ ] F5 开发宿主可重复加载,无激活期未捕获异常
|
||||||
|
- [ ] `Marqdo: Run File` 成功时 Output 有输出;失败时 Problems 出现 `path:line:col`
|
||||||
|
- [ ] `Marqdo: Open Debugger` 拉起本地 debug 页(默认 `http://127.0.0.1:7430/`)
|
||||||
|
- [ ] 无 CLI 时启动提示 Install;确认后下载 bundle(含 stdlib)并可 `Run File`
|
||||||
|
|
||||||
|
设置:`marqdo.cliPath`、`marqdo.libPath`、`marqdo.autoInstall.checkOnStartup`、`marqdo.debugOpen`。
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
# VS Code 扩展(分支工作区)
|
||||||
|
|
||||||
|
| | |
|
||||||
|
|---|---|
|
||||||
|
| 状态 | **三按钮 Run / View / Debug + CLI 检测**(扩展 v0.0.5;封面 logo;需 CLI ≥ **0.1.0**) |
|
||||||
|
| 日期 | 2026-08-05 |
|
||||||
|
| 语言仓 | [`cflmy/marqdo`](https://github.com/cflmy/marqdo) `main` |
|
||||||
|
| 扩展仓形态 | **同仓库专用分支** `vscode-extension`(本目录);`main` **不跟踪**本目录 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. 与 `public` / `gh-pages` 的类比
|
||||||
|
|
||||||
|
| | `public/` 用户站 | `vscode-extension/` |
|
||||||
|
|--|------------------|---------------------|
|
||||||
|
| **main** | 跟踪可执行 `.mq.md` 源 | **忽略**本目录(不进 `main` 历史) |
|
||||||
|
| **专用分支** | `gh-pages`:生成 HTML | **`vscode-extension`**:扩展源码与规范 |
|
||||||
|
| **消费者** | 浏览器 / Pages | VS Code / Open VSX / Marketplace(日后) |
|
||||||
|
|
||||||
|
开发扩展时:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git fetch origin
|
||||||
|
git checkout vscode-extension
|
||||||
|
cd vscode-extension
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
回到语言本体:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout main
|
||||||
|
```
|
||||||
|
|
||||||
|
可选:`git worktree add ../marqdo-vscode vscode-extension`,语言与扩展并行目录开发。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. 目标(对齐 v0.1.0 分发)
|
||||||
|
|
||||||
|
v0.1.0 已是「可解释 + view + debug CLI + catalog」的阶段性稳定小版本。扩展的第一阶段目标是 **编辑体验**,而不是一次做满 IDE:
|
||||||
|
|
||||||
|
| 优先级 | 能力 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| **P0** | `.mq.md` 语言登记 + 基础语法高亮 | TextMate(已落地) |
|
||||||
|
| **P0** | 语言配置 | 括号 / 自动成对(已落地) |
|
||||||
|
| **P1** | 任务 / 命令 | `Marqdo: Run File` → `marqdo run`(已落地) |
|
||||||
|
| **P1** | 问题面板 | CLI `path:line:col` → Problems(已落地) |
|
||||||
|
| **P2** | 轻量语言特性 | 大纲(`#` 函数)、跳转到定义(同文件 / 导入) |
|
||||||
|
| **P3** | DAP / 调试 | 现已:`Marqdo: Open Debugger` 拉起 CLI debug 页;日后 DAP |
|
||||||
|
| **P3** | OKF / catalog | `Marqdo: Generate Catalog`(已落地轻量入口) |
|
||||||
|
|
||||||
|
原则:**扩展是 Marqdo CLI 的薄宿主**;语义以解释器与 [markdown-mapping.md](../doc/design/markdown-mapping.md) 为准,扩展不发明第二套语法。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. 目录约定(本分支)
|
||||||
|
|
||||||
|
```
|
||||||
|
vscode-extension/
|
||||||
|
README.md # 本文件:分支模型与目标
|
||||||
|
DEVELOPMENT.md # 日常开发流程、脚本、验收
|
||||||
|
ARCHITECTURE.md # 进程边界、与 CLI 的契约
|
||||||
|
package.json # 扩展清单(Marketplace id 待定)
|
||||||
|
tsconfig.json
|
||||||
|
.vscode/ # F5:Run Extension
|
||||||
|
.vscodeignore
|
||||||
|
src/
|
||||||
|
extension.ts # activate:命令 / 诊断
|
||||||
|
cli.ts # spawn marqdo
|
||||||
|
diagnostics.ts # path:line:col → Problems
|
||||||
|
syntaxes/ # TextMate 语法(P0)
|
||||||
|
marqdo.tmLanguage.json
|
||||||
|
language-configuration.json
|
||||||
|
```
|
||||||
|
|
||||||
|
生成物(`out/`、`node_modules/`、`*.vsix`)不入库;见本目录 `.gitignore`。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. 命名与发布(待拍板)
|
||||||
|
|
||||||
|
| 项 | 建议(可改) |
|
||||||
|
|----|--------------|
|
||||||
|
| 扩展显示名 | Marqdo |
|
||||||
|
| `publisher` | `cflmy`(或组织账号) |
|
||||||
|
| `name`(包名) | `marqdo` |
|
||||||
|
| 语言 id | `marqdo` |
|
||||||
|
| 文件关联 | `*.mq.md` |
|
||||||
|
|
||||||
|
发布渠道:先私有 / Open VSX,再 VS Marketplace。版本号与语言仓 **不必锁死同一 semver**,但发行说明应写明「需要 Marqdo CLI ≥ 0.1.0」。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. 文档索引(语言仓 `main`)
|
||||||
|
|
||||||
|
在 `main` 上仅保留指针,避免扩展实现泄漏进语言历史:
|
||||||
|
|
||||||
|
- [doc/design/vscode-extension.md](https://github.com/cflmy/marqdo/blob/main/doc/design/vscode-extension.md)(`main` 上的分支说明)
|
||||||
|
- 语法:[markdown-mapping.md](https://github.com/cflmy/marqdo/blob/main/doc/design/markdown-mapping.md)
|
||||||
|
- 诊断:[pipeline-debug.md](https://github.com/cflmy/marqdo/blob/main/doc/design/pipeline-debug.md)
|
||||||
|
- CLI debug:[view-debug.md](https://github.com/cflmy/marqdo/blob/main/doc/design/view-debug.md)
|
||||||
|
- Catalog / OKF:[catalog-cli.md](https://github.com/cflmy/marqdo/blob/main/doc/design/catalog-cli.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. 一句话
|
||||||
|
|
||||||
|
**语言在 `main`;编辑器宿主在 `vscode-extension` 分支。先高亮与 run/诊断,再 LSP/DAP;始终以 CLI 为真相源。**
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"comments": {
|
||||||
|
"lineComment": null,
|
||||||
|
"blockComment": null
|
||||||
|
},
|
||||||
|
"brackets": [
|
||||||
|
["{", "}"],
|
||||||
|
["[", "]"],
|
||||||
|
["(", ")"]
|
||||||
|
],
|
||||||
|
"autoClosingPairs": [
|
||||||
|
{ "open": "{", "close": "}" },
|
||||||
|
{ "open": "[", "close": "]" },
|
||||||
|
{ "open": "(", "close": ")" },
|
||||||
|
{ "open": "`", "close": "`" },
|
||||||
|
{ "open": "*", "close": "*" }
|
||||||
|
],
|
||||||
|
"surroundingPairs": [
|
||||||
|
["{", "}"],
|
||||||
|
["[", "]"],
|
||||||
|
["(", ")"],
|
||||||
|
["`", "`"],
|
||||||
|
["*", "*"]
|
||||||
|
],
|
||||||
|
"onEnterRules": [
|
||||||
|
{
|
||||||
|
"beforeText": "^\\s*>\\s+\\S+.*$",
|
||||||
|
"action": { "indent": "indent" }
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 262 B |
Generated
+3853
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,262 @@
|
|||||||
|
{
|
||||||
|
"name": "marqdo",
|
||||||
|
"displayName": "Marqdo",
|
||||||
|
"description": "Language support for Marqdo (.mq.md) — code as documentation.",
|
||||||
|
"version": "2.8.0",
|
||||||
|
"publisher": "cflmy",
|
||||||
|
"icon": "media/icon.png",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/cflmy/marqdo.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/cflmy/marqdo/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/cflmy/marqdo/tree/main/vscode-extension",
|
||||||
|
"engines": {
|
||||||
|
"vscode": "^1.85.0"
|
||||||
|
},
|
||||||
|
"categories": [
|
||||||
|
"Programming Languages"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"marqdo",
|
||||||
|
"markdown",
|
||||||
|
"mq.md"
|
||||||
|
],
|
||||||
|
"activationEvents": [
|
||||||
|
"onLanguage:marqdo",
|
||||||
|
"onStartupFinished"
|
||||||
|
],
|
||||||
|
"main": "./out/extension.js",
|
||||||
|
"contributes": {
|
||||||
|
"languages": [
|
||||||
|
{
|
||||||
|
"id": "marqdo",
|
||||||
|
"aliases": [
|
||||||
|
"Marqdo",
|
||||||
|
"marqdo"
|
||||||
|
],
|
||||||
|
"extensions": [
|
||||||
|
".mq.md"
|
||||||
|
],
|
||||||
|
"filenamePatterns": [
|
||||||
|
"*.mq.md"
|
||||||
|
],
|
||||||
|
"configuration": "./language-configuration.json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"grammars": [
|
||||||
|
{
|
||||||
|
"language": "marqdo",
|
||||||
|
"scopeName": "source.marqdo",
|
||||||
|
"path": "./syntaxes/marqdo.tmLanguage.json"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"commands": [
|
||||||
|
{
|
||||||
|
"command": "marqdo.run",
|
||||||
|
"title": "Run File",
|
||||||
|
"shortTitle": "Run",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(play)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.view",
|
||||||
|
"title": "Open View",
|
||||||
|
"shortTitle": "View",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(open-preview)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.debug",
|
||||||
|
"title": "Open Debugger",
|
||||||
|
"shortTitle": "Debug",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(debug-alt)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.view.stop",
|
||||||
|
"title": "Stop View",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(close)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.debug.stop",
|
||||||
|
"title": "Stop Debugger",
|
||||||
|
"shortTitle": "Stop Debug",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(debug-stop)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.catalog",
|
||||||
|
"title": "Generate Catalog",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(book)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.showOutput",
|
||||||
|
"title": "Show Output",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(output)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.installCli",
|
||||||
|
"title": "Install / Repair CLI",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(cloud-download)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.checkCli",
|
||||||
|
"title": "Check CLI Status",
|
||||||
|
"category": "Marqdo",
|
||||||
|
"icon": "$(info)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"menus": {
|
||||||
|
"editor/title": [
|
||||||
|
{
|
||||||
|
"command": "marqdo.run",
|
||||||
|
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
|
||||||
|
"group": "navigation@90"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.view",
|
||||||
|
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
|
||||||
|
"group": "navigation@91"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.debug",
|
||||||
|
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/",
|
||||||
|
"group": "navigation@92"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"commandPalette": [
|
||||||
|
{
|
||||||
|
"command": "marqdo.run",
|
||||||
|
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.view",
|
||||||
|
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "marqdo.debug",
|
||||||
|
"when": "editorLangId == marqdo || resourceFilename =~ /\\.mq\\.md$/"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"keybindings": [
|
||||||
|
{
|
||||||
|
"command": "marqdo.run",
|
||||||
|
"key": "ctrl+shift+r",
|
||||||
|
"mac": "cmd+shift+r",
|
||||||
|
"when": "editorTextFocus && editorLangId == marqdo"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"configuration": {
|
||||||
|
"title": "Marqdo",
|
||||||
|
"properties": {
|
||||||
|
"marqdo.cliPath": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "marqdo",
|
||||||
|
"description": "Path to the marqdo CLI executable (default: marqdo on PATH, or extension-managed install)."
|
||||||
|
},
|
||||||
|
"marqdo.managedCliPath": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
"description": "Path written by Marqdo: Install / Repair CLI (managed binary)."
|
||||||
|
},
|
||||||
|
"marqdo.libPath": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "",
|
||||||
|
"description": "Standard library root (sets MARQDO_LIB when spawning the CLI)."
|
||||||
|
},
|
||||||
|
"marqdo.autoInstall.checkOnStartup": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "On startup, detect missing/outdated CLI or missing stdlib and offer install from GitHub Releases."
|
||||||
|
},
|
||||||
|
"marqdo.minCliVersion": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "0.1.2",
|
||||||
|
"description": "Minimum required Marqdo CLI version (semver). Older installs trigger an upgrade prompt."
|
||||||
|
},
|
||||||
|
"marqdo.autoInstall.checkUpdates": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true,
|
||||||
|
"description": "Periodically check GitHub Releases for newer CLI / extension versions."
|
||||||
|
},
|
||||||
|
"marqdo.diagnoseOnSave": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Run `marqdo run` on save to refresh Problems (may hang on interactive input)."
|
||||||
|
},
|
||||||
|
"marqdo.runTimeoutMs": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 60000,
|
||||||
|
"description": "Timeout for `marqdo run` / diagnose (milliseconds)."
|
||||||
|
},
|
||||||
|
"marqdo.viewHost": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "127.0.0.1",
|
||||||
|
"description": "Host for `marqdo view`."
|
||||||
|
},
|
||||||
|
"marqdo.viewPort": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 7429,
|
||||||
|
"description": "Port for `marqdo view`."
|
||||||
|
},
|
||||||
|
"marqdo.viewOpen": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"external",
|
||||||
|
"simpleBrowser"
|
||||||
|
],
|
||||||
|
"default": "external",
|
||||||
|
"description": "How to open the view UI after starting the server."
|
||||||
|
},
|
||||||
|
"marqdo.debugHost": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "127.0.0.1",
|
||||||
|
"description": "Host for `marqdo debug`."
|
||||||
|
},
|
||||||
|
"marqdo.debugPort": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 7430,
|
||||||
|
"description": "Port for `marqdo debug`."
|
||||||
|
},
|
||||||
|
"marqdo.debugOpen": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"external",
|
||||||
|
"simpleBrowser"
|
||||||
|
],
|
||||||
|
"default": "external",
|
||||||
|
"description": "How to open the debug UI after starting the server."
|
||||||
|
},
|
||||||
|
"marqdo.catalogOut": {
|
||||||
|
"type": "string",
|
||||||
|
"default": ".marqdo",
|
||||||
|
"description": "Output directory for `marqdo catalog`."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"configurationDefaults": {
|
||||||
|
"files.associations": {
|
||||||
|
"*.mq.md": "marqdo"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"vscode:prepublish": "npm run compile",
|
||||||
|
"compile": "tsc -p ./",
|
||||||
|
"watch": "tsc -watch -p ./"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^20.11.0",
|
||||||
|
"@types/vscode": "^1.85.0",
|
||||||
|
"@vscode/vsce": "^3.9.2",
|
||||||
|
"typescript": "^5.3.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,193 @@
|
|||||||
|
import * as vscode from "vscode";
|
||||||
|
import { spawn, spawnSync, type ChildProcessWithoutNullStreams } from "child_process";
|
||||||
|
import type { ExtensionContext } from "vscode";
|
||||||
|
|
||||||
|
export interface CliResult {
|
||||||
|
code: number | null;
|
||||||
|
stdout: string;
|
||||||
|
stderr: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let resolveCli: (() => string) | undefined;
|
||||||
|
let resolveLib: (() => string | undefined) | undefined;
|
||||||
|
|
||||||
|
/** Wire install-aware path resolution from extension activate. */
|
||||||
|
export function configureCliResolution(
|
||||||
|
_context: ExtensionContext,
|
||||||
|
cli: () => string,
|
||||||
|
lib: () => string | undefined
|
||||||
|
): void {
|
||||||
|
resolveCli = cli;
|
||||||
|
resolveLib = lib;
|
||||||
|
}
|
||||||
|
|
||||||
|
function configuredPath(): string {
|
||||||
|
return (
|
||||||
|
vscode.workspace.getConfiguration("marqdo").get<string>("cliPath")?.trim() ||
|
||||||
|
"marqdo"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveMarqdoCli(): string {
|
||||||
|
if (resolveCli) {
|
||||||
|
return resolveCli();
|
||||||
|
}
|
||||||
|
return configuredPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
function spawnEnv(): NodeJS.ProcessEnv {
|
||||||
|
const env = { ...process.env };
|
||||||
|
const lib = resolveLib?.();
|
||||||
|
if (lib) {
|
||||||
|
env.MARQDO_LIB = lib;
|
||||||
|
}
|
||||||
|
return env;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function workspaceCwd(prefer?: vscode.Uri): string {
|
||||||
|
if (prefer) {
|
||||||
|
const folder = vscode.workspace.getWorkspaceFolder(prefer);
|
||||||
|
if (folder) {
|
||||||
|
return folder.uri.fsPath;
|
||||||
|
}
|
||||||
|
return vscode.Uri.joinPath(prefer, "..").fsPath;
|
||||||
|
}
|
||||||
|
return vscode.workspace.workspaceFolders?.[0]?.uri.fsPath ?? process.cwd();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function runMarqdo(
|
||||||
|
args: string[],
|
||||||
|
options: { cwd: string; timeoutMs?: number }
|
||||||
|
): Promise<CliResult> {
|
||||||
|
const cli = resolveMarqdoCli();
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const child = spawn(cli, args, {
|
||||||
|
cwd: options.cwd,
|
||||||
|
shell: process.platform === "win32",
|
||||||
|
env: spawnEnv(),
|
||||||
|
});
|
||||||
|
let stdout = "";
|
||||||
|
let stderr = "";
|
||||||
|
let settled = false;
|
||||||
|
const finish = (code: number | null) => {
|
||||||
|
if (settled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
settled = true;
|
||||||
|
resolve({ code, stdout, stderr });
|
||||||
|
};
|
||||||
|
const timer =
|
||||||
|
options.timeoutMs && options.timeoutMs > 0
|
||||||
|
? setTimeout(() => {
|
||||||
|
child.kill();
|
||||||
|
finish(null);
|
||||||
|
}, options.timeoutMs)
|
||||||
|
: undefined;
|
||||||
|
child.stdout.on("data", (d: Buffer) => {
|
||||||
|
stdout += d.toString();
|
||||||
|
});
|
||||||
|
child.stderr.on("data", (d: Buffer) => {
|
||||||
|
stderr += d.toString();
|
||||||
|
});
|
||||||
|
child.on("error", (err) => {
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
stderr += err.message;
|
||||||
|
finish(1);
|
||||||
|
});
|
||||||
|
child.on("close", (code) => {
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer);
|
||||||
|
}
|
||||||
|
finish(code);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function probeMarqdo(
|
||||||
|
cliOverride?: string
|
||||||
|
): { ok: boolean; version?: string; detail: string } {
|
||||||
|
const cli = cliOverride ?? resolveMarqdoCli();
|
||||||
|
try {
|
||||||
|
const r = spawnSync(cli, ["--version"], {
|
||||||
|
encoding: "utf8",
|
||||||
|
shell: process.platform === "win32",
|
||||||
|
timeout: 8000,
|
||||||
|
env: spawnEnv(),
|
||||||
|
});
|
||||||
|
const out = `${r.stdout ?? ""}${r.stderr ?? ""}`.trim();
|
||||||
|
if (r.error) {
|
||||||
|
return { ok: false, detail: r.error.message };
|
||||||
|
}
|
||||||
|
if (r.status !== 0) {
|
||||||
|
return { ok: false, detail: out || `exit ${r.status}` };
|
||||||
|
}
|
||||||
|
return { ok: true, version: out, detail: out };
|
||||||
|
} catch (e) {
|
||||||
|
return { ok: false, detail: e instanceof Error ? e.message : String(e) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class LiveServer {
|
||||||
|
private proc: ChildProcessWithoutNullStreams | null = null;
|
||||||
|
private output: vscode.OutputChannel;
|
||||||
|
private label: string;
|
||||||
|
|
||||||
|
constructor(output: vscode.OutputChannel, label: string) {
|
||||||
|
this.output = output;
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
get running(): boolean {
|
||||||
|
return this.proc !== null && this.proc.exitCode === null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async start(
|
||||||
|
subcommand: "view" | "debug",
|
||||||
|
targetPath: string,
|
||||||
|
host: string,
|
||||||
|
port: number
|
||||||
|
): Promise<string> {
|
||||||
|
if (this.running) {
|
||||||
|
await this.stop();
|
||||||
|
}
|
||||||
|
const cli = resolveMarqdoCli();
|
||||||
|
const cwd = workspaceCwd(vscode.Uri.file(targetPath));
|
||||||
|
this.output.appendLine(
|
||||||
|
`$ ${cli} ${subcommand} ${targetPath} --host ${host} --port ${port} --no-open`
|
||||||
|
);
|
||||||
|
this.proc = spawn(
|
||||||
|
cli,
|
||||||
|
[subcommand, targetPath, "--host", host, "--port", String(port), "--no-open"],
|
||||||
|
{
|
||||||
|
cwd,
|
||||||
|
shell: process.platform === "win32",
|
||||||
|
env: spawnEnv(),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const url = `http://${host}:${port}/`;
|
||||||
|
this.proc.stdout.on("data", (d: Buffer) => this.output.append(d.toString()));
|
||||||
|
this.proc.stderr.on("data", (d: Buffer) => this.output.append(d.toString()));
|
||||||
|
this.proc.on("exit", (code) => {
|
||||||
|
this.output.appendLine(`[${this.label}] exited (${code})`);
|
||||||
|
this.proc = null;
|
||||||
|
});
|
||||||
|
this.proc.on("error", (err) => {
|
||||||
|
this.output.appendLine(`[${this.label}] ${err.message}`);
|
||||||
|
this.proc = null;
|
||||||
|
});
|
||||||
|
await new Promise((r) => setTimeout(r, 600));
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
async stop(): Promise<void> {
|
||||||
|
if (!this.proc) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const p = this.proc;
|
||||||
|
this.proc = null;
|
||||||
|
p.kill();
|
||||||
|
await new Promise((r) => setTimeout(r, 200));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
import * as vscode from "vscode";
|
||||||
|
import * as path from "path";
|
||||||
|
|
||||||
|
export function parseDiagnostics(
|
||||||
|
text: string,
|
||||||
|
fallbackUri: vscode.Uri,
|
||||||
|
cwd: string
|
||||||
|
): vscode.Diagnostic[] {
|
||||||
|
const out: vscode.Diagnostic[] = [];
|
||||||
|
for (const raw of text.split(/\r?\n/)) {
|
||||||
|
const line = raw.trim();
|
||||||
|
if (!line) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const parsed = parseDiagLine(line);
|
||||||
|
if (!parsed) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out.push(
|
||||||
|
makeDiag(parsed.file, parsed.line, parsed.col, parsed.message, fallbackUri, cwd)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
function parseDiagLine(
|
||||||
|
line: string
|
||||||
|
): { file: string; line: number; col: number; message: string } | undefined {
|
||||||
|
// Windows: E:\path\to\file.mq.md:7:1: message
|
||||||
|
const win = /^([A-Za-z]:[\\/][^:]*):(\d+):(\d+):\s*(.+)$/.exec(line);
|
||||||
|
if (win) {
|
||||||
|
return {
|
||||||
|
file: win[1],
|
||||||
|
line: Number(win[2]),
|
||||||
|
col: Number(win[3]),
|
||||||
|
message: win[4],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Unix / relative: path/file.mq.md:7:1: message
|
||||||
|
const normal = /^(.+):(\d+):(\d+):\s*(.+)$/.exec(line);
|
||||||
|
if (normal) {
|
||||||
|
return {
|
||||||
|
file: normal[1],
|
||||||
|
line: Number(normal[2]),
|
||||||
|
col: Number(normal[3]),
|
||||||
|
message: normal[4],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const spanOnly = /^(\d+):(\d+):\s*(.+)$/.exec(line);
|
||||||
|
if (spanOnly) {
|
||||||
|
return {
|
||||||
|
file: "",
|
||||||
|
line: Number(spanOnly[1]),
|
||||||
|
col: Number(spanOnly[2]),
|
||||||
|
message: spanOnly[3],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function makeDiag(
|
||||||
|
filePath: string,
|
||||||
|
line1: number,
|
||||||
|
col1: number,
|
||||||
|
message: string,
|
||||||
|
fallbackUri: vscode.Uri,
|
||||||
|
cwd: string
|
||||||
|
): vscode.Diagnostic {
|
||||||
|
const line = Math.max(0, line1 - 1);
|
||||||
|
const col = Math.max(0, col1 - 1);
|
||||||
|
const range = new vscode.Range(line, col, line, Math.max(col + 1, col));
|
||||||
|
const diag = new vscode.Diagnostic(range, message, vscode.DiagnosticSeverity.Error);
|
||||||
|
diag.source = "marqdo";
|
||||||
|
(diag as vscode.Diagnostic & { targetPath?: string }).targetPath = resolvePath(
|
||||||
|
filePath,
|
||||||
|
fallbackUri,
|
||||||
|
cwd
|
||||||
|
);
|
||||||
|
return diag;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolvePath(filePath: string, fallbackUri: vscode.Uri, cwd: string): string {
|
||||||
|
if (!filePath) {
|
||||||
|
return fallbackUri.fsPath;
|
||||||
|
}
|
||||||
|
if (path.isAbsolute(filePath)) {
|
||||||
|
return filePath;
|
||||||
|
}
|
||||||
|
return path.resolve(cwd, filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
export class DiagnosticBag {
|
||||||
|
private readonly collection: vscode.DiagnosticCollection;
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.collection = vscode.languages.createDiagnosticCollection("marqdo");
|
||||||
|
}
|
||||||
|
|
||||||
|
get disposable(): vscode.Disposable {
|
||||||
|
return this.collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
clear(uri?: vscode.Uri): void {
|
||||||
|
if (uri) {
|
||||||
|
this.collection.delete(uri);
|
||||||
|
} else {
|
||||||
|
this.collection.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setFromCli(text: string, fallbackUri: vscode.Uri, cwd: string): void {
|
||||||
|
const parsed = parseDiagnostics(text, fallbackUri, cwd);
|
||||||
|
const byFile = new Map<string, vscode.Diagnostic[]>();
|
||||||
|
for (const d of parsed) {
|
||||||
|
const target =
|
||||||
|
(d as vscode.Diagnostic & { targetPath?: string }).targetPath ?? fallbackUri.fsPath;
|
||||||
|
const list = byFile.get(target) ?? [];
|
||||||
|
list.push(d);
|
||||||
|
byFile.set(target, list);
|
||||||
|
}
|
||||||
|
if (byFile.size === 0) {
|
||||||
|
const trimmed = text.trim();
|
||||||
|
if (trimmed) {
|
||||||
|
const range = new vscode.Range(0, 0, 0, 1);
|
||||||
|
this.collection.set(fallbackUri, [
|
||||||
|
new vscode.Diagnostic(
|
||||||
|
range,
|
||||||
|
trimmed.split(/\r?\n/)[0],
|
||||||
|
vscode.DiagnosticSeverity.Error
|
||||||
|
),
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
this.collection.delete(fallbackUri);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (const [file, diags] of byFile) {
|
||||||
|
this.collection.set(vscode.Uri.file(file), diags);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,307 @@
|
|||||||
|
import * as vscode from "vscode";
|
||||||
|
import { LiveServer, configureCliResolution, runMarqdo, workspaceCwd } from "./cli";
|
||||||
|
import { DiagnosticBag } from "./diagnostics";
|
||||||
|
import {
|
||||||
|
checkInstallStatus,
|
||||||
|
installFromGitHub,
|
||||||
|
promptIfNeeded,
|
||||||
|
resetSkipPrompt,
|
||||||
|
resolveCliPath,
|
||||||
|
resolveLibEnv,
|
||||||
|
} from "./install";
|
||||||
|
import { checkForUpdates } from "./updateCheck";
|
||||||
|
|
||||||
|
let output: vscode.OutputChannel;
|
||||||
|
let diagnostics: DiagnosticBag;
|
||||||
|
let viewServer: LiveServer;
|
||||||
|
let debugServer: LiveServer;
|
||||||
|
let extContext: vscode.ExtensionContext;
|
||||||
|
|
||||||
|
export function activate(context: vscode.ExtensionContext): void {
|
||||||
|
extContext = context;
|
||||||
|
output = vscode.window.createOutputChannel("Marqdo");
|
||||||
|
diagnostics = new DiagnosticBag();
|
||||||
|
viewServer = new LiveServer(output, "view");
|
||||||
|
debugServer = new LiveServer(output, "debug");
|
||||||
|
|
||||||
|
configureCliResolution(
|
||||||
|
context,
|
||||||
|
() => resolveCliPath(context),
|
||||||
|
() => resolveLibEnv(context)
|
||||||
|
);
|
||||||
|
|
||||||
|
context.subscriptions.push(
|
||||||
|
output,
|
||||||
|
diagnostics.disposable,
|
||||||
|
vscode.commands.registerCommand("marqdo.run", () => runActiveFile()),
|
||||||
|
vscode.commands.registerCommand("marqdo.view", () => startView()),
|
||||||
|
vscode.commands.registerCommand("marqdo.debug", () => startDebug()),
|
||||||
|
vscode.commands.registerCommand("marqdo.debug.stop", () => stopDebug()),
|
||||||
|
vscode.commands.registerCommand("marqdo.view.stop", () => stopView()),
|
||||||
|
vscode.commands.registerCommand("marqdo.catalog", () => runCatalog()),
|
||||||
|
vscode.commands.registerCommand("marqdo.showOutput", () => output.show(true)),
|
||||||
|
vscode.commands.registerCommand("marqdo.installCli", () => installCli()),
|
||||||
|
vscode.commands.registerCommand("marqdo.checkCli", () => checkCli())
|
||||||
|
);
|
||||||
|
|
||||||
|
context.subscriptions.push(
|
||||||
|
vscode.workspace.onDidSaveTextDocument((doc) => {
|
||||||
|
if (doc.languageId === "marqdo" && autoDiagnose()) {
|
||||||
|
void diagnoseDocument(doc);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
void (async () => {
|
||||||
|
await promptIfNeeded(context, output);
|
||||||
|
const status = checkInstallStatus(context);
|
||||||
|
await checkForUpdates(context, output, status.version);
|
||||||
|
})();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function deactivate(): void {
|
||||||
|
void viewServer?.stop();
|
||||||
|
void debugServer?.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
function autoDiagnose(): boolean {
|
||||||
|
return vscode.workspace.getConfiguration("marqdo").get<boolean>("diagnoseOnSave") ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function installCli(): Promise<void> {
|
||||||
|
await resetSkipPrompt(extContext);
|
||||||
|
const status = checkInstallStatus(extContext);
|
||||||
|
try {
|
||||||
|
const mode = status.suggestedMode ?? "bundle";
|
||||||
|
await installFromGitHub(extContext, output, mode);
|
||||||
|
} catch (e) {
|
||||||
|
const err = e instanceof Error ? e.message : String(e);
|
||||||
|
output.appendLine(`[install] ${err}`);
|
||||||
|
const open = await vscode.window.showErrorMessage(`Marqdo install failed: ${err}`, "Open Releases");
|
||||||
|
if (open) {
|
||||||
|
await vscode.env.openExternal(vscode.Uri.parse("https://github.com/cflmy/marqdo/releases"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkCli(): Promise<void> {
|
||||||
|
const status = checkInstallStatus(extContext);
|
||||||
|
output.appendLine(`[check] ${status.detail}`);
|
||||||
|
if (status.cliOk && status.versionOk && status.libOk) {
|
||||||
|
void vscode.window.showInformationMessage(
|
||||||
|
`Marqdo ready: ${status.parsedVersion ?? status.version} (≥ ${status.requiredVersion}), stdlib OK`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const choice = await vscode.window.showWarningMessage(
|
||||||
|
status.detail,
|
||||||
|
"Install / Repair",
|
||||||
|
"Open Releases"
|
||||||
|
);
|
||||||
|
if (choice === "Install / Repair") {
|
||||||
|
await installCli();
|
||||||
|
} else if (choice === "Open Releases") {
|
||||||
|
await vscode.env.openExternal(vscode.Uri.parse("https://github.com/cflmy/marqdo/releases"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function activeMqDoc(): vscode.TextDocument | undefined {
|
||||||
|
const doc = vscode.window.activeTextEditor?.document;
|
||||||
|
if (!doc) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
if (doc.languageId === "marqdo" || doc.fileName.endsWith(".mq.md")) {
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function ensureCliOrOfferInstall(): Promise<boolean> {
|
||||||
|
const status = checkInstallStatus(extContext);
|
||||||
|
if (status.cliOk && status.versionOk && status.libOk) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (status.cliOk && status.versionOk && !status.libOk) {
|
||||||
|
const choice = await vscode.window.showWarningMessage(
|
||||||
|
"Standard library (lib/) is missing. Continue anyway, or install stdlib?",
|
||||||
|
"Install stdlib",
|
||||||
|
"Continue",
|
||||||
|
"Cancel"
|
||||||
|
);
|
||||||
|
if (choice === "Install stdlib") {
|
||||||
|
await installCli();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (choice === "Continue") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const label = !status.cliOk
|
||||||
|
? "Marqdo CLI not found. Install the official release (includes stdlib)?"
|
||||||
|
: `Marqdo CLI is below ${status.requiredVersion}. Upgrade now?`;
|
||||||
|
const choice = await vscode.window.showWarningMessage(label, "Install", "Cancel");
|
||||||
|
if (choice === "Install") {
|
||||||
|
await installCli();
|
||||||
|
const again = checkInstallStatus(extContext);
|
||||||
|
return again.cliOk && again.versionOk;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveTargetPath(): string | undefined {
|
||||||
|
const doc = activeMqDoc();
|
||||||
|
const folder = vscode.workspace.workspaceFolders?.[0];
|
||||||
|
return doc?.uri.fsPath ?? folder?.uri.fsPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function openUrl(url: string, settingKey: "viewOpen" | "debugOpen"): Promise<void> {
|
||||||
|
const open =
|
||||||
|
vscode.workspace.getConfiguration("marqdo").get<string>(settingKey) ?? "external";
|
||||||
|
if (open === "simpleBrowser") {
|
||||||
|
await vscode.commands.executeCommand("simpleBrowser.show", url);
|
||||||
|
} else {
|
||||||
|
await vscode.env.openExternal(vscode.Uri.parse(url));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runActiveFile(): Promise<void> {
|
||||||
|
if (!(await ensureCliOrOfferInstall())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const doc = activeMqDoc();
|
||||||
|
if (!doc) {
|
||||||
|
void vscode.window.showWarningMessage("Open a .mq.md file to run.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (doc.isDirty) {
|
||||||
|
await doc.save();
|
||||||
|
}
|
||||||
|
const cwd = workspaceCwd(doc.uri);
|
||||||
|
output.show(true);
|
||||||
|
output.appendLine(`$ marqdo run ${doc.uri.fsPath}`);
|
||||||
|
const result = await runMarqdo(["run", doc.uri.fsPath], {
|
||||||
|
cwd,
|
||||||
|
timeoutMs: vscode.workspace.getConfiguration("marqdo").get<number>("runTimeoutMs") ?? 60000,
|
||||||
|
});
|
||||||
|
if (result.stdout.trim()) {
|
||||||
|
output.appendLine(result.stdout.trimEnd());
|
||||||
|
}
|
||||||
|
if (result.stderr.trim()) {
|
||||||
|
output.appendLine(result.stderr.trimEnd());
|
||||||
|
}
|
||||||
|
if (result.code === 0) {
|
||||||
|
diagnostics.clear(doc.uri);
|
||||||
|
void vscode.window.setStatusBarMessage("Marqdo: run ok", 3000);
|
||||||
|
} else {
|
||||||
|
diagnostics.setFromCli(result.stderr || result.stdout, doc.uri, cwd);
|
||||||
|
void vscode.window.showErrorMessage("Marqdo: run failed (see Problems / Output)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function diagnoseDocument(doc: vscode.TextDocument): Promise<void> {
|
||||||
|
const cwd = workspaceCwd(doc.uri);
|
||||||
|
const result = await runMarqdo(["run", doc.uri.fsPath], {
|
||||||
|
cwd,
|
||||||
|
timeoutMs: vscode.workspace.getConfiguration("marqdo").get<number>("runTimeoutMs") ?? 60000,
|
||||||
|
});
|
||||||
|
if (result.code === 0) {
|
||||||
|
diagnostics.clear(doc.uri);
|
||||||
|
} else {
|
||||||
|
diagnostics.setFromCli(result.stderr || result.stdout, doc.uri, cwd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function startView(): Promise<void> {
|
||||||
|
if (!(await ensureCliOrOfferInstall())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const target = resolveTargetPath();
|
||||||
|
if (!target) {
|
||||||
|
void vscode.window.showWarningMessage("Open a folder or .mq.md file for view.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const cfg = vscode.workspace.getConfiguration("marqdo");
|
||||||
|
const host = cfg.get<string>("viewHost") ?? "127.0.0.1";
|
||||||
|
const port = cfg.get<number>("viewPort") ?? 7429;
|
||||||
|
output.show(true);
|
||||||
|
try {
|
||||||
|
const url = await viewServer.start("view", target, host, port);
|
||||||
|
await openUrl(url, "viewOpen");
|
||||||
|
void vscode.window.setStatusBarMessage(`Marqdo view: ${url}`, 5000);
|
||||||
|
} catch (e) {
|
||||||
|
void vscode.window.showErrorMessage(
|
||||||
|
`Marqdo view failed: ${e instanceof Error ? e.message : String(e)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function startDebug(): Promise<void> {
|
||||||
|
if (!(await ensureCliOrOfferInstall())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const target = resolveTargetPath();
|
||||||
|
if (!target) {
|
||||||
|
void vscode.window.showWarningMessage("Open a folder or .mq.md file to debug.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const cfg = vscode.workspace.getConfiguration("marqdo");
|
||||||
|
const host = cfg.get<string>("debugHost") ?? "127.0.0.1";
|
||||||
|
const port = cfg.get<number>("debugPort") ?? 7430;
|
||||||
|
output.show(true);
|
||||||
|
try {
|
||||||
|
const url = await debugServer.start("debug", target, host, port);
|
||||||
|
await openUrl(url, "debugOpen");
|
||||||
|
void vscode.window.setStatusBarMessage(`Marqdo debug: ${url}`, 5000);
|
||||||
|
} catch (e) {
|
||||||
|
void vscode.window.showErrorMessage(
|
||||||
|
`Marqdo debug failed: ${e instanceof Error ? e.message : String(e)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function stopView(): Promise<void> {
|
||||||
|
await viewServer.stop();
|
||||||
|
void vscode.window.setStatusBarMessage("Marqdo view stopped", 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function stopDebug(): Promise<void> {
|
||||||
|
await debugServer.stop();
|
||||||
|
void vscode.window.setStatusBarMessage("Marqdo debug stopped", 3000);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runCatalog(): Promise<void> {
|
||||||
|
if (!(await ensureCliOrOfferInstall())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const folder = vscode.workspace.workspaceFolders?.[0];
|
||||||
|
if (!folder) {
|
||||||
|
void vscode.window.showWarningMessage("Open a workspace folder for catalog.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const outDir =
|
||||||
|
vscode.workspace.getConfiguration("marqdo").get<string>("catalogOut") ?? ".marqdo";
|
||||||
|
output.show(true);
|
||||||
|
output.appendLine(`$ marqdo catalog ${folder.uri.fsPath} -o ${outDir}`);
|
||||||
|
const result = await runMarqdo(["catalog", folder.uri.fsPath, "-o", outDir], {
|
||||||
|
cwd: folder.uri.fsPath,
|
||||||
|
timeoutMs: 120000,
|
||||||
|
});
|
||||||
|
if (result.stdout.trim()) {
|
||||||
|
output.appendLine(result.stdout.trimEnd());
|
||||||
|
}
|
||||||
|
if (result.stderr.trim()) {
|
||||||
|
output.appendLine(result.stderr.trimEnd());
|
||||||
|
}
|
||||||
|
if (result.code === 0) {
|
||||||
|
const index = vscode.Uri.joinPath(folder.uri, outDir, "index.md");
|
||||||
|
try {
|
||||||
|
const doc = await vscode.workspace.openTextDocument(index);
|
||||||
|
await vscode.window.showTextDocument(doc, { preview: true });
|
||||||
|
} catch {
|
||||||
|
void vscode.window.showInformationMessage(`Marqdo catalog written to ${outDir}`);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
void vscode.window.showErrorMessage("Marqdo catalog failed (see Output)");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,499 @@
|
|||||||
|
import * as vscode from "vscode";
|
||||||
|
import * as fs from "fs";
|
||||||
|
import * as path from "path";
|
||||||
|
import * as os from "os";
|
||||||
|
import { spawnSync } from "child_process";
|
||||||
|
import { probeMarqdo } from "./cli";
|
||||||
|
|
||||||
|
const REPO = "cflmy/marqdo";
|
||||||
|
const SKIP_KEY = "marqdo.skipInstallPrompt";
|
||||||
|
const MANAGED_DIR = "cli";
|
||||||
|
/** CLI builds from this version ship stdlib inside the binary. */
|
||||||
|
export const EMBEDDED_STDLIB_SINCE = "0.1.2";
|
||||||
|
|
||||||
|
export type InstallStatus = {
|
||||||
|
cliOk: boolean;
|
||||||
|
libOk: boolean;
|
||||||
|
versionOk: boolean;
|
||||||
|
version?: string;
|
||||||
|
parsedVersion?: string;
|
||||||
|
requiredVersion: string;
|
||||||
|
cliPath?: string;
|
||||||
|
libRoot?: string;
|
||||||
|
detail: string;
|
||||||
|
/** Suggested install mode when not fully ready */
|
||||||
|
suggestedMode?: "bundle" | "stdlib";
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Parse first semver-like token from `marqdo --version` output. */
|
||||||
|
export function parseCliVersion(raw: string): string | undefined {
|
||||||
|
const m = raw.match(/(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)/);
|
||||||
|
return m?.[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Compare a.b.c semver (pre-release suffix ignored for ordering). Returns <0 if a<b. */
|
||||||
|
export function compareSemver(a: string, b: string): number {
|
||||||
|
const pa = a.split("-")[0].split(".").map((x) => Number.parseInt(x, 10) || 0);
|
||||||
|
const pb = b.split("-")[0].split(".").map((x) => Number.parseInt(x, 10) || 0);
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
const d = (pa[i] ?? 0) - (pb[i] ?? 0);
|
||||||
|
if (d !== 0) {
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
function requiredVersion(): string {
|
||||||
|
return cfg().get<string>("minCliVersion")?.trim() || "0.1.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
type GhAsset = { name: string; browser_download_url: string };
|
||||||
|
type GhRelease = {
|
||||||
|
tag_name: string;
|
||||||
|
html_url: string;
|
||||||
|
assets: GhAsset[];
|
||||||
|
};
|
||||||
|
|
||||||
|
function cfg() {
|
||||||
|
return vscode.workspace.getConfiguration("marqdo");
|
||||||
|
}
|
||||||
|
|
||||||
|
export function managedRoot(context: vscode.ExtensionContext): string {
|
||||||
|
return path.join(context.globalStorageUri.fsPath, MANAGED_DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function managedExePath(context: vscode.ExtensionContext): string {
|
||||||
|
const name = process.platform === "win32" ? "marqdo.exe" : "marqdo";
|
||||||
|
return path.join(managedRoot(context), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function managedLibRoot(context: vscode.ExtensionContext): string {
|
||||||
|
// Release zip layout: marqdo.exe + lib/… → MARQDO_LIB can be the dir that contains lib/, or lib itself.
|
||||||
|
// load.rs: root.join(remainder) and root.join("lib").join(remainder)
|
||||||
|
return managedRoot(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Prefer explicit setting, then managed install, then PATH. */
|
||||||
|
export function resolveCliPath(context?: vscode.ExtensionContext): string {
|
||||||
|
const setting = cfg().get<string>("cliPath")?.trim() || "marqdo";
|
||||||
|
if (setting !== "marqdo") {
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
if (context) {
|
||||||
|
const managed = managedExePath(context);
|
||||||
|
if (fs.existsSync(managed)) {
|
||||||
|
return managed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const stored = cfg().get<string>("managedCliPath")?.trim();
|
||||||
|
if (stored && fs.existsSync(stored)) {
|
||||||
|
return stored;
|
||||||
|
}
|
||||||
|
return "marqdo";
|
||||||
|
}
|
||||||
|
|
||||||
|
export function resolveLibEnv(context?: vscode.ExtensionContext): string | undefined {
|
||||||
|
const setting = cfg().get<string>("libPath")?.trim();
|
||||||
|
if (setting) {
|
||||||
|
return setting;
|
||||||
|
}
|
||||||
|
if (context) {
|
||||||
|
const root = managedLibRoot(context);
|
||||||
|
if (fs.existsSync(path.join(root, "lib")) || looksLikeLibRoot(root)) {
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function looksLikeLibRoot(root: string): boolean {
|
||||||
|
return (
|
||||||
|
fs.existsSync(path.join(root, "math.mq.md")) ||
|
||||||
|
fs.existsSync(path.join(root, "text.mq.md")) ||
|
||||||
|
fs.existsSync(path.join(root, "lib", "math.mq.md"))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function findExeDir(cliPath: string): string | undefined {
|
||||||
|
if (cliPath.includes(path.sep) || cliPath.includes("/") || /\.exe$/i.test(cliPath)) {
|
||||||
|
if (fs.existsSync(cliPath)) {
|
||||||
|
return path.dirname(cliPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Resolve via where/which
|
||||||
|
const cmd = process.platform === "win32" ? "where" : "which";
|
||||||
|
const r = spawnSync(cmd, [cliPath === "marqdo" && process.platform === "win32" ? "marqdo.exe" : cliPath], {
|
||||||
|
encoding: "utf8",
|
||||||
|
shell: true,
|
||||||
|
});
|
||||||
|
const first = (r.stdout || "")
|
||||||
|
.split(/\r?\n/)
|
||||||
|
.map((s) => s.trim())
|
||||||
|
.find((s) => s.length > 0);
|
||||||
|
if (first && fs.existsSync(first)) {
|
||||||
|
return path.dirname(first);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stdlibPresent(cliPath: string, context?: vscode.ExtensionContext): { ok: boolean; root?: string } {
|
||||||
|
const envLib = process.env.MARQDO_LIB;
|
||||||
|
if (envLib && looksLikeLibRoot(envLib)) {
|
||||||
|
return { ok: true, root: envLib };
|
||||||
|
}
|
||||||
|
const configured = resolveLibEnv(context);
|
||||||
|
if (configured && looksLikeLibRoot(configured)) {
|
||||||
|
return { ok: true, root: configured };
|
||||||
|
}
|
||||||
|
const dir = findExeDir(cliPath);
|
||||||
|
if (dir) {
|
||||||
|
if (looksLikeLibRoot(dir) || looksLikeLibRoot(path.join(dir, "lib"))) {
|
||||||
|
return { ok: true, root: dir };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Workspace ./lib
|
||||||
|
const ws = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath;
|
||||||
|
if (ws && looksLikeLibRoot(path.join(ws, "lib"))) {
|
||||||
|
return { ok: true, root: path.join(ws, "lib") };
|
||||||
|
}
|
||||||
|
return { ok: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkInstallStatus(context: vscode.ExtensionContext): InstallStatus {
|
||||||
|
const need = requiredVersion();
|
||||||
|
const cliPath = resolveCliPath(context);
|
||||||
|
const probe = probeMarqdo(cliPath);
|
||||||
|
if (!probe.ok) {
|
||||||
|
return {
|
||||||
|
cliOk: false,
|
||||||
|
libOk: false,
|
||||||
|
versionOk: false,
|
||||||
|
requiredVersion: need,
|
||||||
|
cliPath,
|
||||||
|
detail: `Marqdo CLI not found (${probe.detail}). Need ≥ ${need} with stdlib.`,
|
||||||
|
suggestedMode: "bundle",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const parsed = parseCliVersion(probe.version ?? "");
|
||||||
|
const versionOk = parsed !== undefined && compareSemver(parsed, need) >= 0;
|
||||||
|
let lib = stdlibPresent(cliPath, context);
|
||||||
|
if (
|
||||||
|
parsed &&
|
||||||
|
compareSemver(parsed, EMBEDDED_STDLIB_SINCE) >= 0 &&
|
||||||
|
!lib.ok
|
||||||
|
) {
|
||||||
|
lib = { ok: true, root: "(embedded in binary)" };
|
||||||
|
}
|
||||||
|
|
||||||
|
let suggestedMode: "bundle" | "stdlib" | undefined;
|
||||||
|
if (!versionOk) {
|
||||||
|
suggestedMode = "bundle";
|
||||||
|
} else if (!lib.ok) {
|
||||||
|
suggestedMode = "stdlib";
|
||||||
|
}
|
||||||
|
|
||||||
|
const parts: string[] = [`CLI ${probe.version}`];
|
||||||
|
if (!versionOk) {
|
||||||
|
parts.push(`version too old (need ≥ ${need}${parsed ? `, found ${parsed}` : ""})`);
|
||||||
|
}
|
||||||
|
if (lib.ok) {
|
||||||
|
parts.push(`stdlib at ${lib.root}`);
|
||||||
|
} else {
|
||||||
|
parts.push("stdlib missing (no lib/ next to binary / MARQDO_LIB)");
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
cliOk: true,
|
||||||
|
libOk: lib.ok,
|
||||||
|
versionOk,
|
||||||
|
version: probe.version,
|
||||||
|
parsedVersion: parsed,
|
||||||
|
requiredVersion: need,
|
||||||
|
cliPath,
|
||||||
|
libRoot: lib.root,
|
||||||
|
detail: parts.join("; "),
|
||||||
|
suggestedMode,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
function rustTargetTriple(): string | undefined {
|
||||||
|
const { platform, arch } = process;
|
||||||
|
if (platform === "win32" && arch === "x64") {
|
||||||
|
return "x86_64-pc-windows-msvc";
|
||||||
|
}
|
||||||
|
if (platform === "linux" && arch === "x64") {
|
||||||
|
return "x86_64-unknown-linux-gnu";
|
||||||
|
}
|
||||||
|
if (platform === "darwin" && arch === "arm64") {
|
||||||
|
return "aarch64-apple-darwin";
|
||||||
|
}
|
||||||
|
if (platform === "darwin" && arch === "x64") {
|
||||||
|
return "x86_64-apple-darwin";
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fetchLatestRelease(): Promise<GhRelease> {
|
||||||
|
const res = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/vnd.github+json",
|
||||||
|
"User-Agent": "marqdo-vscode-extension",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`GitHub releases/latest HTTP ${res.status}`);
|
||||||
|
}
|
||||||
|
return (await res.json()) as GhRelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downloadToFile(url: string, dest: string, onProgress?: (msg: string) => void): Promise<void> {
|
||||||
|
onProgress?.(`Downloading ${path.basename(dest)}…`);
|
||||||
|
const res = await fetch(url, {
|
||||||
|
headers: { "User-Agent": "marqdo-vscode-extension", Accept: "application/octet-stream" },
|
||||||
|
redirect: "follow",
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Download failed HTTP ${res.status}: ${url}`);
|
||||||
|
}
|
||||||
|
const buf = Buffer.from(await res.arrayBuffer());
|
||||||
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
||||||
|
fs.writeFileSync(dest, buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractZip(zipPath: string, destDir: string): void {
|
||||||
|
fs.mkdirSync(destDir, { recursive: true });
|
||||||
|
if (process.platform === "win32") {
|
||||||
|
const ps = `Expand-Archive -LiteralPath '${zipPath.replace(/'/g, "''")}' -DestinationPath '${destDir.replace(/'/g, "''")}' -Force`;
|
||||||
|
const r = spawnSync("powershell", ["-NoProfile", "-Command", ps], { encoding: "utf8" });
|
||||||
|
if (r.status !== 0) {
|
||||||
|
throw new Error(r.stderr || r.stdout || `Expand-Archive exit ${r.status}`);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const r = spawnSync("unzip", ["-o", zipPath, "-d", destDir], { encoding: "utf8" });
|
||||||
|
if (r.status !== 0) {
|
||||||
|
throw new Error(r.stderr || r.stdout || `unzip exit ${r.status}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickBundleAsset(release: GhRelease, triple: string): GhAsset | undefined {
|
||||||
|
const zipName = `marqdo-${release.tag_name.replace(/^v/, "")}-${triple}.zip`;
|
||||||
|
return (
|
||||||
|
release.assets.find((a) => a.name === zipName) ||
|
||||||
|
release.assets.find(
|
||||||
|
(a) => a.name.endsWith(`-${triple}.zip`) && !a.name.includes("stdlib")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickStdlibAsset(release: GhRelease): GhAsset | undefined {
|
||||||
|
return release.assets.find((a) => a.name.includes("stdlib") && a.name.endsWith(".zip"));
|
||||||
|
}
|
||||||
|
|
||||||
|
async function applyManagedPaths(context: vscode.ExtensionContext, exe: string): Promise<void> {
|
||||||
|
await cfg().update("cliPath", exe, vscode.ConfigurationTarget.Global);
|
||||||
|
await cfg().update("managedCliPath", exe, vscode.ConfigurationTarget.Global);
|
||||||
|
await cfg().update("libPath", managedLibRoot(context), vscode.ConfigurationTarget.Global);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Download recommended release bundle (exe + lib/) into extension globalStorage.
|
||||||
|
*/
|
||||||
|
export async function installFromGitHub(
|
||||||
|
context: vscode.ExtensionContext,
|
||||||
|
output: vscode.OutputChannel,
|
||||||
|
mode: "bundle" | "stdlib" = "bundle"
|
||||||
|
): Promise<InstallStatus> {
|
||||||
|
const triple = rustTargetTriple();
|
||||||
|
output.show(true);
|
||||||
|
|
||||||
|
return vscode.window.withProgress(
|
||||||
|
{
|
||||||
|
location: vscode.ProgressLocation.Notification,
|
||||||
|
title: "Marqdo",
|
||||||
|
cancellable: false,
|
||||||
|
},
|
||||||
|
async (progress) => {
|
||||||
|
progress.report({ message: "Fetching latest release…" });
|
||||||
|
output.appendLine(`Fetching https://github.com/${REPO}/releases/latest`);
|
||||||
|
const release = await fetchLatestRelease();
|
||||||
|
output.appendLine(`Latest: ${release.tag_name}`);
|
||||||
|
|
||||||
|
const destRoot = managedRoot(context);
|
||||||
|
fs.mkdirSync(destRoot, { recursive: true });
|
||||||
|
const tmp = path.join(os.tmpdir(), `marqdo-ext-${Date.now()}`);
|
||||||
|
fs.mkdirSync(tmp, { recursive: true });
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (mode === "bundle") {
|
||||||
|
if (!triple) {
|
||||||
|
throw new Error(
|
||||||
|
`No prebuilt bundle for ${process.platform}/${process.arch}. Open ${release.html_url} or build from source.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const asset = pickBundleAsset(release, triple);
|
||||||
|
if (!asset) {
|
||||||
|
throw new Error(
|
||||||
|
`No asset for ${triple} in ${release.tag_name}. Available: ${release.assets
|
||||||
|
.map((a) => a.name)
|
||||||
|
.join(", ") || "(none)"}. See ${release.html_url}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const zipPath = path.join(tmp, asset.name);
|
||||||
|
progress.report({ message: `Downloading ${asset.name}…` });
|
||||||
|
await downloadToFile(asset.browser_download_url, zipPath, (m) => output.appendLine(m));
|
||||||
|
progress.report({ message: "Extracting (CLI + stdlib)…" });
|
||||||
|
// Clear previous managed install
|
||||||
|
fs.rmSync(destRoot, { recursive: true, force: true });
|
||||||
|
fs.mkdirSync(destRoot, { recursive: true });
|
||||||
|
extractZip(zipPath, destRoot);
|
||||||
|
output.appendLine(`Extracted to ${destRoot}`);
|
||||||
|
} else {
|
||||||
|
const asset = pickStdlibAsset(release);
|
||||||
|
if (!asset) {
|
||||||
|
throw new Error(`No stdlib zip in ${release.tag_name}. See ${release.html_url}`);
|
||||||
|
}
|
||||||
|
const zipPath = path.join(tmp, asset.name);
|
||||||
|
progress.report({ message: `Downloading ${asset.name}…` });
|
||||||
|
await downloadToFile(asset.browser_download_url, zipPath, (m) => output.appendLine(m));
|
||||||
|
progress.report({ message: "Extracting stdlib…" });
|
||||||
|
extractZip(zipPath, destRoot);
|
||||||
|
output.appendLine(`Stdlib extracted to ${destRoot}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const exe = managedExePath(context);
|
||||||
|
if (mode === "bundle" && !fs.existsSync(exe)) {
|
||||||
|
// Some zips might nest a folder
|
||||||
|
const nested = findFileRecursive(destRoot, process.platform === "win32" ? "marqdo.exe" : "marqdo");
|
||||||
|
if (nested) {
|
||||||
|
// Flatten: move exe+lib up if needed is complex; just point cliPath at nested
|
||||||
|
await cfg().update("cliPath", nested, vscode.ConfigurationTarget.Global);
|
||||||
|
await cfg().update("managedCliPath", nested, vscode.ConfigurationTarget.Global);
|
||||||
|
const libCandidate = path.dirname(nested);
|
||||||
|
await cfg().update("libPath", libCandidate, vscode.ConfigurationTarget.Global);
|
||||||
|
} else {
|
||||||
|
throw new Error(`Extracted archive but ${exe} not found`);
|
||||||
|
}
|
||||||
|
} else if (mode === "bundle") {
|
||||||
|
await applyManagedPaths(context, exe);
|
||||||
|
} else {
|
||||||
|
await cfg().update("libPath", managedLibRoot(context), vscode.ConfigurationTarget.Global);
|
||||||
|
}
|
||||||
|
|
||||||
|
// chmod +x on unix
|
||||||
|
if (process.platform !== "win32" && fs.existsSync(exe)) {
|
||||||
|
fs.chmodSync(exe, 0o755);
|
||||||
|
}
|
||||||
|
|
||||||
|
const status = checkInstallStatus(context);
|
||||||
|
output.appendLine(status.detail);
|
||||||
|
if (status.cliOk && status.versionOk && status.libOk) {
|
||||||
|
void vscode.window.showInformationMessage(
|
||||||
|
`Marqdo ready (${status.parsedVersion ?? status.version}). Stdlib OK.`
|
||||||
|
);
|
||||||
|
} else if (status.cliOk && !status.versionOk) {
|
||||||
|
void vscode.window.showWarningMessage(
|
||||||
|
`Marqdo CLI still below ${status.requiredVersion}. ${status.detail}`
|
||||||
|
);
|
||||||
|
} else if (status.cliOk && !status.libOk) {
|
||||||
|
void vscode.window.showWarningMessage(
|
||||||
|
`Marqdo CLI ok but stdlib still missing. Try “Marqdo: Install / Repair CLI”.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(tmp, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function findFileRecursive(root: string, name: string): string | undefined {
|
||||||
|
const stack = [root];
|
||||||
|
while (stack.length) {
|
||||||
|
const dir = stack.pop()!;
|
||||||
|
let entries: fs.Dirent[];
|
||||||
|
try {
|
||||||
|
entries = fs.readdirSync(dir, { withFileTypes: true });
|
||||||
|
} catch {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const e of entries) {
|
||||||
|
const p = path.join(dir, e.name);
|
||||||
|
if (e.isDirectory()) {
|
||||||
|
stack.push(p);
|
||||||
|
} else if (e.name === name) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function promptIfNeeded(
|
||||||
|
context: vscode.ExtensionContext,
|
||||||
|
output: vscode.OutputChannel
|
||||||
|
): Promise<void> {
|
||||||
|
if (cfg().get<boolean>("autoInstall.checkOnStartup") === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (context.globalState.get<boolean>(SKIP_KEY)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const status = checkInstallStatus(context);
|
||||||
|
output.appendLine(`[install] ${status.detail}`);
|
||||||
|
|
||||||
|
if (status.cliOk && status.versionOk && status.libOk) {
|
||||||
|
output.appendLine(`[install] ready (CLI ≥ ${status.requiredVersion}, stdlib present)`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let message: string;
|
||||||
|
let primary: string;
|
||||||
|
const mode = status.suggestedMode ?? "bundle";
|
||||||
|
|
||||||
|
if (!status.cliOk) {
|
||||||
|
message = `Marqdo CLI not detected. Install CLI ≥ ${status.requiredVersion} with the standard library?`;
|
||||||
|
primary = "Install CLI + stdlib";
|
||||||
|
} else if (!status.versionOk) {
|
||||||
|
message = `Marqdo CLI version is too old (need ≥ ${status.requiredVersion}${
|
||||||
|
status.parsedVersion ? `, found ${status.parsedVersion}` : `, raw: ${status.version}`
|
||||||
|
}). Upgrade now (includes stdlib)?`;
|
||||||
|
primary = "Upgrade CLI + stdlib";
|
||||||
|
} else {
|
||||||
|
message =
|
||||||
|
"Marqdo CLI is OK, but the standard library (lib/) is missing. Download stdlib into the extension?";
|
||||||
|
primary = "Install stdlib";
|
||||||
|
}
|
||||||
|
|
||||||
|
const choice = await vscode.window.showWarningMessage(
|
||||||
|
message,
|
||||||
|
{ modal: false },
|
||||||
|
primary,
|
||||||
|
"Open Releases",
|
||||||
|
"Don't ask again"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (choice === primary) {
|
||||||
|
try {
|
||||||
|
await installFromGitHub(context, output, mode);
|
||||||
|
} catch (e) {
|
||||||
|
const err = e instanceof Error ? e.message : String(e);
|
||||||
|
output.appendLine(`[install] ${err}`);
|
||||||
|
const open = await vscode.window.showErrorMessage(`Marqdo install failed: ${err}`, "Open Releases");
|
||||||
|
if (open) {
|
||||||
|
await vscode.env.openExternal(vscode.Uri.parse(`https://github.com/${REPO}/releases`));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (choice === "Open Releases") {
|
||||||
|
await vscode.env.openExternal(vscode.Uri.parse(`https://github.com/${REPO}/releases`));
|
||||||
|
} else if (choice === "Don't ask again") {
|
||||||
|
await context.globalState.update(SKIP_KEY, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resetSkipPrompt(context: vscode.ExtensionContext): Promise<void> {
|
||||||
|
await context.globalState.update(SKIP_KEY, undefined);
|
||||||
|
}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
import * as vscode from "vscode";
|
||||||
|
import { compareSemver, parseCliVersion } from "./install";
|
||||||
|
|
||||||
|
const REPO = "cflmy/marqdo";
|
||||||
|
const LAST_CHECK_KEY = "marqdo.lastUpdateCheck";
|
||||||
|
const CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
|
type GhRelease = {
|
||||||
|
tag_name: string;
|
||||||
|
html_url: string;
|
||||||
|
assets: { name: string }[];
|
||||||
|
};
|
||||||
|
|
||||||
|
async function fetchLatestRelease(): Promise<GhRelease> {
|
||||||
|
const res = await fetch(`https://api.github.com/repos/${REPO}/releases/latest`, {
|
||||||
|
headers: {
|
||||||
|
Accept: "application/vnd.github+json",
|
||||||
|
"User-Agent": "marqdo-vscode-extension",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`GitHub releases/latest HTTP ${res.status}`);
|
||||||
|
}
|
||||||
|
return (await res.json()) as GhRelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
function extensionVersion(): string {
|
||||||
|
return vscode.extensions.getExtension("cflmy.marqdo")?.packageJSON?.version ?? "0.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickVsixAsset(release: GhRelease): string | undefined {
|
||||||
|
const mine = extensionVersion();
|
||||||
|
const exact = release.assets.find((a) => a.name === `marqdo-${mine}.vsix`);
|
||||||
|
if (exact) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return release.assets.find((a) => a.name.endsWith(".vsix"))?.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Notify when a newer CLI or extension release exists on GitHub. */
|
||||||
|
export async function checkForUpdates(
|
||||||
|
context: vscode.ExtensionContext,
|
||||||
|
output: vscode.OutputChannel,
|
||||||
|
installedCliVersion?: string
|
||||||
|
): Promise<void> {
|
||||||
|
if (vscode.workspace.getConfiguration("marqdo").get<boolean>("autoInstall.checkUpdates") === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const last = context.globalState.get<number>(LAST_CHECK_KEY) ?? 0;
|
||||||
|
if (Date.now() - last < CHECK_INTERVAL_MS) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await context.globalState.update(LAST_CHECK_KEY, Date.now());
|
||||||
|
|
||||||
|
try {
|
||||||
|
const release = await fetchLatestRelease();
|
||||||
|
const latestTag = release.tag_name.replace(/^v/, "");
|
||||||
|
const extVer = extensionVersion();
|
||||||
|
const messages: string[] = [];
|
||||||
|
|
||||||
|
if (compareSemver(latestTag, extVer) > 0 || pickVsixAsset(release)) {
|
||||||
|
messages.push(`extension ${extVer} → ${release.tag_name}`);
|
||||||
|
}
|
||||||
|
const parsedCli = installedCliVersion ? parseCliVersion(installedCliVersion) : undefined;
|
||||||
|
if (parsedCli && compareSemver(latestTag, parsedCli) > 0) {
|
||||||
|
messages.push(`CLI ${parsedCli} → ${release.tag_name}`);
|
||||||
|
}
|
||||||
|
if (messages.length === 0) {
|
||||||
|
output.appendLine(`[update] up to date (${release.tag_name})`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
output.appendLine(`[update] newer release: ${messages.join("; ")}`);
|
||||||
|
const choice = await vscode.window.showInformationMessage(
|
||||||
|
`Marqdo ${release.tag_name} is available (${messages.join(", ")}).`,
|
||||||
|
"Open Releases",
|
||||||
|
"Later"
|
||||||
|
);
|
||||||
|
if (choice === "Open Releases") {
|
||||||
|
await vscode.env.openExternal(vscode.Uri.parse(release.html_url));
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
output.appendLine(
|
||||||
|
`[update] check skipped: ${e instanceof Error ? e.message : String(e)}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,182 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
|
||||||
|
"name": "Marqdo",
|
||||||
|
"scopeName": "source.marqdo",
|
||||||
|
"patterns": [
|
||||||
|
{ "include": "#frontmatter" },
|
||||||
|
{ "include": "#code-fence" },
|
||||||
|
{ "include": "#formula" },
|
||||||
|
{ "include": "#heading" },
|
||||||
|
{ "include": "#empty-return" },
|
||||||
|
{ "include": "#hr-end" },
|
||||||
|
{ "include": "#call" },
|
||||||
|
{ "include": "#else-arm" },
|
||||||
|
{ "include": "#return-line" },
|
||||||
|
{ "include": "#statement-line" },
|
||||||
|
{ "include": "#param-line" },
|
||||||
|
{ "include": "#loop-line" },
|
||||||
|
{ "include": "#branch" },
|
||||||
|
{ "include": "#table" },
|
||||||
|
{ "include": "#inline-code" },
|
||||||
|
{ "include": "#comment" }
|
||||||
|
],
|
||||||
|
"repository": {
|
||||||
|
"frontmatter": {
|
||||||
|
"name": "meta.embedded.block.frontmatter.marqdo",
|
||||||
|
"begin": "\\A---\\s*$",
|
||||||
|
"end": "^---\\s*$",
|
||||||
|
"beginCaptures": {
|
||||||
|
"0": { "name": "punctuation.definition.frontmatter.begin.marqdo" }
|
||||||
|
},
|
||||||
|
"endCaptures": {
|
||||||
|
"0": { "name": "punctuation.definition.frontmatter.end.marqdo" }
|
||||||
|
},
|
||||||
|
"patterns": [
|
||||||
|
{
|
||||||
|
"name": "meta.import.marqdo",
|
||||||
|
"match": "^(\\s*)(>)(\\s+)(\\S.*)$",
|
||||||
|
"captures": {
|
||||||
|
"2": { "name": "keyword.control.import.marqdo" },
|
||||||
|
"4": { "name": "string.unquoted.import.path.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "meta.frontmatter.field.marqdo",
|
||||||
|
"match": "^([A-Za-z0-9_-]+)\\s*:\\s*(.*)$",
|
||||||
|
"captures": {
|
||||||
|
"1": { "name": "entity.name.tag.frontmatter.marqdo" },
|
||||||
|
"2": { "name": "string.unquoted.frontmatter.marqdo" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"heading": {
|
||||||
|
"name": "markup.heading.marqdo",
|
||||||
|
"match": "^(#{1,6})(\\s+)(.+)$",
|
||||||
|
"captures": {
|
||||||
|
"1": { "name": "punctuation.definition.heading.marqdo" },
|
||||||
|
"3": { "name": "entity.name.function.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"empty-return": {
|
||||||
|
"name": "keyword.control.return.empty.marqdo",
|
||||||
|
"match": "^\\s*(\\*{4}|\\*\\*\\s+\\*\\*)\\s*$"
|
||||||
|
},
|
||||||
|
"hr-end": {
|
||||||
|
"name": "keyword.control.function.end.marqdo",
|
||||||
|
"match": "^\\s*(---+|\\*{3})\\s*$"
|
||||||
|
},
|
||||||
|
"call": {
|
||||||
|
"name": "meta.call.marqdo",
|
||||||
|
"match": "^(\\s*)(>)(\\s+)(\\S+)(.*)$",
|
||||||
|
"captures": {
|
||||||
|
"2": { "name": "keyword.operator.call.marqdo" },
|
||||||
|
"4": { "name": "entity.name.function.call.marqdo" },
|
||||||
|
"5": { "name": "meta.call.args.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else-arm": {
|
||||||
|
"name": "keyword.control.conditional.else.marqdo",
|
||||||
|
"match": "^(\\s*)(\\*)(\\s*)$"
|
||||||
|
},
|
||||||
|
"return-line": {
|
||||||
|
"name": "meta.return.marqdo",
|
||||||
|
"begin": "^(\\s*)(\\*\\*)(?!\\*)",
|
||||||
|
"beginCaptures": {
|
||||||
|
"2": { "name": "punctuation.definition.return.begin.marqdo" }
|
||||||
|
},
|
||||||
|
"end": "(\\*\\*)",
|
||||||
|
"endCaptures": {
|
||||||
|
"1": { "name": "punctuation.definition.return.end.marqdo" }
|
||||||
|
},
|
||||||
|
"contentName": "markup.bold.return.marqdo",
|
||||||
|
"patterns": [
|
||||||
|
{ "include": "#inline-code" },
|
||||||
|
{ "include": "#call-inline" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"statement-line": {
|
||||||
|
"name": "meta.statement.marqdo",
|
||||||
|
"begin": "^(\\s*)(\\*)(?!\\*)",
|
||||||
|
"beginCaptures": {
|
||||||
|
"2": { "name": "punctuation.definition.statement.begin.marqdo" }
|
||||||
|
},
|
||||||
|
"end": "(?<!\\*)(\\*)(?!\\*)\\s*$",
|
||||||
|
"endCaptures": {
|
||||||
|
"1": { "name": "punctuation.definition.statement.end.marqdo" }
|
||||||
|
},
|
||||||
|
"contentName": "markup.italic.statement.marqdo",
|
||||||
|
"patterns": [
|
||||||
|
{ "include": "#inline-code" },
|
||||||
|
{ "include": "#call-inline" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"call-inline": {
|
||||||
|
"name": "meta.call.inline.marqdo",
|
||||||
|
"match": "(>)(\\s*)(\\S+)",
|
||||||
|
"captures": {
|
||||||
|
"1": { "name": "keyword.operator.call.marqdo" },
|
||||||
|
"3": { "name": "entity.name.function.call.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"param-line": {
|
||||||
|
"name": "meta.param.marqdo",
|
||||||
|
"match": "^(\\s*)(\\+)(\\s+)(.+)$",
|
||||||
|
"captures": {
|
||||||
|
"2": { "name": "keyword.other.param.marqdo" },
|
||||||
|
"4": { "name": "variable.parameter.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"loop-line": {
|
||||||
|
"name": "meta.loop.marqdo",
|
||||||
|
"match": "^(\\s*)(-)(\\s+)(.+)$",
|
||||||
|
"captures": {
|
||||||
|
"2": { "name": "keyword.control.loop.marqdo" },
|
||||||
|
"4": { "name": "meta.loop.body.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"branch": {
|
||||||
|
"name": "meta.branch.marqdo",
|
||||||
|
"match": "^(\\s*)(\\d+\\.)(\\s+)(.*)$",
|
||||||
|
"captures": {
|
||||||
|
"2": { "name": "keyword.control.conditional.marqdo" },
|
||||||
|
"4": { "name": "meta.branch.condition.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"table": {
|
||||||
|
"name": "markup.table.marqdo",
|
||||||
|
"match": "^\\s*\\|.*\\|\\s*$"
|
||||||
|
},
|
||||||
|
"formula": {
|
||||||
|
"name": "meta.embedded.math.marqdo",
|
||||||
|
"begin": "^\\s*\\$\\$\\s*$",
|
||||||
|
"end": "^\\s*\\$\\$\\s*$",
|
||||||
|
"contentName": "string.other.math.marqdo"
|
||||||
|
},
|
||||||
|
"code-fence": {
|
||||||
|
"name": "markup.fenced_code.block.marqdo",
|
||||||
|
"begin": "^(\\s*)(```)([\\w+-]*)\\s*$",
|
||||||
|
"beginCaptures": {
|
||||||
|
"2": { "name": "punctuation.definition.raw.begin.marqdo" },
|
||||||
|
"3": { "name": "entity.name.tag.lang.marqdo" }
|
||||||
|
},
|
||||||
|
"end": "^(\\s*)(```)\\s*$",
|
||||||
|
"endCaptures": {
|
||||||
|
"2": { "name": "punctuation.definition.raw.end.marqdo" }
|
||||||
|
},
|
||||||
|
"contentName": "markup.raw.block.marqdo"
|
||||||
|
},
|
||||||
|
"inline-code": {
|
||||||
|
"name": "string.interpolated.marqdo",
|
||||||
|
"match": "`([^`]+)`",
|
||||||
|
"captures": {
|
||||||
|
"0": { "name": "markup.inline.raw.marqdo" },
|
||||||
|
"1": { "name": "variable.other.marqdo" }
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"comment": {
|
||||||
|
"name": "comment.line.marqdo",
|
||||||
|
"match": "^.+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "commonjs",
|
||||||
|
"target": "ES2020",
|
||||||
|
"outDir": "out",
|
||||||
|
"rootDir": "src",
|
||||||
|
"lib": ["ES2020"],
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"skipLibCheck": true
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", ".vscode-test"]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user