A language server that provides IDE features for Cap'n Proto schema files, including go-to-definition and automatic recompilation.
- Supported OS: Linux, macOS
- CMake
- Cap'n Proto libraries (version 1.1.0 or higher)
You have two options for building the language server:
If you already have Cap'n Proto installed on your system:
cmake -B build .
cmake --build buildWith this option, you must specify the compilerPath in the initialization options.
If you don't have Cap'n Proto installed or prefer a self-contained build:
cmake -B build -DUSE_BUNDLED_CAPNP_TOOL=ON .
cmake --build buildWith this option, the compilerPath in the initialization options becomes optional.
This automatically downloads and installs Cap'n Proto, which is guaranteed to be compatible with the language server.
The executable for the language server is located at build/capnp-ls in both cases.
The language server requires the following initialization options:
{
"initializationOptions": {
"capnp": {
"compilerPath": "/path/to/capnp",
"importPaths": [
"path/to/schema/imports"
]
}
}
}Required fields:
compilerPath: The path to the Cap'n Proto compiler executable.- When built with
-DUSE_BUNDLED_CAPNP_TOOL=ON, this path is optional as the bundled compiler will be used by default.
- When built with
importPaths: An array of import paths for Cap'n Proto schemas.- When multiple import paths are provided, they are searched in the specified order, similar to how the Cap'n Proto compiler operates.
- Enables navigation to the definition of types, enums, and other symbols in Cap'n Proto schema files.
- Automatically recompiles schemas when files are saved.
- Symbol resolution for imports (e.g.,
import "/common.capnp") currently requires opening the imported file first. - Limited support for single workspace folders.
- Autocomplete feature that includes ordinals
- Formatting feature
- Windows support
The samples directory contains a complete VSCode extension that demonstrates how to use this language server. For details about the extension, see samples/README.md.
- Build the language server (see above)
- Set up the extension:
cd samples npm install npm run compile - Launch the extension in debug mode:
- Run "Launch Client" from the Run/Debug view
You can customize the sample workspace by modifying the second argument in the launch configuration's args array:
"args": [
"--extensionDevelopmentPath=${workspaceRoot}/samples",
"/absolute/path/to/your/workspace" // Change this path
]