Registry /
devops / purescript-language-server
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
createConnection
✓ import { createConnection } from 'purescript-language-server'
✗ import createConnection from 'purescript-language-server'
This function is primarily used by developers building custom LSP clients or integrations, or extending the server itself, rather than by end-users in typical application code. The package is predominantly consumed as an executable.
PurescriptConnection
✓ import type { PurescriptConnection } from 'purescript-language-server'
This is a TypeScript interface representing the LSP connection object, useful for type-checking when creating custom LSP client implementations or extending the server. It is not for direct runtime instantiation by end-users.
Capabilities
✓ import type { Capabilities } from 'purescript-language-server'
This TypeScript interface defines the server's advertised LSP capabilities (e.g., supported features for completion, formatting). It's primarily for clients to understand the server's functionality programmatically, not for typical end-user library consumption.
Demonstrates how to programmatically launch the `purescript-language-server` as a child process using Node.js, simulating how an editor plugin might interact with it via `stdio` for basic IPC. This is a common pattern for integrating language servers into custom environments or tools.
import { spawn } from 'child_process';
import * as path from 'path';
// Path to the purescript-language-server executable
// Assuming it's installed globally or accessible via node_modules/.bin
// Adjust 'serverPath' if installed locally and 'node_modules/.bin' isn't in PATH, or globally.
const serverPath = path.resolve(__dirname, '../../node_modules/.bin/purescript-language-server');
const serverProcess = spawn(serverPath, ['--stdio'], {
cwd: process.cwd(), // Set this to the root of your PureScript project
stdio: ['pipe', 'pipe', 'pipe'] // stdin, stdout, stderr for IPC
});
console.log('PureScript Language Server launched via child_process.');
// Log server output for debugging (in a real client, this would be parsed as LSP messages)
serverProcess.stdout.on('data', (data) => {
const message = data.toString();
// LSP messages start with Content-Length header, followed by JSON payload.
if (message.includes('Content-Length')) {
console.log('LSP Server seems to be sending a message via STDOUT.');
} else {
// For non-LSP output (e.g., initial logs), just print it.
console.log(`[LSP Server STDOUT]: ${message.trim()}`);
}
});
serverProcess.stderr.on('data', (data) => {
console.error(`[LSP Server STDERR]: ${data.toString().trim()}`);
});
serverProcess.on('close', (code) => {
console.log(`PureScript Language Server exited with code ${code}`);
});
serverProcess.on('error', (err) => {
console.error(`Failed to start LSP server: ${err.message}`);
});
// Implement graceful shutdown on Node.js process exit
process.on('SIGINT', () => {
console.log('Detected SIGINT. Shutting down LSP server...');
// A proper LSP shutdown involves sending an 'exit' notification
const exitNotification = JSON.stringify({ jsonrpc: '2.0', id: null, method: 'exit' });
const contentLength = Buffer.byteLength(exitNotification, 'utf8');
const exitMessage = `Content-Length: ${contentLength}\r\n\r\n${exitNotification}`;
serverProcess.stdin.write(exitMessage);
serverProcess.stdin.end(); // Close stdin after sending the message
serverProcess.kill(); // Ensure the process is terminated
process.exit();
});
// In a real LSP client, you would send an 'initialize' request to serverProcess.stdin
// For this quickstart, we'll keep the server alive for a few seconds then trigger a shutdown.
setTimeout(() => {
console.log('Demonstration complete. Triggering graceful shutdown.');
process.emit('SIGINT', 'SIGINT'); // Trigger the SIGINT handler
}, 8000); // Keep server alive for 8 seconds for observation
purescript-language-server --version
Errors
Common errors & fixes
command not found: purescript-language-server
The `purescript-language-server` executable is not installed globally or is not discoverable in the system's PATH.
fixInstall the package globally using `npm i -g purescript-language-server`. If installed locally, ensure your shell's PATH includes `$(npm bin)` or `node_modules/.bin`.
Language server failed to start or client unable to connect.
Mismatch in communication methods between the LSP client and the `purescript-language-server` (e.g., client expects `--stdio` but server is configured for `--socket`).
fixVerify that your LSP client's configuration for `purescript-language-server` matches the server's expected communication method (e.g., `--stdio`, `--socket=[port]`, `--node-ipc`, or `--pipe`).
Formatting request failed or code not formatted as expected.
The selected formatter tool (e.g., `purs-tidy`, `pose`, `purty`) is either not installed, not in the system's PATH, or the `purescript.formatter` setting is incorrect.
fixInstall your desired formatter globally (e.g., `npm i -g purs-tidy`) or locally. Ensure the formatter is in your PATH. Check your LSP client's settings to confirm `purescript.formatter` is set correctly and `purescript.addNpmPath` is enabled if using a local formatter.
Audit
Dependencies
purs ide serverrequiredThe language server wraps and depends on the functionality of the `purs ide server`, which is part of the PureScript compiler distribution. It is effectively a peer dependency.
Node.jsrequiredRequired runtime environment as specified by `engines.node: ">=14"` in package.json.