Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support pyright-langserver from python package #1086

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
36 changes: 23 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,34 @@ export async function activate(context: ExtensionContext): Promise<void> {
window.showWarningMessage('coc-python is installed and activated, coc-pyright will be disabled');
return;
}

const runOptions = { execArgv: [`--max-old-space-size=${defaultHeapSize}`] };
const debugOptions = { execArgv: ['--nolazy', '--inspect=6600', `--max-old-space-size=${defaultHeapSize}`] };

let serverOptions: ServerOptions;

let module = pyrightCfg.get<string>('server');
if (module) {
module = which.sync(workspace.expand(module), { nothrow: true }) || module;
const serverBin = which.sync(workspace.expand(module), { nothrow: true }) || module;
if (!existsSync(serverBin)) {
window.showErrorMessage(`Pyright langserver ${serverBin} doesn't exist`);
return;
}
serverOptions = {
run: { command: serverBin, args: [...runOptions.execArgv, '--stdio'] },
debug: { command: serverBin, args: [...debugOptions.execArgv, '--stdio'] },
};
} else {
module = join(context.extensionPath, 'node_modules', 'pyright', 'langserver.index.js');
serverOptions = {
run: { module: module, transport: TransportKind.ipc, options: runOptions },
debug: { module: module, transport: TransportKind.ipc, options: debugOptions },
};
if (!existsSync(module)) {
window.showErrorMessage(`Pyright langserver doesn't exist, please reinstall coc-pyright`);
return;
}
}
if (!existsSync(module)) {
window.showErrorMessage(`Pyright langserver doesn't exist, please reinstall coc-pyright`);
return;
}

const runOptions = { execArgv: [`--max-old-space-size=${defaultHeapSize}`] };
const debugOptions = { execArgv: ['--nolazy', '--inspect=6600', `--max-old-space-size=${defaultHeapSize}`] };

const serverOptions: ServerOptions = {
run: { module: module, transport: TransportKind.ipc, options: runOptions },
debug: { module: module, transport: TransportKind.ipc, options: debugOptions },
};

const disabledFeatures: string[] = [];
if (pyrightCfg.get<boolean>('disableCompletion')) {
Expand Down
Loading