This module implements a Language Server Protocol (LSP) server for NPL.
The language server can operate in two modes:
- TCP mode: Listens on a specified port (default: 5007)
- STDIO mode: Communicates through standard input/output
You'll need Maven and Java 24 (graalvm if you want to build binaries) or later installed on your system.
mvn clean verifyTo test the language server with VS Code:
-
Run the
Main::mainfunction in TCP mode within IntelliJ:- Navigate to
com.noumenadigital.npl.lang.server.Main - Edit the run configuration to include
--tcpas a program argument - Run the main function
- Navigate to
-
Set up the VS Code extension:
- Clone the extension repository:
git clone git@github.com:NoumenaDigital/npl-vscode-extension.git- (Check that you're using an appropriate branch for your purposes)
- Open the project in VS Code
- Install dependencies with
npm install
- Clone the extension repository:
-
Run the extension:
- Navigate to
extension.ts - Press F5 to start running the extension in instrumented mode
- Navigate to
-
Test functionality:
- Open an NPL project (such as npl-starter)
- Make changes to NPL files and interact with your codebase
You can use pre-commit to run some automated checks as well as Kotlin (ktlint) and Markdown formatting whenever you
commit something.
brew install pre-commit
pre-commit installThe checks can be bypassed by running git commit -n or git commit --no-verify
Enforces accidental secret commits with a pre-commit hook using Yelp's detect-secrets tool. The pre-commit hook will scan staged changes for potential secrets before allowing a commit. If any secrets are detected above baseline, the commit will be aborted, ensuring that no sensitive information is pushed to the repository.
No need to install locally, just make sure you have the pre-commit hook installed.
To check locally:
pre-commit run detect-secrets --all-filesTo generate a new baseline, install the version of detect-secrets that's configured in .pre-commit-config.yaml
locally (using pip or brew -- just double check that you have the right version) and run:
detect-secrets scan > .secrets.baselineThis project enforces a standard code formatting style using ktlint via the
automatic pretty-format-kotlin pre-commit hook.
The pretty-format-kotlin hook automatically formats Kotlin code with ktlint rules before committing it.
You can run ktlint for the entire project using the pre-commit like so:
pre-commit run pretty-format-kotlin --all-filesWe use prettier to format our Markdown. The configuration is found in .prettierrc.yml.
To format all Markdown files in the project, run (needed if e.g. the corresponding job is failing):
pre-commit run prettier --all-filesNote that prettier formats tables differently than IntelliJ, so you might want to disable IntelliJ's
Incorrect table formatting Markdown inspection.
The language server can be compiled to a native executable using GraalVM's native-image. This creates a standalone binary that users can run without installing a JRE or any other dependencies.
- Install GraalVM JDK 24 or later
- Build the native executable:
mvn -Pnative package
./target/language-serverThe language server uses GraalVM's native-image for creating standalone executables. To generate the necessary configuration files:
-
Run the configuration generator script:
-
Manual generation:
bash ./generate-native-configs.shThis script will: - Build a fat jar with all dependencies - Run the language server with the native-image-agent - Generate configuration files in `src/main/resources/META-INF/native-image` -
Maven generation
mvn clean verify -Pconfig-gen
-
-
While the server is running, interact with it through your IDE or client to exercise different code paths. The agent will automatically collect metadata about classes, methods, and resources used at runtime.
-
Once you've exercised the desired functionality, stop the server (Ctrl+C). The generated configurations will be saved in the
src/main/resources/META-INF/native-imagedirectory. -
After generating configurations, you can build the native image using:
mvn -Pnative package
If you encounter issues with the native image, you may need to manually modify the generated configuration files. Refer to the GraalVM documentation for more information on native image configuration.