diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5e04515..2d25666e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -284,9 +284,6 @@ jobs: - target: alpine-x64 image: ghcr.io/blackdex/rust-musl:x86_64-musl-nightly rust-target: x86_64-unknown-linux-musl - - target: alpine-arm64 - image: ghcr.io/blackdex/rust-musl:aarch64-musl-nightly - rust-target: aarch64-unknown-linux-musl steps: - name: Install build dependencies run: | @@ -647,7 +644,6 @@ jobs: - win32-x64 - darwin-arm64 - alpine-x64 - - alpine-arm64 - web steps: - name: Download VSIX artifacts diff --git a/Cargo.toml b/Cargo.toml index a72b76a3..e17616a4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "vide" -version = "1.1.0" +version = "1.2.0" edition = "2024" authors = ["roifewu ", "hongjr03 "] repository = "https://github.com/pascal-lab/vide" diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index f2be334f..e70fcecd 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -134,7 +134,7 @@ export default defineConfig({ { label: 'Changelog', translations: { en: 'Changelog' }, - items: ['changelog', 'changelog/v1-1-0'], + items: ['changelog', 'changelog/v1-2-0', 'changelog/v1-1-0'], }, { label: 'Playground', diff --git a/docs/src/content/docs/advanced-guide/advanced-installation.md b/docs/src/content/docs/advanced-guide/advanced-installation.md index d515f84f..860af175 100644 --- a/docs/src/content/docs/advanced-guide/advanced-installation.md +++ b/docs/src/content/docs/advanced-guide/advanced-installation.md @@ -106,10 +106,9 @@ npm run package:vsix -- --target linux-arm64 npm run package:vsix -- --target win32-x64 npm run package:vsix -- --target darwin-arm64 npm run package:vsix -- --target alpine-x64 -npm run package:vsix -- --target alpine-arm64 ``` -这些脚本会先编译扩展,然后准备目标平台的 release 版语言服务器,再生成 `vide-vscode-.vsix`。release 包默认不启用 profile trace,也不包含 Speedscope 静态资源或 profiling 命令。当前 release workflow 只覆盖上面这些目标:glibc Linux、Windows x64、macOS arm64,以及 Alpine/musl x64 和 arm64。 +这些脚本会先编译扩展,然后准备目标平台的 release 版语言服务器,再生成 `vide-vscode-.vsix`。release 包默认不启用 profile trace,也不包含 Speedscope 静态资源或 profiling 命令。当前 release workflow 只覆盖上面这些目标:glibc Linux、Windows x64、macOS arm64,以及 Alpine/musl x64。 这几项也是当前 CI 会实际构建的 VSIX 目标。其他平台不是当前支持的打包目标。 上面的打包命令都需要先准备目标平台的语言服务器二进制;`editors/vscode/scripts/package.ts` 会调用 `cargo xtask vscode prepare-server`,而通用的 server 构建规则由 `cargo xtask server build` 承载: @@ -158,7 +157,6 @@ code --install-extension ./vide-vscode-win32-x64-debug.vsix VSIX 是按平台打包的。当前正式发布和 CI 产物覆盖这些目标: -- `alpine-arm64` - `alpine-x64` - `darwin-arm64` - `linux-arm64` diff --git a/docs/src/content/docs/assets/changelog/1.2.0/ansi-non-ansi.gif b/docs/src/content/docs/assets/changelog/1.2.0/ansi-non-ansi.gif new file mode 100644 index 00000000..34aecd9f Binary files /dev/null and b/docs/src/content/docs/assets/changelog/1.2.0/ansi-non-ansi.gif differ diff --git a/docs/src/content/docs/assets/changelog/1.2.0/conv-to-always-comb.gif b/docs/src/content/docs/assets/changelog/1.2.0/conv-to-always-comb.gif new file mode 100644 index 00000000..9a08fda6 Binary files /dev/null and b/docs/src/content/docs/assets/changelog/1.2.0/conv-to-always-comb.gif differ diff --git a/docs/src/content/docs/assets/changelog/1.2.0/extract-var.gif b/docs/src/content/docs/assets/changelog/1.2.0/extract-var.gif new file mode 100644 index 00000000..5bc027ac Binary files /dev/null and b/docs/src/content/docs/assets/changelog/1.2.0/extract-var.gif differ diff --git a/docs/src/content/docs/assets/changelog/1.2.0/macro-hover-inlay.gif b/docs/src/content/docs/assets/changelog/1.2.0/macro-hover-inlay.gif new file mode 100644 index 00000000..0dec5bdf Binary files /dev/null and b/docs/src/content/docs/assets/changelog/1.2.0/macro-hover-inlay.gif differ diff --git a/docs/src/content/docs/assets/changelog/1.2.0/named-port-shorthand-expansion-collapse.gif b/docs/src/content/docs/assets/changelog/1.2.0/named-port-shorthand-expansion-collapse.gif new file mode 100644 index 00000000..1092c9ed Binary files /dev/null and b/docs/src/content/docs/assets/changelog/1.2.0/named-port-shorthand-expansion-collapse.gif differ diff --git a/docs/src/content/docs/assets/changelog/1.2.0/struct-outline.png b/docs/src/content/docs/assets/changelog/1.2.0/struct-outline.png new file mode 100644 index 00000000..fc3f1ff9 Binary files /dev/null and b/docs/src/content/docs/assets/changelog/1.2.0/struct-outline.png differ diff --git a/docs/src/content/docs/changelog/index.mdx b/docs/src/content/docs/changelog/index.mdx index 9e9a4121..e5dfdc42 100644 --- a/docs/src/content/docs/changelog/index.mdx +++ b/docs/src/content/docs/changelog/index.mdx @@ -8,6 +8,11 @@ import { CardGrid, LinkCard } from '@astrojs/starlight/components'; 按版本查看 Vide 的发布变化。 + .vsix`. Release packages do not enable profile trace, and they do not include Speedscope static assets or the profiling command by default. The current release workflow only covers those targets: glibc Linux, Windows x64, macOS arm64, and Alpine/musl x64 and arm64. +These scripts compile the extension, prepare a release server binary for the target platform, and generate `vide-vscode-.vsix`. Release packages do not enable profile trace, and they do not include Speedscope static assets or the profiling command by default. The current release workflow only covers those targets: glibc Linux, Windows x64, macOS arm64, and Alpine/musl x64. Those are also the VSIX targets currently built by CI. Other platforms are not current packaging targets. All packaging commands above need to prepare the language server binary for the target platform first. `editors/vscode/scripts/package.ts` calls `cargo xtask vscode prepare-server`, and the reusable server build rules live under `cargo xtask server build`: @@ -172,7 +171,6 @@ You can download a `.vsix` file and install it manually. Choose the source based VSIX packages are platform-specific. Current release and CI artifacts cover these targets: -- `alpine-arm64` - `alpine-x64` - `darwin-arm64` - `linux-arm64` diff --git a/docs/src/content/docs/en/changelog/index.mdx b/docs/src/content/docs/en/changelog/index.mdx index b030dd53..1a848cf1 100644 --- a/docs/src/content/docs/en/changelog/index.mdx +++ b/docs/src/content/docs/en/changelog/index.mdx @@ -8,6 +8,11 @@ import { CardGrid, LinkCard } from '@astrojs/starlight/components'; Browse Vide changes by version. + Outline panel, breadcrumbs , and `Go to Symbol in Editor`. +Document symbols organize modules, ports, parameters, declarations, `struct` / `union` types, functions, tasks, generate blocks, and regions in the current file into a hierarchy. They appear in VS Code's Outline panel, breadcrumbs , and `Go to Symbol in Editor`. ## Demo diff --git a/docs/src/content/docs/en/user-guide/features/hover.mdx b/docs/src/content/docs/en/user-guide/features/hover.mdx index 66571df1..4d23bbab 100644 --- a/docs/src/content/docs/en/user-guide/features/hover.mdx +++ b/docs/src/content/docs/en/user-guide/features/hover.mdx @@ -10,7 +10,7 @@ import { hoverFiles } from '../../../../../examples/dailyUse'; ## What It Is -Hover is a lightweight explanation shown near the cursor. Place the mouse over a module name, instance name, port, parameter, task/function, or number literal to check what it means without leaving the current file. +Hover is a lightweight explanation shown near the cursor. Place the mouse over a module name, instance name, port, parameter, task/function, macro call, or number literal to check what it means without leaving the current file. ## Demo @@ -37,8 +37,12 @@ Hover is a lightweight explanation shown near the cursor. Place the mouse over a ### Without Complete Configuration -Modules, ports, and parameters declared in the current file, as well as number literals, can be shown directly. Cross-file targets only show complete information when Vide has scanned the target file and can determine a unique target. +Modules, ports, parameters, macros, and number literals declared in the current file can be shown directly. Cross-file targets only show complete information when Vide has scanned the target file and can determine a unique target. ### With Complete Configuration After `vide.toml` is configured, hover uses the project structure to resolve include paths, macro branches, and libraries. Target modules, port directions, and parameter declarations for instances become more complete. + +## Macro Hover + +For macro calls, Vide tries to show the macro signature, argument bindings, final expanded result, and nested expansion steps. Macros from include files or `defines` in `vide.toml` use the same preprocessor source information. Because the available preprocessor information can be limited, expansion sources may sometimes be imprecise; in that case, Vide only shows the parts it can confirm. diff --git a/docs/src/content/docs/en/user-guide/features/navigation.mdx b/docs/src/content/docs/en/user-guide/features/navigation.mdx index e43d77f0..9e696825 100644 --- a/docs/src/content/docs/en/user-guide/features/navigation.mdx +++ b/docs/src/content/docs/en/user-guide/features/navigation.mdx @@ -10,7 +10,7 @@ import { navigationFiles } from '../../../../../examples/dailyUse'; ## What It Is -Go to Definition takes you from a symbol use to the declaration or definition it points at. The common cases are jumping from a module instance to the module definition, from a port connection to the target port, or from a signal use to its declaration. +Go to Definition takes you from a symbol use to the declaration or definition it points at. The common cases are jumping from a module instance to the module definition, from a port connection to the target port, from a signal use to its declaration, or from a macro call to its macro definition. You can use this feature through VS Code's `Go to Definition`, `Peek Definition`, `Go to Declaration`, and `Go to Type Definition`. `Go to Declaration` prefers declaration locations; when there is no separate declaration location, it uses the definition result. @@ -46,3 +46,5 @@ For example, if one instance name can match multiple modules with the same name, ### With Complete Configuration After `vide.toml` is configured, Vide resolves targets from the project structure described by `sources`, `libraries`, `include_dirs`, `defines`, and `top_modules`. Cross-file jumps, targets inside macro branches, and duplicate module boundaries become more accurate. + +Predefined macros configured in `vide.toml` can also jump back to the manifest when an authoritative source range is available. diff --git a/docs/src/content/docs/en/user-guide/features/quick-fixes.mdx b/docs/src/content/docs/en/user-guide/features/quick-fixes.mdx index 030c6ca6..af75a23c 100644 --- a/docs/src/content/docs/en/user-guide/features/quick-fixes.mdx +++ b/docs/src/content/docs/en/user-guide/features/quick-fixes.mdx @@ -1,6 +1,6 @@ --- title: Automatic Refactoring -description: Fill ports and parameters, convert connection styles, remove empty connections, and convert numeric literal bases. +description: Fill ports and parameters, convert connection styles, clean up procedural blocks, rewrite expressions, and fix common syntax issues. --- import Codicon from '../../../../../components/Codicon.astro'; @@ -11,7 +11,7 @@ import { missingPortFiles } from '../../../../../examples/dailyUse'; ## What It Is -Automatic refactoring handles repetitive, error-prone edits such as port connections, parameter assignments, and integer literal base conversion. In VS Code, you trigger these operations from the lightbulb menu, also called Code Actions. +Automatic refactoring handles repetitive, error-prone edits such as port connections, parameter assignments, procedural blocks, control flow, and expression rewrites. In VS Code, you trigger these operations from the lightbulb menu, also called Code Actions. ## Demo @@ -36,7 +36,9 @@ Automatic refactoring handles repetitive, error-prone edits such as port connect ## Supported Actions -Place the cursor near an instance, integer literal, or diagnostic, then open the lightbulb menu. Vide currently supports: +Place the cursor near an instance, port list, procedural block, expression, integer literal, or diagnostic, then open the lightbulb menu. Vide currently supports: + +### Instances, Ports, and Parameters - `Fill connections` - `Fill parameters` @@ -45,7 +47,30 @@ Place the cursor near an instance, integer literal, or diagnostic, then open the - `Remove empty port connections` - `Add explicit empty port connection` - `Add empty instance port list` -- `Convert literal to binary/octal/decimal/hexadecimal` +- `Expand named port shorthand` / `Collapse named port to shorthand` +- `Convert ANSI port declarations to non-ANSI` / `Convert non-ANSI port declarations to ANSI` +- `Split declaration`, `Sort named parameter assignments`, and `Sort named port connections` + +### Procedural Blocks and Control Flow + +- `Convert to always_comb`, `Convert to always_ff`, `Convert to always @(*)`, and `Convert to always @(...)` +- `Add default case item` +- `Invert if/else` and `Merge nested if` +- `Wrap statement in begin/end` / `Unwrap single-statement begin/end` +- `Pull assignment up` / `Pull assignment down` + +### Expressions and Number Literals + +- `Extract into variable` +- `Apply De Morgan's law` / `Factor De Morgan's law` +- `Remove redundant parentheses` +- `Expand compound assignment` / `Collapse compound assignment` +- Increment, decrement, compound-assignment, and expanded-assignment forms can be converted into each other, for example between `count++`, `++count`, `count += 1`, and `count = count + 1`. +- `Convert literal to binary/octal/decimal/hexadecimal` and `Remove digit separators` + +### Diagnostic Quick Fixes + +- `Insert missing '{token}'` when a parse diagnostic identifies a missing bracket, semicolon, or similar syntax token. ## Project Configuration diff --git a/docs/src/content/docs/en/user-guide/features/references.mdx b/docs/src/content/docs/en/user-guide/features/references.mdx index 3baf09b3..852fd6f4 100644 --- a/docs/src/content/docs/en/user-guide/features/references.mdx +++ b/docs/src/content/docs/en/user-guide/features/references.mdx @@ -10,7 +10,7 @@ import { usageFiles } from '../../../../../examples/dailyUse'; ## What It Is -Find References answers “where is this symbol used?” In RTL projects, it is useful for tracing module instances, port connections, parameters, and signals, and for checking whether connections are complete. +Find References answers “where is this symbol used?” In RTL projects, it is useful for tracing module instances, port connections, parameters, signals, and preprocessor macros, and for checking whether connections are complete. Run VS Code's `Find All References` or `Peek References` on a symbol. Vide searches for its usage locations, deduplicates them, and shows them in the references view. @@ -45,6 +45,8 @@ Vide searches references in all Verilog/SystemVerilog files scanned from the wor After `vide.toml` is configured, reference search follows the project scope described by `sources` and `libraries`, and uses include directories and macro definitions to decide which files participate in analysis. +When a macro comes from `defines` in `vide.toml`, and the manifest source range is available, reference results also include the definition location in the manifest. + ## Result Display By default, the references view also includes the declaration location so you can confirm where the symbol comes from. If you want usage locations only, add this to VS Code Settings: diff --git a/docs/src/content/docs/en/user-guide/neovim-installation.mdx b/docs/src/content/docs/en/user-guide/neovim-installation.mdx index 8706aa40..b88fab01 100644 --- a/docs/src/content/docs/en/user-guide/neovim-installation.mdx +++ b/docs/src/content/docs/en/user-guide/neovim-installation.mdx @@ -16,7 +16,6 @@ Choose the language server binary for your platform, and rename it to `vide` (`v | Windows x64 | [`vide-win32-x64.exe`](https://github.com/pascal-lab/vide/releases/latest/download/vide-win32-x64.exe) | | macOS arm64 | [`vide-darwin-arm64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-darwin-arm64) | | Alpine/musl x64 | [`vide-alpine-x64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-alpine-x64) | -| Alpine/musl arm64 | [`vide-alpine-arm64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-alpine-arm64) | On Linux or macOS, run the following (replace `` with the matching platform name): diff --git a/docs/src/content/docs/en/user-guide/vscode-settings.mdx b/docs/src/content/docs/en/user-guide/vscode-settings.mdx index b68f4730..ab5e8edd 100644 --- a/docs/src/content/docs/en/user-guide/vscode-settings.mdx +++ b/docs/src/content/docs/en/user-guide/vscode-settings.mdx @@ -123,7 +123,7 @@ Related feature: [Formatting](../features/formatting/). ## Inlay Hints -Inlay hints appear directly in the editor and are useful for reading port and parameter connections. +Inlay hints appear directly in the editor and are useful for reading port, parameter, and macro-call connections. Related feature: [Annotations](../features/annotations/). @@ -132,6 +132,7 @@ Related feature: [Annotations](../features/annotations/). settings={[ 'inlayHints.port.connection.enable', 'inlayHints.parameter.assignment.enable', + 'inlayHints.macro.argument.enable', 'inlayHints.end.structure.enable', ]} /> diff --git a/docs/src/content/docs/user-guide/emacs-installation.mdx b/docs/src/content/docs/user-guide/emacs-installation.mdx index b1567b26..2f6d250a 100644 --- a/docs/src/content/docs/user-guide/emacs-installation.mdx +++ b/docs/src/content/docs/user-guide/emacs-installation.mdx @@ -16,7 +16,6 @@ description: 下载 Vide 语言服务器,并配置 Emacs Eglot。 | Windows x64 | [`vide-win32-x64.exe`](https://github.com/pascal-lab/vide/releases/latest/download/vide-win32-x64.exe) | | macOS arm64 | [`vide-darwin-arm64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-darwin-arm64) | | Alpine/musl x64 | [`vide-alpine-x64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-alpine-x64) | -| Alpine/musl arm64 | [`vide-alpine-arm64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-alpine-arm64) | Linux x64 示例: diff --git a/docs/src/content/docs/user-guide/features/annotations.mdx b/docs/src/content/docs/user-guide/features/annotations.mdx index 7c86324d..d3a94e08 100644 --- a/docs/src/content/docs/user-guide/features/annotations.mdx +++ b/docs/src/content/docs/user-guide/features/annotations.mdx @@ -1,6 +1,6 @@ --- title: 代码注解 -description: 在实例连接、结构结尾和模块声明处显示端口、参数、结构名称和实例数量注解。 +description: 在实例连接、宏调用、结构结尾和模块声明处显示端口、参数、结构名称和实例数量注解。 --- import FeatureExample from '../../../../components/FeatureExample.astro'; @@ -12,11 +12,12 @@ import { inlayHintFiles } from '../../../../examples/dailyUse'; 代码注解会把辅助信息直接显示在相关代码旁边,这样不用跳转也能看见当前连接、参数或结构对应的目标。 -目前主要有三类代码注解: +目前主要有四类代码注解: 1. 实例连接注解:在端口连接旁显示目标端口名和方向箭头,`input` 显示 `←`,`output` 显示 `→`,`inout` 显示 `↔`,`ref` 显示 `&`。如果端口名已经写在代码里,Vide 只显示方向箭头,避免重复。 -2. 参数和结构注解:在有序参数赋值旁显示目标参数名,在 `endmodule` 等结构结尾处显示对应结构名。 -3. 实例数量注解:在模块声明上方显示当前模块被实例化的次数。 +2. 参数和宏实参注解:在有序参数赋值旁显示目标参数名,在宏调用实参旁显示对应宏形参名。 +3. 结构注解:在 `endmodule` 等结构结尾处显示对应结构名。 +4. 实例数量注解:在模块声明上方显示当前模块被实例化的次数。 ## 演示 @@ -43,11 +44,11 @@ import { inlayHintFiles } from '../../../../examples/dailyUse'; ### 没有完整配置时 -当前文件内能解析到的端口、参数和结构结尾可以显示注解。跨文件实例连接和实例数量统计依赖 Vide 扫描到的文件,可能不完整。 +当前文件内能解析到的端口、参数、宏实参和结构结尾可以显示注解。跨文件实例连接、include 链里的宏和实例数量统计依赖 Vide 扫描到的文件,可能不完整。 ### 有完整配置时 -写好 `vide.toml` 后,注解会按工程范围解析模块、include 和宏分支。跨文件端口、参数和实例数量统计会更完整。 +写好 `vide.toml` 后,注解会按工程范围解析模块、include 和宏分支。跨文件端口、参数、宏实参和实例数量统计会更完整。 ## 调整显示 @@ -57,6 +58,7 @@ import { inlayHintFiles } from '../../../../examples/dailyUse'; { "vide.inlayHints.port.connection.enable": true, "vide.inlayHints.parameter.assignment.enable": true, + "vide.inlayHints.macro.argument.enable": true, "vide.inlayHints.end.structure.enable": true, "vide.lens.instantiations.enable": true } @@ -64,6 +66,7 @@ import { inlayHintFiles } from '../../../../examples/dailyUse'; - `vide.inlayHints.port.connection.enable`:显示或隐藏实例端口连接旁的端口名和方向箭头。 - `vide.inlayHints.parameter.assignment.enable`:显示或隐藏有序参数赋值旁的参数名。 +- `vide.inlayHints.macro.argument.enable`:显示或隐藏宏调用实参旁的形参名。 - `vide.inlayHints.end.structure.enable`:显示或隐藏 `endmodule` 等结构结尾处的结构名。 - `vide.lens.instantiations.enable`:显示或隐藏模块声明上方的实例数量注解。 diff --git a/docs/src/content/docs/user-guide/features/document-symbols.mdx b/docs/src/content/docs/user-guide/features/document-symbols.mdx index e677aabd..c916680f 100644 --- a/docs/src/content/docs/user-guide/features/document-symbols.mdx +++ b/docs/src/content/docs/user-guide/features/document-symbols.mdx @@ -11,7 +11,7 @@ import { documentSymbolFiles } from '../../../../examples/dailyUse'; ## 什么是符号大纲 -符号大纲把当前文件里的模块、端口、参数、声明、函数、任务、generate 块和区域结构整理成层级。它会出现在 VS Code 的 Outline 面板、面包屑 `转到文件中的符号` 等入口里。 +符号大纲把当前文件里的模块、端口、参数、声明、`struct` / `union` 类型、函数、任务、generate 块和区域结构整理成层级。它会出现在 VS Code 的 Outline 面板、面包屑 `转到文件中的符号` 等入口里。 ## 演示 diff --git a/docs/src/content/docs/user-guide/features/hover.mdx b/docs/src/content/docs/user-guide/features/hover.mdx index bd55b704..03494d2c 100644 --- a/docs/src/content/docs/user-guide/features/hover.mdx +++ b/docs/src/content/docs/user-guide/features/hover.mdx @@ -10,7 +10,7 @@ import { hoverFiles } from '../../../../examples/dailyUse'; ## 什么是悬停信息 -悬停信息是在光标附近显示的轻量解释。把鼠标停在模块名、实例名、端口、参数、任务/函数或数字字面量上,就能在不离开当前文件的情况下确认它的含义。 +悬停信息是在光标附近显示的轻量解释。把鼠标停在模块名、实例名、端口、参数、任务/函数、宏调用或数字字面量上,就能在不离开当前文件的情况下确认它的含义。 ## 演示 @@ -37,8 +37,12 @@ import { hoverFiles } from '../../../../examples/dailyUse'; ### 没有完整配置时 -当前文件里声明的模块、端口、参数和字面量可以直接显示。跨文件目标只有在 Vide 扫描到对应文件,并且能判断出唯一目标时才会显示完整信息。 +当前文件里声明的模块、端口、参数、宏和字面量可以直接显示。跨文件目标只有在 Vide 扫描到对应文件,并且能判断出唯一目标时才会显示完整信息。 ### 有完整配置时 写好 `vide.toml` 后,悬停信息会按工程结构解析 include、宏分支和库文件。实例对应的目标模块、端口方向和参数声明会更完整。 + +## 宏悬停信息 + +对于宏调用,Vide 会尽量显示宏签名、实参绑定、最终展开结果和嵌套展开步骤。宏来自 include 文件或 `vide.toml` 的 `defines` 时,悬停信息会沿用同一套预处理来源信息;受限于当前可获得的预处理信息,展开来源有时可能不够精确,此时 Vide 只会显示可确认的部分。 diff --git a/docs/src/content/docs/user-guide/features/navigation.mdx b/docs/src/content/docs/user-guide/features/navigation.mdx index dc7dac73..586fe4b6 100644 --- a/docs/src/content/docs/user-guide/features/navigation.mdx +++ b/docs/src/content/docs/user-guide/features/navigation.mdx @@ -10,7 +10,7 @@ import { navigationFiles } from '../../../../examples/dailyUse'; ## 什么是定义跳转 -定义跳转让你从一个符号的使用位置跳到它对应的声明或定义。最常见的场景是从模块实例跳到模块定义,从端口连接跳到目标端口,或者从信号使用位置跳到对应声明。 +定义跳转让你从一个符号的使用位置跳到它对应的声明或定义。最常见的场景是从模块实例跳到模块定义,从端口连接跳到目标端口,从信号使用位置跳到对应声明,或者从宏调用跳到宏定义。 你可以通过 VS Code 的 `转到定义`、`查看定义`、`转到声明` 和 `转到类型定义` 使用该功能。其中,`转到声明` 会优先返回声明位置;没有单独声明位置时,会使用定义跳转结果。 @@ -46,3 +46,5 @@ Vide 会根据当前文件和工作区里扫描到的 Verilog/SystemVerilog 文 ### 有完整配置时 写好 `vide.toml` 后,Vide 会按 `sources`、`libraries`、`include_dirs`、`defines` 和 `top_modules` 描述的工程结构解析目标。跨文件跳转、宏分支下的目标和同名模块边界都会更准确。 + +配置在 `vide.toml` 的预定义宏在有明确来源范围时也可以跳回清单文件。 diff --git a/docs/src/content/docs/user-guide/features/quick-fixes.mdx b/docs/src/content/docs/user-guide/features/quick-fixes.mdx index 50d1de65..39b6a018 100644 --- a/docs/src/content/docs/user-guide/features/quick-fixes.mdx +++ b/docs/src/content/docs/user-guide/features/quick-fixes.mdx @@ -1,6 +1,6 @@ --- title: 自动重构 -description: 使用代码操作补齐端口参数、转换连接写法、清理空连接和转换数字进制。 +description: 使用代码操作补齐端口参数、转换连接写法、整理过程块、改写表达式和修复常见语法问题。 --- import Codicon from '../../../../components/Codicon.astro'; @@ -11,7 +11,7 @@ import { missingPortFiles } from '../../../../examples/dailyUse'; ## 什么是自动重构 -自动重构用于处理端口连接、参数赋值和数字字面量进制转换这类重复但容易出错的编辑工作。在 VS Code 中,你可以通过 灯泡菜单触发这些操作,这个入口也叫 Code Actions。 +自动重构用于处理端口连接、参数赋值、过程块、控制流和表达式改写这类重复但容易出错的编辑工作。在 VS Code 中,你可以通过 灯泡菜单触发这些操作,这个入口也叫 Code Actions。 ## 演示 @@ -36,7 +36,9 @@ import { missingPortFiles } from '../../../../examples/dailyUse'; ## 支持的操作 -把光标放到对应实例、数字 literal 或诊断附近,打开灯泡菜单。Vide 目前支持这些常见操作: +把光标放到对应实例、端口列表、过程块、表达式、数字 literal 或诊断附近,打开灯泡菜单。Vide 目前支持这些常见操作: + +### 实例、端口和参数 - `Fill connections`:补齐缺失端口连接。 - `Fill parameters`:补齐缺失参数赋值。 @@ -45,7 +47,30 @@ import { missingPortFiles } from '../../../../examples/dailyUse'; - `Remove empty port connections`:清理多余空端口连接。 - `Add explicit empty port connection`:把 `.port` 改成显式 `.port()`。 - `Add empty instance port list`:给没有端口列表的实例补上空端口列表。 -- `Convert literal to binary/octal/decimal/hexadecimal`:转换整数 literal 进制。 +- `Expand named port shorthand` / `Collapse named port to shorthand`:在 `.ready` 和 `.ready(ready)` 之间转换。 +- `Convert ANSI port declarations to non-ANSI` / `Convert non-ANSI port declarations to ANSI`:在模块头端口声明和模块体端口声明之间转换。 +- `Split declaration`、`Sort named parameter assignments`、`Sort named port connections`:拆分多声明项,并按目标模块顺序整理命名参数或端口连接。 + +### 过程块和控制流 + +- `Convert to always_comb`、`Convert to always_ff`、`Convert to always @(*)`、`Convert to always @(...)`:在兼容的 `always`、`always_comb` 和 `always_ff` 写法之间转换。 +- `Add default case item`:给缺少 `default` 的 `case` 补上默认分支。 +- `Invert if/else`、`Merge nested if`:反转分支,或把嵌套 `if` 合并成一个条件。 +- `Wrap statement in begin/end` / `Unwrap single-statement begin/end`:给控制流语句包上或移除单语句 `begin/end`。 +- `Pull assignment up` / `Pull assignment down`:在 `if/else` 赋值链和三目赋值之间转换。 + +### 表达式和数字 literal + +- `Extract into variable`:把选中的表达式提取成临时变量。 +- `Apply De Morgan's law` / `Factor De Morgan's law`:应用或提取德摩根律。 +- `Remove redundant parentheses`:移除不会改变优先级的多余括号。 +- `Expand compound assignment` / `Collapse compound assignment`:在 `a += b` 和 `a = a + b` 之间转换。 +- 自增、自减、复合赋值和展开赋值可以互相转换,例如在 `count++`、`++count`、`count += 1` 和 `count = count + 1` 之间切换。 +- `Convert literal to binary/octal/decimal/hexadecimal`、`Remove digit separators`:转换整数 literal 进制或清理数字分隔符。 + +### 诊断快速修复 + +- `Insert missing '{token}'`:当解析诊断能识别缺失的括号、分号等 token 时,直接插入缺失 token。 ## 项目配置影响 diff --git a/docs/src/content/docs/user-guide/features/references.mdx b/docs/src/content/docs/user-guide/features/references.mdx index 350887ad..3b4386c4 100644 --- a/docs/src/content/docs/user-guide/features/references.mdx +++ b/docs/src/content/docs/user-guide/features/references.mdx @@ -10,7 +10,7 @@ import { usageFiles } from '../../../../examples/dailyUse'; ## 什么是引用搜索 -引用搜索能够找到选中的符号在哪里被使用。在 SystemVerilog 工程里,它可以用于追模块实例、端口连接、参数和信号的使用位置,也可以配合定义跳转确认一个连接关系是否完整。 +引用搜索能够找到选中的符号在哪里被使用。在 SystemVerilog 工程里,它可以用于追模块实例、端口连接、参数、信号和预处理宏的使用位置,也可以配合定义跳转确认一个连接关系是否完整。 你可以在 VS Code 中执行 `查找所有引用` 或 `查看引用`。Vide 会查找对应符号的使用位置,去重后显示在引用视图里。 @@ -45,6 +45,8 @@ Vide 会在工作区扫描到的所有 Verilog/SystemVerilog 文件中查找引 写好 `vide.toml` 后,引用搜索会按 `sources` 和 `libraries` 描述的工程范围执行,并结合 include 目录和宏定义判断实际参与分析的文件。 +如果宏来自 `vide.toml` 的 `defines`,在清单来源范围可用时,引用结果也会包含清单里的定义位置。 + ## 结果显示 默认情况下,引用结果会把声明位置一起显示,方便你从列表里确认符号是从哪里引入的。如果你只想看真正的使用位置,可以在 VS Code Settings 中写: diff --git a/docs/src/content/docs/user-guide/neovim-installation.mdx b/docs/src/content/docs/user-guide/neovim-installation.mdx index 9d08ce36..1406865d 100644 --- a/docs/src/content/docs/user-guide/neovim-installation.mdx +++ b/docs/src/content/docs/user-guide/neovim-installation.mdx @@ -16,7 +16,6 @@ description: 下载 Vide 语言服务器,并配置 Neovim 内置 LSP。 | Windows x64 | [`vide-win32-x64.exe`](https://github.com/pascal-lab/vide/releases/latest/download/vide-win32-x64.exe) | | macOS arm64 | [`vide-darwin-arm64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-darwin-arm64) | | Alpine/musl x64 | [`vide-alpine-x64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-alpine-x64) | -| Alpine/musl arm64 | [`vide-alpine-arm64`](https://github.com/pascal-lab/vide/releases/latest/download/vide-alpine-arm64) | Linux 或 macOS 可以用以下命令(注意把 `` 替换为对应平台名称): diff --git a/docs/src/content/docs/user-guide/vscode-settings.mdx b/docs/src/content/docs/user-guide/vscode-settings.mdx index 400c9b97..33bcd129 100644 --- a/docs/src/content/docs/user-guide/vscode-settings.mdx +++ b/docs/src/content/docs/user-guide/vscode-settings.mdx @@ -123,7 +123,7 @@ Neovim、Emacs 等编辑器通常通过 LSP 启动 Vide。LSP 是编辑器和语 ## Inlay Hints -行内提示会直接显示在编辑器里,适合日常阅读端口和参数连接。 +行内提示会直接显示在编辑器里,适合日常阅读端口、参数和宏调用。 相关功能:[代码注解](../features/annotations/)。 @@ -132,6 +132,7 @@ Neovim、Emacs 等编辑器通常通过 LSP 启动 Vide。LSP 是编辑器和语 settings={[ 'inlayHints.port.connection.enable', 'inlayHints.parameter.assignment.enable', + 'inlayHints.macro.argument.enable', 'inlayHints.end.structure.enable', ]} /> diff --git a/editors/vscode/package-lock.json b/editors/vscode/package-lock.json index 5e8eaad0..566fe01d 100644 --- a/editors/vscode/package-lock.json +++ b/editors/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "vide-ide", - "version": "1.1.0", + "version": "1.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "vide-ide", - "version": "1.1.0", + "version": "1.2.0", "license": "MIT", "dependencies": { "vscode-languageclient": "^9.0.1" diff --git a/editors/vscode/package.json b/editors/vscode/package.json index a239327c..5c5f0555 100644 --- a/editors/vscode/package.json +++ b/editors/vscode/package.json @@ -2,7 +2,7 @@ "name": "vide-ide", "displayName": "Vide - Verilog/SystemVerilog Coding IDE", "description": "%extension.description%", - "version": "1.1.0", + "version": "1.2.0", "publisher": "pascal-lab", "license": "MIT", "icon": "media/icon.png", diff --git a/editors/vscode/scripts/package/server.ts b/editors/vscode/scripts/package/server.ts index 3908d884..5c22ad02 100644 --- a/editors/vscode/scripts/package/server.ts +++ b/editors/vscode/scripts/package/server.ts @@ -5,6 +5,10 @@ import type { PackageContext } from './context'; import { run } from './process'; import type { BuildProfile, NativeTargetSpec, ServerMode } from './targets'; +const ALPINE_CARGO_TARGETS: Partial> = { + 'alpine-x64': 'x86_64-unknown-linux-musl', +}; + export function ensureTargetServerBinary( context: PackageContext, spec: NativeTargetSpec, @@ -28,7 +32,7 @@ export function ensureTargetServerBinary( } const serverPath = targetServerPath(context, spec); - run('cargo', args, context.repoRoot); + run('cargo', args, context.repoRoot, cargoXtaskEnvForTarget(spec)); if (!fs.existsSync(serverPath)) { throw new Error(`prepared server binary was not found: ${serverPath}`); @@ -63,3 +67,65 @@ export function cleanRuntimeServerFiles(context: PackageContext): void { function targetServerPath(context: PackageContext, spec: NativeTargetSpec): string { return path.join(context.vscodeDir, 'server', spec.target, spec.binaryFile); } + +export function cargoXtaskEnvForTarget( + spec: NativeTargetSpec, + env: NodeJS.ProcessEnv = process.env, +): NodeJS.ProcessEnv { + const cargoTarget = ALPINE_CARGO_TARGETS[spec.target]; + if (!cargoTarget) { + return env; + } + + let updated = env; + const linkerEnvKey = cargoTargetLinkerEnvKey(cargoTarget); + if (!optionalEnv(updated, linkerEnvKey)) { + updated = { + ...updated, + [linkerEnvKey]: cargoLinkerForTarget(cargoTarget, updated), + }; + } + + return appendRustFlags(updated, ['-C', 'link-arg=-lc']); +} + +function cargoTargetLinkerEnvKey(cargoTarget: string): string { + return `CARGO_TARGET_${cargoTargetEnvName(cargoTarget)}_LINKER`; +} + +function cargoTargetEnvName(cargoTarget: string): string { + return cargoTarget.toUpperCase().replace(/-/g, '_'); +} + +function cargoLinkerForTarget(cargoTarget: string, env: NodeJS.ProcessEnv): string { + return ( + optionalEnv(env, cxxCompilerEnvKey(cargoTarget)) ?? + optionalEnv(env, 'TARGET_CXX') ?? + `${cargoTarget}-g++` + ); +} + +function cxxCompilerEnvKey(cargoTarget: string): string { + return `CXX_${cargoTarget.replace(/-/g, '_')}`; +} + +function appendRustFlags(env: NodeJS.ProcessEnv, flags: string[]): NodeJS.ProcessEnv { + const encodedFlags = optionalEnv(env, 'CARGO_ENCODED_RUSTFLAGS'); + if (encodedFlags) { + return { + ...env, + CARGO_ENCODED_RUSTFLAGS: `${encodedFlags}\x1f${flags.join('\x1f')}`, + }; + } + + const rustFlags = optionalEnv(env, 'RUSTFLAGS'); + return { + ...env, + RUSTFLAGS: rustFlags ? `${rustFlags} ${flags.join(' ')}` : flags.join(' '), + }; +} + +function optionalEnv(env: NodeJS.ProcessEnv, name: string): string | undefined { + const value = env[name]?.trim(); + return value ? value : undefined; +} diff --git a/editors/vscode/src/platform.ts b/editors/vscode/src/platform.ts index 7a8447de..0f341f31 100644 --- a/editors/vscode/src/platform.ts +++ b/editors/vscode/src/platform.ts @@ -1,7 +1,6 @@ import * as path from 'node:path'; export const SUPPORTED_PLATFORM_FOLDERS = [ - 'alpine-arm64', 'alpine-x64', 'darwin-arm64', 'linux-arm64', diff --git a/editors/vscode/test/package.test.ts b/editors/vscode/test/package.test.ts index 0f5fce05..caa366f8 100644 --- a/editors/vscode/test/package.test.ts +++ b/editors/vscode/test/package.test.ts @@ -11,7 +11,8 @@ import { stagePackageJsonForTarget, stageProfileTraceAssets, } from '../scripts/package/manifest'; -import { createPackagePlan } from '../scripts/package/targets'; +import { cargoXtaskEnvForTarget } from '../scripts/package/server'; +import { createPackagePlan, type NativeTargetSpec } from '../scripts/package/targets'; describe('package cli', () => { it('keeps the existing debug positional target syntax', () => { @@ -105,6 +106,40 @@ describe('package staging', () => { }); }); +describe('package server preparation', () => { + it('injects Alpine cargo env before cargo xtask is built', () => { + const env = cargoXtaskEnvForTarget(nativeTargetSpec('alpine-x64'), {}); + + assert.equal( + env.CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER, + 'x86_64-unknown-linux-musl-g++', + ); + assert.equal(env.RUSTFLAGS, '-C link-arg=-lc'); + }); + + it('appends Alpine cargo flags to encoded rust flags', () => { + const env = cargoXtaskEnvForTarget(nativeTargetSpec('alpine-x64'), { + CARGO_ENCODED_RUSTFLAGS: '-C\x1ftarget-feature=+crt-static', + CXX_x86_64_unknown_linux_musl: 'custom-x86_64-g++', + }); + + assert.equal(env.CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER, 'custom-x86_64-g++'); + assert.equal( + env.CARGO_ENCODED_RUSTFLAGS, + '-C\x1ftarget-feature=+crt-static\x1f-C\x1flink-arg=-lc', + ); + }); + + it('leaves non-Alpine cargo env untouched', () => { + const baseEnv = { RUSTFLAGS: '-Dwarnings' }; + + assert.equal( + cargoXtaskEnvForTarget(nativeTargetSpec('win32-x64', 'vide.exe'), baseEnv), + baseEnv, + ); + }); +}); + function temporaryPackageContext(): PackageContext { const root = fs.mkdtempSync(path.join(os.tmpdir(), 'vide-package-')); return { @@ -113,6 +148,19 @@ function temporaryPackageContext(): PackageContext { }; } +function nativeTargetSpec( + target: NativeTargetSpec['target'], + binaryFile = 'vide', +): NativeTargetSpec { + return { + kind: 'native', + target, + binaryFile, + isWindows: target.startsWith('win32-'), + removeBrowserEntry: true, + }; +} + describe('package plan', () => { it('models web packages without native server staging', () => { const plan = createPackagePlan({ diff --git a/editors/vscode/test/platform.test.ts b/editors/vscode/test/platform.test.ts index 610884a1..070e243d 100644 --- a/editors/vscode/test/platform.test.ts +++ b/editors/vscode/test/platform.test.ts @@ -11,7 +11,6 @@ import { } from '../src/platform'; test('maps supported Node platform and architecture pairs to VS Code target folders', () => { - assert.equal(getPlatformFolder('alpine', 'arm64'), 'alpine-arm64'); assert.equal(getPlatformFolder('alpine', 'x64'), 'alpine-x64'); assert.equal(getPlatformFolder('darwin', 'arm64'), 'darwin-arm64'); assert.equal(getPlatformFolder('linux', 'arm64'), 'linux-arm64'); @@ -20,6 +19,7 @@ test('maps supported Node platform and architecture pairs to VS Code target fold }); test('rejects unsupported platform and architecture pairs', () => { + assert.equal(getPlatformFolder('alpine', 'arm64'), undefined); assert.equal(getPlatformFolder('darwin', 'x64'), undefined); assert.equal(getPlatformFolder('freebsd', 'x64'), undefined); assert.equal(getPlatformFolder('linux', 'ia32'), undefined); @@ -27,7 +27,7 @@ test('rejects unsupported platform and architecture pairs', () => { }); test('checks package targets with a type guard', () => { - assert.equal(isPlatformFolder('alpine-arm64'), true); + assert.equal(isPlatformFolder('alpine-arm64'), false); assert.equal(isPlatformFolder('alpine-x64'), true); assert.equal(isPlatformFolder('linux-x64'), true); assert.equal(isPlatformFolder('linux-riscv64'), false); diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 42313ace..85c60347 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -115,7 +115,6 @@ enum ExtensionServerMode { #[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] #[value(rename_all = "kebab-case")] enum VscodeServerTarget { - AlpineArm64, AlpineX64, DarwinArm64, LinuxArm64, @@ -126,7 +125,6 @@ enum VscodeServerTarget { impl VscodeServerTarget { fn folder(self) -> &'static str { match self { - VscodeServerTarget::AlpineArm64 => "alpine-arm64", VscodeServerTarget::AlpineX64 => "alpine-x64", VscodeServerTarget::DarwinArm64 => "darwin-arm64", VscodeServerTarget::LinuxArm64 => "linux-arm64", @@ -141,7 +139,6 @@ impl VscodeServerTarget { fn cargo_target(self) -> Option<&'static str> { match self { - VscodeServerTarget::AlpineArm64 => Some("aarch64-unknown-linux-musl"), VscodeServerTarget::AlpineX64 => Some("x86_64-unknown-linux-musl"), _ => None, } @@ -152,7 +149,7 @@ impl VscodeServerTarget { } fn requires_alpine_linker(self) -> bool { - matches!(self, VscodeServerTarget::AlpineArm64 | VscodeServerTarget::AlpineX64) + matches!(self, VscodeServerTarget::AlpineX64) } } @@ -417,7 +414,7 @@ fn run_command( cwd: &Path, env_updates: &[(String, String)], ) -> Result<()> { - let mut child = ProcessCommand::new(command_for_host(command)); + let mut child = ProcessCommand::new(command); child.args(args).current_dir(cwd); for (key, value) in env_updates { child.env(key, value); @@ -434,10 +431,6 @@ fn run_command( Ok(()) } -fn command_for_host(command: &str) -> String { - if cfg!(windows) { format!("{command}.cmd") } else { command.to_owned() } -} - fn workspace_root() -> Result { Path::new(env!("CARGO_MANIFEST_DIR")) .parent()