English | 简体中文
Better support for the Kiwi message format in Visual Studio Code.
Forked from connorskees/kiwi-lsp, which published on VSCode Marketplace, identified by connorskees.kiwi-lsp.
The original plugin provides the following features:
- TextMate-based syntax highlighting
- Basic language configuration (including comments, bracket matching, etc.)
- Code intelligence
- Go to definition
- Go to references
- Auto-completion
- Find all references
- Code Lens support
- Hover documentation
- Basic code checking
- Quick fixes
- Auto-correct case errors
- Generate next available ID for messages (especially useful for large messages with hundreds of fields)
The original plugin's code analysis functionality was limited to the currently open file. When cross-file references existed (e.g., derived.kiwi referencing types from enum.kiwi, base-1.kiwi, and base-2.kiwi), the existing functionality couldn't properly support this usage, resulting in code checking errors.
To address this, this plugin introduces a syntax that uses /// @include filename.kiwi at the beginning of the file to include other kiwi files. Example:
/// @include ../enum.kiwi
/// @include "./base-1.kiwi"
/// @include './base-2.kiwi'
- Must be placed at the beginning of the content, ignoring whitespace characters like line breaks. Can have multiple lines, but placing it elsewhere is invalid (treated as comments)
- Valid
/// @include ../enum.kiwi // Valid /// @include "./base-1.kiwi" // Valid with empty line - Invalid
message Rect {} /// @include './base-1.kiwi' // Invalid, because there's content before message Vector {}
- Valid
- Must start with
/// @include - File paths support both absolute and relative paths
- Filenames can be wrapped in
''or"", or without quotes - Filenames are case-sensitive
- Multiple inclusions are imported only once, similar to
#pragma once
To adapt this syntax, the project implements the following features on top of the original plugin:
- Clicking on
@includefiles enables jumping to the corresponding file - When opening a
.kiwifile, the plugin parses valid@includedirectives, concatenates dependent file contents to the current file for parsing, effectively declaring all dependencies in the current file @includedirectives only affect file parsing, content concatenation only occurs during parsing, warnings and errors still correspond to the current file- Code Actions: Unaffected, providing correct suggestions
- Go to Definition: Clicking on types enables jumping to the corresponding code in the original file
- Auto-completion: After supporting
@includedirectives, types from referenced files are added to the candidate list
See the fixtures/intellisense/ directory, which contains test data for the language service.
The dependency relationships in the intellisense/ folder are as follows: package/derived.kiwi depends on enum.kiwi, package/base-1.kiwi, and package/base-2.kiwi. derived.kiwi uses types from enum.kiwi, base-1.kiwi, and base-2.kiwi. During parsing, the content of the three dependent files is added to the beginning of derived.kiwi.
enum.kiwi \
package/base-1.kiwi ----> package/derived.kiwi
package/base-2.kiwi /
The original project only used tsc to compile code without a bundler. When packaging the plugin with vsce, the following prompt was received:
This extension consists of 590 files, out of which 341 are JavaScript files. For performance reasons, you should bundle your extension: https://aka.ms/vscode-bundle-extension
....
kiwi-vscode-1.0.3.vsix (590 files, 759.55KB)This project implements build optimizations:
- Uses
tsupas the build tool - Uses
pnpm workspaceto manageserver/andclient/modules
The optimized build output is as follows:
client build: CJS out/extension.js 1.02 KB
client build: CJS ⚡️ Build success in 27ms
client build: Done
server build: CJS out/server.js 19.45 KB
server build: CJS ⚡️ Build success in 111ms
...
kiwi-vscode-1.0.3.vsix (11 files, 131.39 KB)The compressed plugin package size is reduced by 80%, and the extracted files are more streamlined.
The Logo was generated by Slea.ai using the following prompt:
a vector logo design, with the text "Kiwi", main symbol: messages, binary, code, programming language, the background is circular, Minimalistic, be used in Internet industry, clear background.
