Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 83 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"packages/malloy-render",
"packages/malloy-render-validator",
"packages/malloy-syntax-highlight",
"packages/malloy-language-server",
"test",
"profiler"
]
Expand Down
79 changes: 79 additions & 0 deletions packages/malloy-language-server/bin/malloy-language-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/env node

/*
* Copyright Contributors to the Malloy project
* SPDX-License-Identifier: MIT
*/

const args = process.argv.slice(2);

if (args[0] === 'check') {
// One-shot diagnostic mode
const files = [];
let format = 'text';
let globalConfigDir;

for (let i = 1; i < args.length; i++) {
if (args[i] === '--format' && args[i + 1]) {
format = args[i + 1];
i++;
} else if (args[i] === '--global-config-dir' && args[i + 1]) {
globalConfigDir = args[i + 1];
i++;
} else if (!args[i].startsWith('-')) {
files.push(args[i]);
}
}

if (files.length === 0) {
console.error('Usage: malloy-language-server check <file.malloy> [file2.malloy ...] [--format text|json] [--global-config-dir <path>]');
process.exit(1);
}

const {check} = require('../dist/check');
check(files, {format, globalConfigDir}).then((exitCode) => {
process.exit(exitCode);
}).catch((err) => {
console.error(err);
process.exit(1);
});
} else {
// Long-lived LSP server mode (stdio)
const {createConnection, ProposedFeatures} = require('vscode-languageserver/node');
const {createServer, CommonConnectionManager, NodeURLReader} = require('../dist/index');
const os = require('os');
const {pathToFileURL} = require('url');

// Try to load backends (optional)
try { require('@malloydata/malloy-connections'); } catch {}
try { require('@malloydata/db-publisher'); } catch {}

const {ConnectionFactory} = require('../dist/common/connections/types');

const connection = createConnection(ProposedFeatures.all);
const urlReader = new NodeURLReader();
const connectionManager = new CommonConnectionManager(
{}, // Empty factory — backends registered via side-effect imports above
{
expandHome: (path) => path.replace(/^~/, os.homedir()),
pathToFileURL: (path) => pathToFileURL(path),
}
);
connectionManager.setURLReader(urlReader);

// Parse optional flags
let globalConfigDir;
for (let i = 0; i < args.length; i++) {
if (args[i] === '--global-config-dir' && args[i + 1]) {
globalConfigDir = args[i + 1];
i++;
}
}
if (globalConfigDir) {
connectionManager.setGlobalConfigDirectory(globalConfigDir);
} else if (process.env['MALLOY_GLOBAL_CONFIG_DIR']) {
connectionManager.setGlobalConfigDirectory(process.env['MALLOY_GLOBAL_CONFIG_DIR']);
}

createServer(connection, connectionManager, {urlReader});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "malloy-lsp",
"version": "1.0.0",
"description": "Malloy language intelligence for Claude Code — diagnostics, completions, hover, go-to-definition for .malloy files",
"author": {"name": "Malloy Contributors"},
"repository": "https://github.com/malloydata/malloy",
"keywords": ["malloy", "lsp", "data", "sql"]
}
10 changes: 10 additions & 0 deletions packages/malloy-language-server/claude-code-plugin/.lsp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"malloy": {
"command": "malloy-language-server",
"extensionToLanguage": {
".malloy": "malloy",
".malloysql": "malloy-sql",
".malloynb": "malloy-notebook"
}
}
}
55 changes: 55 additions & 0 deletions packages/malloy-language-server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "@malloydata/malloy-language-server",
"version": "0.0.396",
"license": "MIT",
"description": "Malloy Language Server Protocol implementation — diagnostics, completions, hover, go-to-definition for .malloy files",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"bin": {
"malloy-language-server": "./bin/malloy-language-server.js"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./node": {
"types": "./dist/node/index.d.ts",
"default": "./dist/node/index.js"
},
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"index": ["./dist/index.d.ts"],
"node": ["./dist/node/index.d.ts"]
}
},
"engines": {
"node": ">=20"
},
"homepage": "https://github.com/malloydata/malloy#readme",
"repository": {
"type": "git",
"url": "https://github.com/malloydata/malloy"
},
"scripts": {
"build": "tsc --build",
"clean": "tsc --build --clean && rm -f tsconfig.tsbuildinfo"
},
"dependencies": {
"@malloydata/malloy": "0.0.396",
"@malloydata/malloy-sql": "0.0.396",
"@malloydata/malloy-interfaces": "0.0.396",
"@malloydata/render-validator": "0.0.396",
"vscode-languageserver": "^9.0.1",
"vscode-languageserver-textdocument": "^1.0.8",
"vscode-jsonrpc": "^8.1.0",
"vscode-uri": "^3.0.7",
"lodash": "^4.17.21"
},
"optionalDependencies": {
"@malloydata/malloy-connections": "0.0.396",
"@malloydata/db-publisher": "0.0.396"
}
}
Loading
Loading