diff --git a/README.md b/README.md index f51e13b..085de41 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,23 @@ The JSON configuration file consists of an array of server instance descriptions - The `routing` property is an optional object that describes your project's routing configuration - The `frontmatter` property is a string that tells the extension which property in the Markdoc file's YAML frontmatter contains the URL route associated with the file +### Standalone Server Configuration + +When using the server standalone without the client VS Code extension you can pass the configuration object to your LSP client like so: + +```json +{ + "root": "/path/to/project/root", + "path": "relative/path/to/markdoc/files", + "config": { + "root": "/path/to/project/root", + "path": "relative/path/to/markdoc/files" + } +} +``` + +Invoke the server with `markdoc-ls --stdio` from within your LSP client. + ### File extensions In order to distinguish Markdoc files from Markdown files, the Visual Studio Code extension expects Markdoc files to use one of the following file extensions: `.markdoc`, `.markdoc.md`, or `.mdoc`. diff --git a/build.mjs b/build.mjs index 6055bf5..53ddabc 100644 --- a/build.mjs +++ b/build.mjs @@ -2,12 +2,13 @@ import {context, build} from 'esbuild'; const config = { bundle: true, - entryPoints: ['client/index.ts', 'server/index.ts', 'client/server.ts'], + entryPoints: ['client/index.ts', 'server/index.ts', 'server/wrapper.ts', 'client/server.ts'], outdir: 'dist', sourcemap: 'linked', external: ['vscode'], platform: 'node', format: 'cjs', + banner: { js: '#!/usr/bin/env node' }, }; if (process.argv.includes('--watch')) { diff --git a/package.json b/package.json index 1289cd6..6b15cb8 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,9 @@ "url": "https://github.com/markdoc/language-server.git" }, "main": "./dist/client/index.js", + "bin": { + "markdoc-ls": "dist/server/wrapper.js" + }, "scripts": { "build": "node build.mjs", "build:watch": "node build.mjs --watch", diff --git a/server/server.ts b/server/server.ts index b3c5619..d3dd032 100644 --- a/server/server.ts +++ b/server/server.ts @@ -29,8 +29,9 @@ export function connect( }); return new Promise((resolve) => { - connection.onInitialized(() => resolve(options)); + const options = connection.onInitialized(() => resolve(options)); connection.listen(); + return options }); } diff --git a/server/wrapper.ts b/server/wrapper.ts new file mode 100644 index 0000000..3a86e95 --- /dev/null +++ b/server/wrapper.ts @@ -0,0 +1,3 @@ +import { server } from './server'; + +server();