Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Vide Developer Documentation

This directory contains development and maintainer documentation for the Vide repository.

*If you are a user of Vide, please refer to the [User Guide](https://vide.pascal-lab.net/user-guide/).*

- [Developer Guide](developer-guide.md)
- [Setup](setup.md)
- [Core Language Server](lsp/README.md)
- [Website](website.md)
- [VS Code Extension](vscode.md)
- [CI](ci.md)
- [slang-sys](slang-sys.md)
3 changes: 3 additions & 0 deletions docs/ci.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CI

TODO
4 changes: 4 additions & 0 deletions docs/developer-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Developer Guide

TODO

15 changes: 15 additions & 0 deletions docs/lsp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Vide Language Server Architecture

Vide keeps LSP protocol mechanics in `crates/vide-lsp-runtime`. The runtime owns typed request
and notification routing, request lifecycle and cancellation, server-to-client requests, response
encoding, retries, and accepted-response effects.

`GlobalState` contains Vide's mutable language state. Read-only requests run against a
`GlobalStateSnapshot`; notifications and explicitly mutable requests run on the main loop. VFS and
background compiler events remain domain events handled by the main loop rather than protocol
concerns.

Native stdio and browser/WASM are transport adapters over the same runtime router. The native
adapter blocks on stdio and internal channels. The browser adapter pushes JSON messages into the
same router and drains outgoing messages through its FFI polling surface. Neither adapter contains
request handlers or a second dispatch implementation.
4 changes: 4 additions & 0 deletions docs/setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Setup

TODO

46 changes: 46 additions & 0 deletions docs/slang-sys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# slang-sys

`slang-sys` is the Rust FFI boundary for the Slang C++ library. It is intended to replace the old `slang` crate as the FFI interface used
by Vide crates.

Unlike old `slang` crate, `slang-sys` doesn't vendored or edit the upstream slang repository. Instead, it uses `git submodule` to reference the upstream slang and provides rust bindings inside the crate, this will not only avoid introducing bugs into slang code base but also make it easier to keep up with the latest slang version. You can find the submodule in `third_party/slang` directory.

## slang integration
Since slang is written in C++, and use some trick to generate code when compiling itself, we need to use some special procedure to build slang library and linked it with `slang-sys` crate. You can find the details in [build.rs](../crates/slang-sys/build.rs).

Here is a brief summary of the build procedure:
1. Generate rust definitions from slang IDL files (for example, [syntax.txt](../third_party/slang/scripts/syntax.txt)). The build scripts will call generator scripts (under `../crates/slang-sys/scripts/` directory), and emit rust code into `OUT_DIR` directory. When you navigate around the slang-sys source code, you may jump to the `target/` directory occasionally, that's where the generated rust code is located. :)

2. Build slang library. The build script will call `cmake` to build the slang library, and install it into `OUT_DIR` directory.

3. Generate cxx bridge code. Since we rely on `cxx` crate to provide C++ FFI support, we need to generate cxx bridge code (C++) for the FFI functions and types defined in the `**/ffi.rs` files.

4. Linking all the things together.

## Development
### Setup
To develop `slang-sys`, you need to follow the steps below:

1. Since slang-sys need slang source code to build, you need to initialize the submodule first:
```bash
git submodule update --init
```

2. You need to make sure you have the full C++ toolchain installed and is available in your `PATH`, including:
- clang/clang++ (MSVC on windows)
- cmake
- ninja
- python3
- rust toolchain (YOU MUST HAVE IT, RIGHT?)

3. For better developer experience, we recommend you to install `clangd`. If you have installed it, it should read `.clangd` and `.clang-format` files correctly and automatically provide right IDE features in the `.cpp/.h` files inside this crate and `third_party/slang` codebase after you build the slang-sys crates.

### Edit slang-sys
If you want to edit slang-sys, for example, add new FFI functions, here are some tips for you:

1. Conventionally, we put FFI definitions and C++ wrapper files inside the corresponding module directory, for example, `diagnostic/ffi.rs`, `diagnostic/wrapper.h`, `diagnostic/wrapper.cpp` are all related to diagnostic module. It will be better to follow this convention since it will improve the readability for FFI code.

2. If you add more FFI file / C++ wrapper file / C++ header file, you need to add them into the `FFI_FILES` / `WRAPPER_HEADERS` / `WRAPPER_SOURCES` in the [build.rs](../crates/slang-sys/build.rs) file, otherwise they will not be compiled and linked correctly.

### Update slang version
Theoretically, you can just update the submodule version, everything should work. **Don't forget to update the crate version of slang-sys, it should be aligned with the slang version.**
3 changes: 3 additions & 0 deletions docs/vscode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# VS Code Extension

TODO
22 changes: 22 additions & 0 deletions docs/website.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Website

This is the development document for the website module (`website/`).

## Development
If you want to run the website locally, you can do so by following the steps below.
1. **Install emscripten**. If you have emscripten installed, you can skip this step.

The playground needs [emscripten](https://emscripten.org/index.html) to build the wasm module. You can follow the [official guide](https://emscripten.org/docs/getting_started/downloads.html) to install it.

> Don't forget to activate the emscripten environment by running `source /path/to/emsdk/emsdk_env.sh` in your terminal.

2. **Setup dependencies**.
This will automatically install all the npm dependencies and build the vide wasm lsp.
```bash
npm run setup
```

3. **Run the website**.
```bash
npm run dev
```
Loading