This PR adds comprehensive documentation for the Neovim Tinymist plugin, establishing it as the canonical implementation of a Tinymist editor language client. ## Changes Made ### Added `editors/neovim/Specification.md` The specification was a mess, so I the reviewer deleted it. ### Enhanced `editors/neovim/CONTRIBUTING.md` Expanded the contributing guide to document: - **Canonical Implementation Status**: Establishes this as the heavily-documented reference implementation for other editors - **Bootstrap Script Commands**: - `./bootstrap.sh editor` - Interactive editing experience in Docker - `./bootstrap.sh test` - Headless test execution - `./bootstrap.sh bash` - Development shell access - **Test Suite Structure**: Overview of all spec files and their testing purposes - **Contribution Patterns**: Guidelines for maintaining the reference implementation ### Updated `.github/copilot-instructions.md` Added guidance for working with editor integrations: - **Repository Structure**: Notes the Neovim plugin as canonical implementation with documentation links - **Editor Integration Guidelines**: New section specifically for referencing Neovim patterns - **Development Workflow**: References to bootstrap commands and documentation ## Why This Matters The Neovim plugin now serves as the **canonical implementation** that other editor integrations can reference for: - LSP client setup patterns and configuration handling - Event subscription mechanisms for development events - Project resolution modes (singleFile vs lockDatabase) - Export functionality patterns (onSave, onType, never) - Comprehensive test coverage examples This documentation enables maintainers and contributors to understand the complete scope of the Neovim integration and provides a reference for implementing similar functionality in other editors. Fixes #2081. <!-- START COPILOT CODING AGENT TIPS --> --- ✨ Let Copilot coding agent [set things up for you](https://github.com/Myriad-Dreamin/tinymist/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Co-authored-by: Myriad-Dreamin <camiyoru@gmail.com>
4.9 KiB
This is a Rust+JavaScript repository. It builds:
- A Rust binary serves language features:
lsp: Runs language serverdap: Runs debug adapterpreview: Runs preview server
- The JavaScript VS Code extension.
- The lua plugin for Neovim.
It is primarily responsible for providing integrated typst language service to various editors like VS Code, Neovim, Emacs, and Zed. Please follow these guidelines when contributing:
Specialized Instructions
- Localization: See copilot-instructions-l10n.md for comprehensive guidance on adding, updating, and maintaining localization in the project.
Code Standards
Keep Good PR Title
Determine a good PR prefix only by the PR description before work. Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/
Available types:
- dev
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
Required Before Each Commit
- Run
yarn fmtto format Rust/JavaScript files - This will run formatters on all necessary files to maintain consistent style
Development Flow
- Build Server:
cargo build - Build VS Code Extension:
cd editors/vscode && yarn build - Full CI check:
cargo clippy --workspace --all-targets - Test Server:
cargo test --workspace -- --skip=e2eNote that, in the envoironment where network is not available (copilot or nix actions), we should also skip following tests:completion::tests::test_pkgs docs::package::tests::cetz docs::package::tests::fletcher docs::package::tests::tidy docs::package::tests::touying
Repository Structure
crates/: rust crates for the server and related functionalityeditors/vscode/: VS Code extension codeeditors/neovim/: Lua plugin for Neovim (canonical implementation - see CONTRIBUTING.md and Specification.md)tools/editor-tools: utility GUI tools for typsttools/typst-preview-frontend: Preview GUI for typstdocs/: documentation for the projectlocales/: localization files for the entire projecttests/: integration tests for the server and editorssyntaxes/: textmate syntax definitions for typst
Key Guidelines
- Follow Rust and JavaScript best practices and idiomatic patterns
- Maintain existing code structure and organization
- Write unit tests for new functionality. Use snapshot-based unit tests when possible.
- Document public APIs and complex logic in code comments
Editor Integration Guidelines
Neovim Canonical Implementation
The Neovim plugin in editors/neovim/ serves as the canonical implementation of a Tinymist editor language client. When working on editor integrations:
- Reference Implementation: Use the Neovim plugin as the reference for LSP client patterns, configuration handling, and event subscription mechanisms
- Test Suite: Refer to
editors/neovim/spec/for comprehensive test coverage examples - Documentation: See editors/neovim/Specification.md for complete API and functionality documentation
- Development Workflow: Use
./bootstrap.sh editorfor interactive testing and./bootstrap.sh testfor automated validation - Contributing: Follow patterns established in editors/neovim/CONTRIBUTING.md
Development Guidelines
tools/editor-tools
The frontend-side and backend-side can be developed independently. For example, a data object passed from backend to frontend can be coded as van.state<T> as follows:
-
Intermediate arguments:
const documentMetricsData = `:[[preview:DocumentMetrics]]:`; const docMetrics = van.state<DocumentMetrics>( documentMetricsData.startsWith(":") ? DOC_MOCK : JSON.parse(base64Decode(documentMetricsData)), ); -
Server-pushing arguments (e.g.
programTraceintools/editor-tools/src/vscode.ts):export const programTrace = van.state<TraceReport | undefined>(undefined /* init value */); export function setupVscodeChannel() { if (vscodeAPI?.postMessage) { // Handle messages sent from the extension to the webview window.addEventListener("message", (event: any) => { switch (event.data.type) { case "traceData": { programTrace.val = event.data.data; break; } // other cases } }); } } -
Tool request arguments (e.g.
requestSaveFontsExportConfigureintools/editor-tools/src/vscode.ts):export function requestSaveFontsExportConfigure(data: fontsExportConfigure) { if (vscodeAPI?.postMessage) { vscodeAPI.postMessage({ type: "saveFontsExportConfigure", data }); } }
DOC_MOCK is a mock data object for the frontend to display so that the frontend can be developed directly with yarn dev.