From 0539ef85b90aa1d7527a49b860cc851c800abe14 Mon Sep 17 00:00:00 2001 From: Fern Sanchez Date: Tue, 26 Mar 2024 22:42:15 -0400 Subject: [PATCH 1/3] fix: allow server to be used standalone without VS Code extension client --- README.md | 15 +++++++++++++++ build.mjs | 3 ++- server/package.json | 5 ++++- server/server.ts | 3 ++- server/wrapper.ts | 3 +++ 5 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 server/wrapper.ts diff --git a/README.md b/README.md index f51e13b..f1f191f 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,21 @@ 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" + } +} +``` + ### 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/server/package.json b/server/package.json index 5a537e5..4d2f183 100644 --- a/server/package.json +++ b/server/package.json @@ -1,10 +1,13 @@ { - "name": "@markdoc/language-server", + "name": "@fjorn/markdoc-ls", "version": "0.0.12", "description": "A Markdoc language server", "main": "dist/index.js", "author": "Ryan Paul", "license": "MIT", + "bin": { + "markdoc-ls": "dist/wrapper.js" + }, "devDependencies": { "@markdoc/markdoc": "^0.3.3", "@types/picomatch": "^2.3.0", 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(); From 7bdd8f199652a0876426cd6c8a979818d8ba445a Mon Sep 17 00:00:00 2001 From: Fern Sanchez Date: Tue, 26 Mar 2024 22:58:19 -0400 Subject: [PATCH 2/3] build: fix build output to get npm to install markdoc-ls to bin --- README.md | 2 ++ package.json | 3 +++ server/package.json | 3 --- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f1f191f..085de41 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ When using the server standalone without the client VS Code extension you can pa } ``` +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/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/package.json b/server/package.json index 4d2f183..86652f8 100644 --- a/server/package.json +++ b/server/package.json @@ -5,9 +5,6 @@ "main": "dist/index.js", "author": "Ryan Paul", "license": "MIT", - "bin": { - "markdoc-ls": "dist/wrapper.js" - }, "devDependencies": { "@markdoc/markdoc": "^0.3.3", "@types/picomatch": "^2.3.0", From d249382e48917e245d578b72b8ea7a6321a4a5ca Mon Sep 17 00:00:00 2001 From: Fern Sanchez Date: Mon, 1 Apr 2024 19:47:42 -0400 Subject: [PATCH 3/3] build: revert unintended change to server package name --- server/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/package.json b/server/package.json index 86652f8..5a537e5 100644 --- a/server/package.json +++ b/server/package.json @@ -1,5 +1,5 @@ { - "name": "@fjorn/markdoc-ls", + "name": "@markdoc/language-server", "version": "0.0.12", "description": "A Markdoc language server", "main": "dist/index.js",