Skip to content

Commit

Permalink
feat: Bun-based language server (DEV only) (#2604)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Apr 11, 2023
1 parent 9a3059a commit b16292c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
8 changes: 5 additions & 3 deletions packages/vscode-vue/client.js
@@ -1,3 +1,5 @@
let modulePath = './dist/client';
try { modulePath = require.resolve('./out/nodeClientMain'); } catch { }
module.exports = require(modulePath);
try {
module.exports = require('./out/nodeClientMain');
} catch { }

module.exports = require('./dist/client');
8 changes: 5 additions & 3 deletions packages/vscode-vue/server.js
@@ -1,3 +1,5 @@
let modulePath = './dist/server';
try { modulePath = require.resolve('@volar/vue-language-server/bin/vue-language-server'); } catch { }
module.exports = require(modulePath);
try {
module.exports = require('@volar/vue-language-server/bin/vue-language-server');
} catch { }

module.exports = require('./dist/server');
25 changes: 24 additions & 1 deletion packages/vscode-vue/src/nodeClientMain.ts
Expand Up @@ -49,7 +49,7 @@ export function activate(context: vscode.ExtensionContext) {
runOptions.execArgv.push("--max-old-space-size=" + maxOldSpaceSize);
}
const debugOptions: lsp.ForkOptions = { execArgv: ['--nolazy', '--inspect=' + port] };
const serverOptions: lsp.ServerOptions = {
let serverOptions: lsp.ServerOptions = {
run: {
module: serverModule.fsPath,
transport: lsp.TransportKind.ipc,
Expand All @@ -61,6 +61,29 @@ export function activate(context: vscode.ExtensionContext) {
options: debugOptions
},
};
const bunPath: string | undefined = undefined; // path to .bun/bin/bun
if (bunPath) {
serverOptions = {
run: {
transport: {
kind: lsp.TransportKind.socket,
port: port + 10,
},
options: runOptions,
command: bunPath,
args: ['run', serverModule.fsPath],
},
debug: {
transport: {
kind: lsp.TransportKind.socket,
port: port + 10,
},
options: debugOptions,
command: bunPath,
args: ['run', serverModule.fsPath],
},
};
}
const clientOptions: lsp.LanguageClientOptions = {
middleware,
documentSelector: langs.map<lsp.DocumentFilter>(lang => ({ language: lang })),
Expand Down

0 comments on commit b16292c

Please sign in to comment.