This repository provides comprehensive language tooling for ArkTS (Ark TypeScript) development in Visual Studio Code and compatible editors. It consists of a VS Code extension (vscode-naily-ets) and a complete language server infrastructure built on the Volar framework, enabling intelligent code editing, navigation, diagnostics, and project management for OpenHarmony and HarmonyOS applications.
For information about specific subsystems:
Sources: README.md1-195 packages/vscode/package.json1-537
ArkTS is the primary programming language for OpenHarmony and HarmonyOS application development. It extends TypeScript with declarative UI syntax, custom annotations, and platform-specific APIs. ArkTS files use the .ets extension and combine standard TypeScript with UI component declarations using decorators like @Component, @State, and @Prop.
This repository provides the tooling infrastructure necessary to develop ArkTS applications outside of DevEco Studio, making VS Code a viable alternative development environment.
Sources: packages/vscode/package.json344-359 README.md22-41
The repository is organized as a pnpm workspace monorepo containing eight published packages and supporting infrastructure:
| Package | Purpose | Published To |
|---|---|---|
vscode-naily-ets | VS Code extension providing UI, commands, and integration | VS Code Marketplace, Open VSX |
@arkts/language-server | LSP server implementation with Volar integration | npm |
@arkts/language-service | Core language features (completion, diagnostics, etc.) | npm |
@arkts/language-plugin | Volar language plugin for virtual code generation | npm |
@arkts/typescript-plugin | TypeScript server plugin for VS Code's built-in TS service | npm (private) |
@arkts/shared | Common utilities and types | npm |
@arkts/types | Type definitions for OpenHarmony configuration files | npm |
@arkts/vfs | Virtual file system implementation | npm |
Additionally, the repository includes:
@arkts/project-detector: Native module (17 platform variants) for analyzing Hvigor projects and resources@ohos-rs/oxk: Rust-based code formatter (15 platform variants)ohos-typescript: Customized TypeScript compiler for ArkTSSources: packages/vscode/package.json1-14 packages/language-server/package.json1-77 packages/language-service/package.json1-81 packages/language-plugin/package.json1-57 packages/typescript-plugin/package.json1-66 packages/shared/package.json1-66 CONTRIBUTING.md1-78
Architecture Overview
The system is organized into five cooperating layers:
Extension Layer (packages/vscode): Entry point at packages/vscode/src/client.ts provides ArkTSExtension class managing:
SdkAnalyzer: Validates SDK paths and generates configurationets.restartServer, ets.installSDK, etc.ResourceExplorer: TreeView UI for browsing project resourcesHdcManager: Webview panel for device managementHvigorAssembleHapTaskProvider, HdcInstallHapTaskProvider, HdcRunAbilityTaskProviderLanguage Server Protocol Layer: Dual communication paths:
LanguageClient communicates with standalone Node.js process running bin/ets-language-server.jsets-typescript-plugin loaded by VS Code's built-in tsserver processLanguage Service Layer (packages/language-service): Core feature implementations:
Resource namespace: ResourceProvider, ResourceResolver for $r() referencesCompletionProvider, DiagnosticProvider, DefinitionProvider, HoverProvider, DocumentLinkProviderLanguageServerConfigManager: Generates TypeScript compiler options from SDK configurationLanguage Plugin Layer (packages/language-plugin): Volar integration:
ETSLanguagePlugin: Implements Volar's createLanguage() interfaceETSVirtualCode: Maps .ets source files to virtual TypeScript with source mappings$$thisFixerPlugin transforms ArkTS-specific constructs using ts-macroExternal Dependencies: Platform-specific and SDK resources:
ohos-typescript: Fork of TypeScript compiler supporting ScriptKind.ETS@ohos-rs/oxk: Rust-based formatter with 15 platform-specific binaries@arkts/project-detector: Rust module with 17 platform-specific binaries for project analysisets/component, ets/build-tools/ets-loader/tsconfig.json, and sysResource.jsSources: packages/vscode/package.json36-502 packages/language-server/package.json1-77 packages/language-service/package.json1-81 packages/language-plugin/package.json1-57 packages/vscode/src/tasks/hvigor-assemble-hap.ts1-79 packages/vscode/src/sdk/sdk-analyzer-exception.ts1-36 packages/language-server/src/classes/config-manager.ts1-278
Volar Framework: The language server is built on @volar/language-core and @volar/language-server, which provide:
Language Server Protocol (LSP): Communication between VS Code and the language server follows the LSP specification, enabling language features like:
textDocument/completiontextDocument/definitiontextDocument/diagnostictextDocument/hovertextDocument/formattingSources: packages/language-server/package.json64-75
$this and @interfaceSources: packages/language-service/package.json63-76 packages/language-server/package.json57-76 README.md36-40
The extension provides comprehensive language support across multiple feature domains:
@ohos-rs/oxk formatter$r('app.string.hello'))build-profile.json5 and local.propertiesets.installSDK commandmodule.json5, build-profile.json5, oh-package.json5, app.json5, and other configuration fileshvigor-assemble-hap, hdc-install-hap, hdc-run-ability task typesSources: packages/vscode/package.json50-519 README.md24-41
The system provides language intelligence through two complementary modes:
The primary mode uses a dedicated language server process:
.ets files, build-profile.json5, or oh-package.json5LanguageClient from vscode-languageclient@arkts/language-serverA complementary mode integrates with VS Code's built-in TypeScript service:
typescriptServerPlugins contribution point in package.json registers ets-typescript-plugintsserver process@arkts/language-plugin for virtual code generationThis dual-mode architecture ensures language features remain available even if the language server fails to start, and allows the extension to work with VS Code's existing TypeScript infrastructure.
Sources: packages/vscode/package.json45-49 packages/vscode/package.json497-502 packages/typescript-plugin/package.json1-66
File: packages/vscode/src/client.ts
Main Class: ArkTSExtension
Activation events trigger extension loading:
The ArkTSExtension class manages:
ets.restartServer → Restarts language server processets.installSDK → Opens SDK installation UIets.createProject → Opens project creation wizardets.resourceExplorer.refresh → Refreshes resource tree viewLanguageClient instance connecting to language servertypescriptServerPlugins contribution pointResourceExplorer (tree view), HdcManager (webview panel)HvigorAssembleHapTaskProvider, HdcInstallHapTaskProvider, HdcRunAbilityTaskProviderSources: packages/vscode/package.json45-49 packages/vscode/src/generated/meta.ts15-69
Package: @arkts/language-server
Binary: bin/ets-language-server.js
Export: Main module at packages/language-server/src/index.ts
Server initialization flow:
createConnection() - Establishes LSP connection (stdio/IPC/socket)createLanguageServer() - Creates Volar language server with:
ETSLanguagePlugin instanceLanguageServerConfigManager for SDK pathsconnection.listen() starts message processingKey configuration class: LanguageServerConfigManager
setSdkPath(), getTsConfig(), getSysResource(), getEtsLoaderConfigCompilerOptions()CompilerOptions from SDK configurationsysResource.js from SDK using createRequire()Sources: packages/language-server/package.json39-41 packages/language-server/src/classes/config-manager.ts10-277
Resource Namespace (@arkts/language-service/src/resource/)
Key classes:
ResourceProvider: Main service providing LSP features for $r() references
provideCompletionItems(), provideDefinition(), provideDiagnostics(), provideHover(), provideDocumentLinks()@arkts/project-detector for resource indexing$r('app.string.hello')) and system resources ($r('sys.color.bg'))ResourceResolver: Parses and resolves resource references
resolveResourceReference() - Parses $r() call expressionsgetResourceLocation() - Maps references to file locations{ uri: URI, range: Range, value: any } for resolved resourcesETSLanguagePlugin (@arkts/language-plugin/src/index.ts)
Implements Volar's LanguagePlugin interface:
createVirtualCode(fileId, languageId, snapshot): Creates ETSVirtualCode instance
.ets source$$thisFixerPlugintypescript.resolveLanguageServiceHost(host): Configures TS host
host.getScriptFileNames()CompilerOptionsETSVirtualCode (@arkts/language-plugin/src/virtual-code.ts)
Represents virtual TypeScript generated from .ets:
mappings: CodeMapping[] - Source position mappingsupdate(snapshot) - Regenerates virtual code when source changesgetContent() - Returns virtual TypeScript stringts-macro to transform $this to this, handle @interface annotationsSources: packages/language-service/package.json24-77 packages/language-plugin/package.json24-56
The extension exposes configuration through VS Code settings API:
| Configuration Key | Type | Purpose | Default |
|---|---|---|---|
ets.sdkPath | string | OpenHarmony SDK path (triggers server restart) | "" |
ets.baseSdkPath | string | Base directory for multiple SDK versions | "${os.homedir}/OpenHarmony" |
ets.hmsPath | string | HMS SDK path (independent of OHOS SDK) | "" |
ets.lspDebugMode | boolean | Enable debug logging in language server | false |
ets.ignoreWorkspaceLocalPropertiesFile | boolean | Skip reading local.properties for SDK path | false |
ets.linterVersion | "1.0" | "1.1" | "off" | ArkTS linter version | "1.1" |
ets.resourceReferenceDiagnostic | "error" | "warning" | "none" | Severity for unresolved $r() | "error" |
ets.localImagePath | string? | Emulator image storage location | Platform-specific |
ets.imageConfigPath | string? | DevEco Studio config path | Platform-specific |
ets.deployedEmulatorPath | string? | Deployed emulator instances | Platform-specific |
ets.emulatorLogPath | string? | Emulator log files location | Platform-specific |
Configuration Usage in Code:
Generated type-safe configuration access via packages/vscode/src/generated/meta.ts87-270:
Configuration Flow:
vscode.workspace.getConfiguration('ets').get('sdkPath')onDidChangeConfiguration eventets.sdkPath, extension calls client.restart() to reload language serverInitializeParams in LSP protocolLanguageServerConfigManager applies config to TypeScript compiler optionsSDK Path Resolution Priority:
local.properties (project root, ignored if ets.ignoreWorkspaceLocalPropertiesFile = true)ets.sdkPath settingets.sdkPath settingSources: packages/vscode/package.json421-496 packages/vscode/src/generated/meta.ts87-270 packages/language-server/src/classes/config-manager.ts61-80
The dependency graph shows:
vscode-naily-ets depends on language server, TypeScript plugin, and native tools@arkts/project-detector and @ohos-rs/oxk are pre-built binariesohos-typescript is the foundation for all language processingSources: packages/language-server/package.json57-76 packages/language-service/package.json63-77 packages/typescript-plugin/package.json53-65 packages/vscode/package.json530-535
The repository uses a sophisticated build pipeline:
The extension supports 10 platform variants:
darwin-arm64, darwin-x64linux-arm64, linux-x64, linux-x64-muslwin32-x64, win32-arm64alpine-arm64, alpine-x64web (browser-based VS Code)Native modules (@arkts/project-detector, @ohos-rs/oxk) are bundled for each platform with pre-built binaries.
@arkts scopeSources: packages/vscode/package.json521-528 CONTRIBUTING.md55-78
For information about setting up a development environment, building the project, and contributing code, see Contributing.
Sources: CONTRIBUTING.md1-78
Refresh this wiki