Real-World Problem: The Editor Tooling Nightmare
Last quarter, our platform team introduced an internal configuration DSL for orchestrating Kubernetes deployments across 14 microservices. Engineers edited these manifests constantly. Unfortunately, subtle syntax slips, mismatched cluster IDs (like typing us-east-1a instead of us-east-1-prod), and missing required fields frequently bypassed local checks. Each slip triggered a failed CI run, costing engineers a 12-minute round-trip delay every time.
To make matters worse, our 18 engineers used three completely different editor environments. Eight worked in VS Code, six lived in Neovim, and four relied on JetBrains GoLand. Building editor-specific tooling meant writing and maintaining three parallel plugins in TypeScript, Lua, and Kotlin. A single schema change would force us to update three separate codebases, test three plugin runtimes, and resolve editor-specific quirks.
Root Cause Analysis: The M × N Matrix Problem
Supporting custom tooling across an engineering team inevitably hits the classic M × N complexity problem. If you support M file formats across N modern editors, you traditionally had to build M × N bespoke integrations.
Each editor exposes its own proprietary runtime architecture:
- VS Code: Relies on a Node.js extension host managing buffers via event emitters.
- Neovim: Runs Lua and Vimscript bindings with buffer-local namespaces and floating popups.
- IntelliJ: Uses a JVM-based Program Structure Interface (PSI) model requiring Java or Kotlin.
Baking AST parsing, type analysis, and documentation lookups into a client-specific extension tightly couples your language logic to that single UI runtime. When your schema shifts, every client plugin breaks in subtle ways.
Solutions Compared: Evaluating Our Tooling Options
We evaluated three potential strategies before settling on an implementation plan.
Option 1: Proprietary Editor Plugins
We prototyped a standalone VS Code extension and a dedicated Neovim Lua script.
- Pros: Immediate access to native editor UI widgets and configuration panels.
- Cons: Doubled our maintenance overhead. Any bug fix in the validator required two parallel PRs across distinct repositories.
- Verdict: Too expensive for a team of our size to maintain.
Option 2: CLI Linter with Git Pre-commit Hooks
We tested running a standalone Node.js CLI script during local pre-commit stages and automated CI runs.
- Pros: One unified codebase and zero editor-specific dependencies.
- Cons: No live feedback while typing. Developers frequently skipped the 4-second hook using
--no-verifywhen rushing hotfixes, which defeated the purpose. - Verdict: Useful as a CI gate, but poor for daily developer ergonomics.
Option 3: Language Server Protocol (LSP) Server
Microsoft designed the Language Server Protocol to cleanly separate editor frontends from language backends. The editor operates strictly as an LSP client. Meanwhile, our TypeScript analysis engine runs as an isolated server process exchanging standard JSON-RPC payloads over stdio.
- Pros: Build the engine once in TypeScript. Every modern editor—VS Code, Neovim, JetBrains (via the LSP plugin), Helix, and Zed—consumes completions, warnings, and hovers automatically.
- Cons: Requires tracking in-memory buffer states and handling asynchronous RPC message cycles.
- Verdict: The most sustainable and extensible architecture for multi-editor teams.
Best Approach: Building an LSP Server with TypeScript
Instead of wrestling with editor plugins, building a lightweight LSP server in TypeScript takes under an afternoon. It gives your entire team immediate auto-completion, real-time validation, and contextual hover documentation regardless of their preferred editor.
Here is how to construct a production-ready server using the official vscode-languageserver package as a standalone Node.js process.
Step 1: Project Initialization
Initialize a new workspace and install the required language server packages:
mkdir custom-lsp-server
cd custom-lsp-server
npm init -y
npm install vscode-languageserver vscode-languageserver-textdocument
npm install -D typescript @types/node ts-node
Set up a tsconfig.json targeting Node 18 or later:
{
"compilerOptions": {
"target": "ES2022",
"module": "commonjs",
"lib": ["ES2022"],
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"]
}
Step 2: Server Scaffold and Connection Handshake
Create src/server.ts. During initialization, the server negotiates supported features with the editor client via an exchange of JSON-RPC capabilities:
import {
createConnection,
TextDocuments,
ProposedFeatures,
InitializeParams,
InitializeResult,
TextDocumentSyncKind,
} from 'vscode-languageserver/node';
import { TextDocument } from 'vscode-languageserver-textdocument';
// Initialize the RPC transport over Node IPC or standard I/O (stdio)
const connection = createConnection(ProposedFeatures.all);
// Manage synchronized document buffers in memory
const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
connection.onInitialize((params: InitializeParams): InitializeResult => {
return {
capabilities: {
// Synchronize only the text ranges that actually changed
textDocumentSync: TextDocumentSyncKind.Incremental,
completionProvider: {
resolveProvider: true,
triggerCharacters: ['.', ':'],
},
hoverProvider: true,
},
};
});
// Bind document buffer events to the active RPC connection
documents.listen(connection);
connection.listen();
Step 3: Implementing Real-Time Diagnostics
Diagnostics mark errors and warnings directly within the active buffer. We register an event listener that parses and validates document contents whenever an engineer makes an edit:
import {
Diagnostic,
DiagnosticSeverity,
} from 'vscode-languageserver/node';
documents.onDidChangeContent((change) => {
validateTextDocument(change.document);
});
async function validateTextDocument(textDocument: TextDocument): Promise<void> {
const text = textDocument.getText();
const diagnostics: Diagnostic[] = [];
// Rule: Warn against deprecated "legacy" cluster targets
const pattern = /cluster_type:\s*legacy/g;
let match: RegExpExecArray | null;
while ((match = pattern.exec(text)) !== null) {
const startPos = textDocument.positionAt(match.index);
const endPos = textDocument.positionAt(match.index + match[0].length);
diagnostics.push({
severity: DiagnosticSeverity.Warning,
range: {
start: startPos,
end: endPos,
},
message: '"legacy" cluster type is deprecated. Migrate to "cloud-native".',
source: 'infra-lsp',
});
}
// Dispatch diagnostic markers back to the editor client
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}
Step 4: Providing Context-Aware Auto-Completion
When an engineer pauses or types a trigger character, the editor requests suggestions at the current cursor offset:
import {
CompletionItem,
CompletionItemKind,
TextDocumentPositionParams,
} from 'vscode-languageserver/node';
connection.onCompletion(
(textDocumentPosition: TextDocumentPositionParams): CompletionItem[] => {
return [
{
label: 'service_mesh',
kind: CompletionItemKind.Property,
data: 1,
detail: 'Enable Istio service mesh configuration',
},
{
label: 'replicas',
kind: CompletionItemKind.Field,
data: 2,
detail: 'Integer count of desired pod instances',
},
{
label: 'health_check_path',
kind: CompletionItemKind.Keyword,
data: 3,
detail: 'HTTP endpoint probed by ingress controllers',
},
];
}
);
// Lazy-load rich markdown details only when an item is selected
connection.onCompletionResolve((item: CompletionItem): CompletionItem => {
if (item.data === 1) {
item.documentation = 'Controls sidecar injection and strict mTLS policies.';
} else if (item.data === 2) {
item.documentation = 'Default value is 2. Production deployments require at least 3 replicas.';
}
return item;
});
Step 5: Adding Hover Information
Hover handlers deliver Markdown-rendered explanations directly under the cursor:
import {
Hover,
HoverParams,
MarkupKind,
} from 'vscode-languageserver/node';
connection.onHover((params: HoverParams): Hover | null => {
const document = documents.get(params.textDocument.uri);
if (!document) return null;
const offset = document.offsetAt(params.position);
const text = document.getText();
const word = getWordAtOffset(text, offset);
if (word === 'service_mesh') {
return {
contents: {
kind: MarkupKind.Markdown,
value: '**service_mesh**: Enables automatic Envoy sidecar injection.\n\n*Example:* `service_mesh: enabled`',
},
};
}
return null;
});
function getWordAtOffset(text: string, offset: number): string {
const left = text.slice(0, offset).search(/[a-zA-Z0-9_]+$/);
const right = text.slice(offset).search(/[^a-zA-Z0-9_]/);
if (left === -1) return '';
const end = right === -1 ? text.length : offset + right;
return text.slice(left, end);
}
Step 6: Connecting Any Editor Client
Compile the TypeScript code to JavaScript:
npx tsc
You can now attach any LSP-compliant editor directly. In Neovim 0.8+, configure a standard filetype autocommand using vim.lsp.start:
vim.api.nvim_create_autocmd("FileType", {
pattern = "customconf",
callback = function()
vim.lsp.start({
name = "custom-lsp",
cmd = { "node", "/path/to/custom-lsp-server/dist/server.js", "--stdio" },
root_dir = vim.fs.dirname(vim.fs.find({ ".git" }, { upward = true })[1]),
})
end,
})
For VS Code, wrap the Node executable in a lightweight extension wrapper using vscode-languageclient/node. In JetBrains IDEs, bind the command to your custom file extension in the LSP settings.
By shifting intelligence into a single standalone server, we eliminated repetitive configuration errors across all teams. One codebase now powers autocompletion and schema validation across every editor we support.

