XU XUv0.16.0

VS Code / Cursor Editor Support

To provide developers with a modern, responsive editing experience, the official Xu ecosystem maintains an editor extension in the standalone vscode-xu repository, natively supporting both Visual Studio Code and Cursor IDE. The extension is driven by high-fidelity TextMate grammar definitions and the compiler's self-hosted Language Server Protocol (LSP) engine.

1. Core Language Server Capabilities

Powered by the compiler's built-in xu lsp (and companion tool xu-lsp), the extension provides the following language services, with the current query and edit scopes described below:

Feature Keybinding (macOS / Win) Capabilities & Details
Syntax Highlighting Real-time Precise TextMate grammar aligned with official lexer rules, coloring keywords, control flow, types ($, struct, chan), statement symbols (<<, >>>, <<<, ->, <-), and annotations (@main).
Live Diagnostics As-you-type squiggles Continuous background type-checking and borrow-checker verification, surfacing compile errors and type mismatches directly inline.
Go to Definition F12 / Cmd+Click Instantly navigates to declarations of structs, functions, global constants, methods, and interface implementations—including transparent navigation into standard library source files.
Hover Tooltips Mouse hover Hovering over any identifier reveals exact type signatures, mutability flags ($), and Markdown-formatted documentation comments.
IntelliSense Completion Ctrl+Space Completion suggestions come mainly from keywords, built-in functions, and declarations in the current file. Semantic completion for member chains and external packages is limited.
Find All References Shift+F12 Matches identifier text in the current file and sibling .xu files in the same directory. Results may include unrelated symbols with the same spelling.
Rename Symbol Refactoring F2 Produces edits only for the current file using identifier text matching. Review the edit preview, including unrelated symbols with the same spelling; update other files separately.
Document Outline & Breadcrumbs Cmd+Shift+O / Ctrl+Shift+O Hierarchical outline listing all structs, enums, and functions in the current file with fast fuzzy-search filtering.
Workspace Symbols Cmd+T / Ctrl+T workspace/symbol을 통해 워크스페이스 전체의 심볼을 검색하여 프로젝트 전역으로 빠르게 이동합니다.
Quick-Fix Code Actions Cmd+. / Ctrl+. 지원 중단된 or 오류 핸들러를 >>>로 마이그레이션하거나 불변 바인딩에 $ 가변성을 추가하는 등 textDocument/codeAction 빠른 수정을 제공합니다.
Format on Save Cmd+S / Ctrl+S Invokes the production xu fmt tool on file save, ensuring 100% consistent team code formatting and indentation.

워크스페이스 심볼 및 빠른 수정 코드 액션 (0.15.0)

Xu 0.15.0부터 xu-lsp는 두 가지 추가 LSP 기능(workspaceSymbolProvider 및 codeActionProvider)을 제공합니다:

2. Installation Methods

Method A: Install from VSIX Archive (Recommended)

Unpack the Xu 0.16.0 SDK and open its editors/vscode/ directory. It includes xu-language-0.3.0.vsix; the extension version is independent of the compiler version. Install through the CLI or editor UI:

# Install in VS Code via terminal
code --install-extension xu-language-0.3.0.vsix

# Install in Cursor via terminal
cursor --install-extension xu-language-0.3.0.vsix

Alternatively, open the Extensions panel in VS Code or Cursor, click the ... menu in the upper right, choose Install from VSIX..., select the downloaded file, and click Reload Window.

Method B: Build from Source

To contribute to the extension or test unreleased features, build directly from the git repository:

# Clone the official repository
git clone https://github.com/xulang-org/vscode-xu.git
cd vscode-xu

# Install dependencies and package VSIX
npm ci
npm run package

# Install the freshly built package
code --install-extension xu-language-*.vsix

Press Cmd+Shift+P (macOS) or Ctrl+Shift+P (Windows/Linux), select Preferences: Open User Settings (JSON), and add the following configuration:

{
  // Path to the Xu compiler binary ("xu" if in your system PATH)
  "xu.languageServerPath": "xu",

  // Language server trace logging level ("off", "messages", or "verbose")
  "xu.trace.server": "off",

  // Xu language specific editor settings
  "[xu]": {
    "editor.defaultFormatter": "xu-lang.xu-language",
    "editor.formatOnSave": true,
    "editor.tabSize": 4,
    "editor.insertSpaces": true,
    "editor.suggestOnTriggerCharacters": true,
    "editor.quickSuggestions": {
      "other": true,
      "comments": false,
      "strings": true
    }
  }
}

4. Keyboard Shortcuts Cheat Sheet

Action macOS Shortcut Windows / Linux Shortcut Description
Go to Definition F12 or Cmd+Click F12 or Ctrl+Click Navigate to the declaration of a function, struct, or variable
Find All References Shift+F12 Shift+F12 List identifier matches in the current file and same-directory Xu files
Rename Symbol F2 F2 Preview identifier replacements in the current file
Document Outline Cmd+Shift+O Ctrl+Shift+O Fuzzy search functions, structs, and symbols in the active file
Format Document Option+Shift+F Alt+Shift+F Format the active document using xu fmt
Trigger Completion Ctrl+Space Ctrl+Space Manually display IntelliSense completion suggestions

Open Source & Independence: The official extension is open-sourced under the MIT License. The independent vscode-xu repository evolves independently from the compiler core while remaining 100% synchronized with the latest grammar specification.