Skip to content

Commit c0ab0d7

Browse files
kinto0meta-codesync[bot]
authored andcommitted
disable based pyright language services if installed
Summary: if pyrefly is installed and language services are enabled, turn off basedpyright language services to not conflict Reviewed By: migeed-z Differential Revision: D88676060 fbshipit-source-id: bd18df9a1d533e410198aba628253306d229ff76
1 parent 69985d1 commit c0ab0d7

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

lsp/src/extension-interop.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,18 @@ export async function disableWindsurfPyrightIfInstalled() {
4949
await config.update(setting, true, vscode.ConfigurationTarget.Global);
5050
}
5151
}
52+
53+
/**
54+
* This function checks if the Based Pyright extension is installed, and if so,
55+
* disables its language services to avoid conflicts with Pyrefly.
56+
*/
57+
export async function disableBasedPyrightIfInstalled() {
58+
const basedPyrightExtension = vscode.extensions.getExtension(
59+
'detachhead.basedpyright',
60+
);
61+
if (basedPyrightExtension) {
62+
const config = vscode.workspace.getConfiguration('basedpyright');
63+
const setting = 'disableLanguageServices';
64+
await config.update(setting, true, vscode.ConfigurationTarget.Global);
65+
}
66+
}

lsp/src/extension.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {runDocstringFoldingCommand} from './docstring';
2727
import {
2828
triggerMsPythonRefreshLanguageServers,
2929
disableWindsurfPyrightIfInstalled,
30+
disableBasedPyrightIfInstalled,
3031
} from './extension-interop';
3132

3233
let client: LanguageClient;
@@ -235,6 +236,14 @@ export async function activate(context: ExtensionContext) {
235236
// Disable Windsurf Pyright language services if the extension is installed
236237
await disableWindsurfPyrightIfInstalled();
237238

239+
// Disable Based Pyright language services if the extension is installed and Pyrefly is enabled
240+
const pyreflyDisabled = vscode.workspace
241+
.getConfiguration('python.pyrefly')
242+
.get<boolean>('disableLanguageServices', false);
243+
if (!pyreflyDisabled) {
244+
await disableBasedPyrightIfInstalled();
245+
}
246+
238247
// Start the client. This will also launch the server
239248
await client.start();
240249

0 commit comments

Comments
 (0)