Răsfoiți Sursa

update docs

ruki 1 lună în urmă
părinte
comite
6d43b4efe3

+ 240 - 14
docs/guide/extensions/ide-integration-plugins.md

@@ -22,6 +22,137 @@ After completing the installation of the plugin, restart VSCode to see the statu
 
 You can set the platform, architecture, compilation mode, tool-chain and other options in the status bar, and then click Build to start the build.
 
+### Debugging Support
+
+The xmake-vscode plugin provides comprehensive breakpoint debugging support with multiple debugger types:
+
+#### Debugger Types
+- **default**: Automatically select appropriate debugger (CodeLLDB on macOS, GDB on other platforms)
+- **codelldb**: Use CodeLLDB debugger (recommended for macOS)
+- **lldb-dap**: Use official LLVM LLDB DAP debugger
+- **gdb-dap**: Use GDB DAP debugger (requires C/C++ extension)
+
+#### Debug Environment Requirements
+
+**Required VSCode Extensions:**
+- **CodeLLDB**: For macOS and Linux debugging (install `vadimcn.vscode-lldb`)
+- **C/C++**: For GDB DAP debugging support (install `ms-vscode.cpptools`)
+- **LLDB DAP**: For official LLDB debugging (install `llvm-vs-code-extensions.lldb-dap`)
+
+**System Debugger Requirements:**
+- **macOS**: Need Xcode Command Line Tools (includes `lldb` command)
+- **Linux**: Need `gdb` or `lldb` debugger installed
+- **Windows**: Need Visual Studio Build Tools or MinGW-w64 (includes `gdb`)
+
+**Installation Commands:**
+```bash
+# macOS
+xcode-select --install
+
+# Ubuntu/Debian
+sudo apt install gdb
+
+# CentOS/RHEL
+sudo yum install gdb
+
+# Windows (using Chocolatey)
+choco install gdb
+```
+
+#### Debug Configuration
+The xmake-vscode plugin automatically generates debug configuration and passes it to the debugger, so users don't need to manually create `launch.json`.
+
+If you need to override internal debug configuration, you can use `xmake.customDebugConfig` setting:
+
+```json
+{
+  "xmake.customDebugConfig": {
+    "stopAtEntry": false,
+    "args": ["--custom-arg"],
+    "env": {
+      "CUSTOM_ENV": "value"
+    }
+  }
+}
+```
+
+### Configuration Options
+
+The plugin supports rich configuration options that can be configured in VSCode settings:
+
+#### Basic Configuration
+```json
+{
+  "xmake.executable": "xmake",
+  "xmake.logLevel": "normal",
+  "xmake.buildLevel": "normal",
+  "xmake.runMode": "runOnly"
+}
+```
+
+#### Path Configuration
+```json
+{
+  "xmake.buildDirectory": "${workspaceRoot}/build",
+  "xmake.installDirectory": "",
+  "xmake.packageDirectory": "",
+  "xmake.workingDirectory": "${workspaceRoot}",
+  "xmake.compileCommandsDirectory": ".vscode"
+}
+```
+
+#### Toolchain Configuration
+```json
+{
+  "xmake.androidNDKDirectory": "",
+  "xmake.QtDirectory": "",
+  "xmake.WDKDirectory": ""
+}
+```
+
+#### IntelliSense Configuration
+```json
+{
+  "xmake.compileCommandsBackend": "clangd",
+  "xmake.autoGenerateCompileCommands": "onFileChange",
+  "xmake.compileCommandsDirectory": ".vscode",
+  "xmake.enableSyntaxCheck": true
+}
+```
+
+> **Tip**: For detailed explanation of these configuration options (such as auto-generation mode, generation path, etc.), please jump to the [Configure IntelliSense](#intellisense) section below.
+
+#### Debug Configuration
+```json
+{
+  "xmake.debugConfigType": "default",
+  "xmake.debuggingTargetsArguments": {
+    "default": ["--debug"],
+    "mytarget": ["--arg1", "--arg2"]
+  },
+  "xmake.runningTargetsArguments": {
+    "default": []
+  },
+  "xmake.envBehaviour": "merge"
+}
+```
+
+#### Status Bar Configuration
+```json
+{
+  "xmake.status.showProject": false,
+  "xmake.status.showXMake": true,
+  "xmake.status.showPlatform": false,
+  "xmake.status.showArch": false,
+  "xmake.status.showMode": false,
+  "xmake.status.showToolchain": false,
+  "xmake.status.showTarget": false,
+  "xmake.status.showBuild": true,
+  "xmake.status.showRun": true,
+  "xmake.status.showDebug": true
+}
+```
+
 ### Custom options
 
 If these options are not enough, you can create .vscode/settings.json and write the settings required by xmake, such as:
@@ -38,7 +169,7 @@ If these options are not enough, you can create .vscode/settings.json and write
 
 Other xmake options can also be set in settings.json. After modification, the configuration can be refreshed through the >XMake: Configure command.
 
-### Configure Intellsence
+### Configure IntelliSense {#intellisense}
 
 For a better C++ syntax prompt experience, xmake provides support for [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) (LSP for short).
 
@@ -52,9 +183,9 @@ In addition, in order to support intellisense, xmake provides compile_commands.j
 
 Usually after modifying xmake.lua and clicking Save, the xmake-vscode plugin will trigger the automatic generation of compile_commands.json, which is stored in the .vscode directory by default.
 
-This is also the recommended way. Usually after installing the xmake-vscode plugin and opening the project with xmake.lua, you only need to edit xmake.lua to save and trigger without any other additional operations.
+This is also the recommended way. Usually after installing the xmake-vscode plugin and opening the project with xmake.lua, you only need to edit xmake.lua to save and trigger, without any other additional operations.
 
-##### Manually trigger generation
+##### Manual trigger generation
 
 Of course, if we don't see the file being generated, we can also use the `>XMake: UpdateIntellisense` command to manually trigger the generation of .vscode/compile_commands.json in VSCode.
 
@@ -65,8 +196,8 @@ Alternatively, we can also use this rule to automatically update and generate co
 ```lua
 add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode"})
 target("test")
-     set_kind("binary")
-     add_files("src/*.c")
+    set_kind("binary")
+    add_files("src/*.c")
 ```
 
 This will automatically update this file after each build.
@@ -79,7 +210,16 @@ If the above methods are invalid, we can also execute the command to generate it
 $ xmake project -k compile_commands .vscode
 ```
 
-#### vscode-cpptools
+#### IntelliSense Configuration
+
+```json
+{
+  "xmake.compileCommandsBackend": "clangd",
+  "xmake.autoGenerateCompileCommands": "onFileChange",
+  "xmake.compileCommandsDirectory": ".vscode",
+  "xmake.enableSyntaxCheck": true
+}
+```
 
 If we use the vscode-cpptools plugin to provide intellisense support, we need to go to the VSCode plugin marketplace first, search for C++, and install the default first plugin.
 
@@ -156,21 +296,25 @@ Also, since the compile_commands.json generated by XMake is in the .vscode direc
 }
 ```
 
-## Sublime Plugin
+## Intellij IDEA/CLion Plugin
 
-* [xmake-sublime](https://github.com/xmake-io/xmake-sublime)
+* [xmake-idea](https://github.com/xmake-io/xmake-idea)
 
-<img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" />
+<img src="https://raw.githubusercontent.com/xmake-io/xmake-idea/master/res/problem.gif" width="650px" />
 
-## Intellij IDEA/Clion Plugin
+**CLion 2025.3+ New Feature**: Supports lldb/gdb-dap debugging, allowing you to debug Xmake projects directly without needing to generate `CMakeLists.txt` as a workaround. You can set breakpoints, step through code, and view variable values.
 
-* [xmake-idea](https://github.com/xmake-io/xmake-idea)
+Debug configuration interface:
 
-<img src="https://raw.githubusercontent.com/xmake-io/xmake-idea/master/res/problem.gif" width="650px" />
+<img src="/assets/img/posts/xmake/xmake-idea-dap-debug-conf.png" width="650px" />
 
-## Vim Plugin
+Runtime debugging interface:
 
-* [xmake.vim](https://github.com/luzhlon/xmake.vim) (third-party, thanks [@luzhlon](https://github.com/luzhlon))
+<img src="/assets/img/posts/xmake/xmake-idea-dap-debug-run.png" width="650px" />
+
+Additionally, the plugin now supports automatic updating of `compile_commands.json` to improve C++ code completion and highlighting experience.
+
+<img src="/assets/img/posts/xmake/xmake-idea-update-compd.png" width="650px" />
 
 ## Neovim Plugin
 
@@ -180,6 +324,78 @@ The plugin provides an easy-to-use configuration UI and auto-generation of *comp
 
 <img src="https://raw.githubusercontent.com/Mythos-404/xmake.nvim/main/assets/XmakePreview.gif" width="650px" />
 
+## Zed Editor Plugin
+
+* [xmake-zed](https://github.com/xmake-io/xmake-zed)
+
+[Zed](https://zed.dev/) is a high-performance, multiplayer code editor, and xmake provides plugin support for it.
+
+### Plugin installation
+
+The Zed editor plugin provides seamless integration with xmake, offering features like:
+
+- Project configuration and build management
+- Real-time build status and error reporting
+- IntelliSense support through compile_commands.json generation
+- Quick access to common xmake commands
+
+> **Note**: The plugin is currently being submitted to the official Zed marketplace and is pending review ([PR #4565](https://github.com/zed-industries/extensions/pull/4565)). In the meantime, you can install it locally:
+
+#### Local Installation
+
+1. Clone the plugin repository:
+   ```sh
+   git clone https://github.com/xmake-io/xmake-zed.git
+   ```
+
+2. Load the extension in Zed:
+   - Open Zed editor
+   - Go to `Zed > Extensions`
+   - Click `Load Extension` and select the cloned `xmake-zed` directory
+
+#### Marketplace Installation (Future Support)
+
+Once the official review is approved, you'll be able to install it directly from the Zed marketplace by going to `Zed > Extensions`, then search for `xmake` and install the official plugin.
+
+### Usage
+
+After installation, the plugin will automatically detect xmake projects and provide:
+
+- **Full LSP Support**: Code completion, diagnostics, hover info, code actions, symbol navigation, and formatting via xmake_ls
+- **Syntax Highlighting**: Support for 300+ XMake API functions
+- **Project Templates**: 25+ project templates covering 15 programming languages
+- **Auto-installation**: Automatically downloads and installs xmake_ls language server
+
+> **Tip**: The plugin will automatically download and install the xmake_ls language server, no manual configuration required.
+
+### Configuration
+
+The plugin supports the following main configuration options:
+
+```json
+{
+  "lsp": {
+    "xmake-ls": {
+      "settings": {
+        "linuxVariant": "auto",
+        "logLevel": "Info",
+        "enableDiagnostics": true,
+        "enableCompletion": true,
+        "enableHover": true,
+        "enableCodeActions": true,
+        "xmakePath": ""
+      }
+    }
+  }
+}
+```
+
+Key options:
+- **linuxVariant**: Linux binary variant (auto/musl/x64 etc.)
+- **logLevel**: Log level (Error/Warning/Info/Debug/Trace)
+- **enableDiagnostics/Completion/Hover/CodeActions**: Enable/disable features
+- **xmakePath**: Path to xmake executable
+
 ## Gradle Plugin (JNI)
 
 * [xmake-gradle](https://github.com/xmake-io/xmake-gradle): A gradle plugin that integrates xmake seamlessly
@@ -331,3 +547,13 @@ $ ./gradlew app:assembleDebug
 ```sh
 $ ./gradlew nativelib:xmakeRebuild
 ```
+
+## Sublime Plugin
+
+* [xmake-sublime](https://github.com/xmake-io/xmake-sublime)
+
+<img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" />
+
+## Vim Plugin
+
+* [xmake.vim](https://github.com/luzhlon/xmake.vim) (third-party, thanks [@luzhlon](https://github.com/luzhlon))

+ 236 - 8
docs/zh/guide/extensions/ide-integration-plugins.md

@@ -22,6 +22,137 @@
 
 可以在状态栏设置平台、架构、编译模式、工具链等选项,随后点击 Build 开始构建。
 
+### 调试支持
+
+xmake-vscode 插件提供了完整的断点调试支持,支持多种调试器类型:
+
+#### 调试器类型
+- **default**: 自动选择合适的调试器(macOS 默认使用 CodeLLDB,其他平台使用 GDB)
+- **codelldb**: 使用 CodeLLDB 调试器(推荐用于 macOS)
+- **lldb-dap**: 使用 LLVM 官方 LLDB DAP 调试器
+- **gdb-dap**: 使用 GDB DAP 调试器(需要 C/C++ 插件支持)
+
+#### 调试环境要求
+
+**必需的 VSCode 插件:**
+- **CodeLLDB**: 用于 macOS 和 Linux 调试(推荐安装 `vadimcn.vscode-lldb`)
+- **C/C++**: 用于 GDB DAP 调试支持(安装 `ms-vscode.cpptools`)
+- **LLDB DAP**: 用于官方 LLDB 调试(安装 `llvm-vs-code-extensions.lldb-dap`)
+
+**系统调试器要求:**
+- **macOS**: 需要安装 Xcode Command Line Tools(包含 `lldb` 命令)
+- **Linux**: 需要安装 `gdb` 或 `lldb` 调试器
+- **Windows**: 需要 Visual Studio Build Tools 或 MinGW-w64(包含 `gdb`)
+
+**安装命令:**
+```bash
+# macOS
+xcode-select --install
+
+# Ubuntu/Debian
+sudo apt install gdb
+
+# CentOS/RHEL
+sudo yum install gdb
+
+# Windows (使用 Chocolatey)
+choco install gdb
+```
+
+#### 调试配置
+xmake-vscode 插件会自动生成调试配置并传递给调试器,用户无需手动创建 `launch.json`。
+
+如果需要覆盖内部调试配置,可以使用 `xmake.customDebugConfig` 设置:
+
+```json
+{
+  "xmake.customDebugConfig": {
+    "stopAtEntry": false,
+    "args": ["--custom-arg"],
+    "env": {
+      "CUSTOM_ENV": "value"
+    }
+  }
+}
+```
+
+### 配置选项
+
+插件支持丰富的配置选项,可在 VSCode 设置中配置:
+
+#### 基础配置
+```json
+{
+  "xmake.executable": "xmake",
+  "xmake.logLevel": "normal",
+  "xmake.buildLevel": "normal",
+  "xmake.runMode": "runOnly"
+}
+```
+
+#### 路径配置
+```json
+{
+  "xmake.buildDirectory": "${workspaceRoot}/build",
+  "xmake.installDirectory": "",
+  "xmake.packageDirectory": "",
+  "xmake.workingDirectory": "${workspaceRoot}",
+  "xmake.compileCommandsDirectory": ".vscode"
+}
+```
+
+#### 工具链配置
+```json
+{
+  "xmake.androidNDKDirectory": "",
+  "xmake.QtDirectory": "",
+  "xmake.WDKDirectory": ""
+}
+```
+
+#### IntelliSense 配置
+```json
+{
+  "xmake.compileCommandsBackend": "clangd",
+  "xmake.autoGenerateCompileCommands": "onFileChange",
+  "xmake.compileCommandsDirectory": ".vscode",
+  "xmake.enableSyntaxCheck": true
+}
+```
+
+> **提示**: 关于这些配置选项的详细说明(如自动生成模式、生成路径等),请跳转到下面的 [配置 IntelliSense](#intellisense) 章节。
+
+#### 调试配置
+```json
+{
+  "xmake.debugConfigType": "default",
+  "xmake.debuggingTargetsArguments": {
+    "default": ["--debug"],
+    "mytarget": ["--arg1", "--arg2"]
+  },
+  "xmake.runningTargetsArguments": {
+    "default": []
+  },
+  "xmake.envBehaviour": "merge"
+}
+```
+
+#### 状态栏配置
+```json
+{
+  "xmake.status.showProject": false,
+  "xmake.status.showXMake": true,
+  "xmake.status.showPlatform": false,
+  "xmake.status.showArch": false,
+  "xmake.status.showMode": false,
+  "xmake.status.showToolchain": false,
+  "xmake.status.showTarget": false,
+  "xmake.status.showBuild": true,
+  "xmake.status.showRun": true,
+  "xmake.status.showDebug": true
+}
+```
+
 ### 自定义选项
 
 如果这些选项不够,可以创建 .vscode/settings.json 并编写 xmake 需要的设置,如:
@@ -79,6 +210,17 @@ target("test")
 $ xmake project -k compile_commands .vscode
 ```
 
+#### IntelliSense 配置
+
+```json
+{
+  "xmake.compileCommandsBackend": "clangd",
+  "xmake.autoGenerateCompileCommands": "onFileChange",
+  "xmake.compileCommandsDirectory": ".vscode",
+  "xmake.enableSyntaxCheck": true
+}
+```
+
 #### vscode-cpptools
 
 如果我们使用 vscode-cpptools 插件来提供 intellisense 支持,需要先去 VSCode 插件市场,搜索 C++,默认第一个插件就是,安装即可。
@@ -161,21 +303,25 @@ $ xmake project -k compile_commands .vscode
 
 如果配置后,还是没生效,可以尝试重启 VSCode 和 clangd 进程,再验证。
 
-## Sublime 插件 {#sublime-plugin}
-
-* [xmake-sublime](https://github.com/xmake-io/xmake-sublime)
-
-<img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" />
-
 ## Intellij IDEA/CLion 插件 {#clion-plugin}
 
 * [xmake-idea](https://github.com/xmake-io/xmake-idea)
 
 <img src="https://raw.githubusercontent.com/xmake-io/xmake-idea/master/res/problem.gif" width="650px" />
 
-## Vim 插件 {#vim-plugin}
+**CLion 2025.3+ 版本新特性**: 支持 lldb/gdb-dap 调试,现在可以直接调试 Xmake 项目,不再需要通过生成 `CMakeLists.txt` 来变相支持调试。支持设置断点、单步调试和查看变量值。
 
-* [xmake.vim](https://github.com/luzhlon/xmake.vim) (第三方开发, 感谢[@luzhlon](https://github.com/luzhlon))
+调试配置界面:
+
+<img src="/assets/img/posts/xmake/xmake-idea-dap-debug-conf.png" width="650px" />
+
+运行时调试界面:
+
+<img src="/assets/img/posts/xmake/xmake-idea-dap-debug-run.png" width="650px" />
+
+此外,插件还增加了自动更新 `compile_commands.json` 的支持,以改进 C++ 代码的自动补全和高亮体验。
+
+<img src="/assets/img/posts/xmake/xmake-idea-update-compd.png" width="650px" />
 
 ## Neovim 插件 {#neovim-plugin}
 
@@ -185,6 +331,78 @@ $ xmake project -k compile_commands .vscode
 
 <img src="https://raw.githubusercontent.com/Mythos-404/xmake.nvim/main/assets/XmakePreview.gif" width="650px" />
 
+## Zed 编辑器插件 {#zed-plugin}
+
+* [xmake-zed](https://github.com/xmake-io/xmake-zed)
+
+[Zed](https://zed.dev/) 是一个高性能的多人协作代码编辑器,xmake 为其提供了插件支持。
+
+### 插件安装
+
+Zed 编辑器插件提供了与 xmake 的无缝集成,提供以下功能:
+
+- 项目配置和构建管理
+- 实时构建状态和错误报告
+- 通过 compile_commands.json 生成支持 IntelliSense
+- 快速访问常用 xmake 命令
+
+> **注意**: 插件正在提交到 Zed 官方市场,等待审核中 ([PR #4565](https://github.com/zed-industries/extensions/pull/4565))。在此期间,您可以通过本地安装方式使用:
+
+#### 本地安装
+
+1. 克隆插件仓库:
+   ```sh
+   git clone https://github.com/xmake-io/xmake-zed.git
+   ```
+
+2. 在 Zed 中打开插件目录:
+   - 打开 Zed 编辑器
+   - 转到 `Zed > Extensions`
+   - 点击 `Load Extension` 并选择克隆的 `xmake-zed` 目录
+
+#### 市场安装(未来支持)
+
+等待官方审核通过后,您可以直接在 Zed 中转到 `Zed > Extensions`,然后搜索 `xmake` 并安装官方插件。
+
+### 使用方法
+
+安装后,插件将自动检测工作区中的 xmake 项目并提供以下功能:
+
+- **完整的 LSP 支持**: 通过 xmake_ls 提供代码补全、诊断、悬停信息、代码操作、符号导航和格式化
+- **语法高亮**: 支持 300+ XMake API 函数的语法高亮
+- **项目模板**: 支持 25+ 项目模板,涵盖 15 种编程语言
+- **自动安装**: 自动下载和安装 xmake_ls 语言服务器
+
+> **提示**: 插件会自动下载和安装 xmake_ls 语言服务器,无需手动配置。
+
+### 配置
+
+插件支持以下主要配置选项:
+
+```json
+{
+  "lsp": {
+    "xmake-ls": {
+      "settings": {
+        "linuxVariant": "auto",
+        "logLevel": "Info",
+        "enableDiagnostics": true,
+        "enableCompletion": true,
+        "enableHover": true,
+        "enableCodeActions": true,
+        "xmakePath": ""
+      }
+    }
+  }
+}
+```
+
+主要配置项:
+- **linuxVariant**: Linux 二进制变体(auto/musl/x64 等)
+- **logLevel**: 日志级别(Error/Warning/Info/Debug/Trace)
+- **enableDiagnostics/Completion/Hover/CodeActions**: 启用/禁用各项功能
+- **xmakePath**: xmake 可执行文件路径
+
 ## Gradle插件(JNI){#gradle-plugin}
 
 * [xmake-gradle](https://github.com/xmake-io/xmake-gradle): 一个无缝整合 xmake 的 gradle 插件
@@ -337,3 +555,13 @@ $ ./gradlew app:assembleDebug
 ```sh
 $ ./gradlew nativelib:xmakeRebuild
 ```
+
+## Sublime 插件 {#sublime-plugin}
+
+* [xmake-sublime](https://github.com/xmake-io/xmake-sublime)
+
+<img src="https://raw.githubusercontent.com/xmake-io/xmake-sublime/master/res/problem.gif" width="650px" />
+
+## Vim 插件 {#vim-plugin}
+
+* [xmake.vim](https://github.com/luzhlon/xmake.vim) (第三方开发, 感谢[@luzhlon](https://github.com/luzhlon))