UNPKG

@intlayer/chokidar

Version:

Scans and builds Intlayer declaration files into dictionaries based on Intlayer configuration.

58 lines (56 loc) 2.32 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const require_runtime = require('./_virtual/_rolldown/runtime.cjs'); let node_path = require("node:path"); node_path = require_runtime.__toESM(node_path); let node_fs = require("node:fs"); //#region src/installLSP.ts const VSCODE_DIR = ".vscode"; const SETTINGS_FILENAME = "settings.json"; const LSP_COMMAND_KEY = "intlayer.languageServer.command"; const LSP_ARGS_KEY = "intlayer.languageServer.args"; const LSP_COMMAND_VALUE = "npx"; const LSP_ARGS_VALUE = ["@intlayer/lsp"]; /** * Writes the Intlayer LSP configuration to `.vscode/settings.json`. * Creates the file (and the `.vscode/` directory) if they don't exist. * Does not overwrite keys that are already present. * * Returns a human-readable summary of what was done plus next-step instructions. */ const installLSP = async (projectRoot) => { const settingsPath = node_path.default.join(projectRoot, VSCODE_DIR, SETTINGS_FILENAME); await node_fs.promises.mkdir(node_path.default.dirname(settingsPath), { recursive: true }); let settings = {}; try { const raw = await node_fs.promises.readFile(settingsPath, "utf-8"); settings = JSON.parse(raw); } catch {} const updated = []; if (!settings[LSP_COMMAND_KEY]) { settings[LSP_COMMAND_KEY] = LSP_COMMAND_VALUE; updated.push(LSP_COMMAND_KEY); } if (!settings[LSP_ARGS_KEY]) { settings[LSP_ARGS_KEY] = LSP_ARGS_VALUE; updated.push(LSP_ARGS_KEY); } await node_fs.promises.writeFile(settingsPath, JSON.stringify(settings, null, 2), "utf-8"); return [ updated.length > 0 ? `Added to ${settingsPath}:\n${updated.map((k) => ` "${k}"`).join("\n")}` : `${settingsPath} already contains the LSP configuration — no changes made.`, "", "Next steps:", "", "1. Install the language server binary (required once):", " npm install -g @intlayer/lsp", "", "2. (Optional) Register the Intlayer Claude Code plugin and enable Go-to-Definition inside Claude Code:", " claude plugin marketplace add intlayer@github:aymericzip/intlayer", " claude plugin install intlayer-lsp@intlayer", " claude plugin enable intlayer-lsp@intlayer", "", "3. Reload your editor window so the new settings take effect." ].join("\n"); }; //#endregion exports.installLSP = installLSP; //# sourceMappingURL=installLSP.cjs.map