Skip to content
Merged
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
22 changes: 14 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,11 @@
"contributes": {
"configuration": {
"properties": {
"ty.path": {
"default": [],
"markdownDescription": "Path to a custom `ty` executable, e.g., `[\"/path/to/ty\"]`.",
"scope": "resource",
"items": {
"type": "string"
},
"type": "array"
"python.ty.disableLanguageServices": {
"default": false,
"markdownDescription": "Whether to disable all language services for ty like completions, hover, goto definition, etc.",
"scope": "window",
"type": "boolean"
},
"ty.experimental.completions.enable": {
"default": false,
Expand Down Expand Up @@ -130,6 +127,15 @@
"scope": "application",
"type": "string"
},
"ty.path": {
"default": [],
"markdownDescription": "Path to a custom `ty` executable, e.g., `[\"/path/to/ty\"]`.",
"scope": "resource",
"items": {
"type": "string"
},
"type": "array"
},
"ty.trace.server": {
"type": "string",
"enum": [
Expand Down
24 changes: 24 additions & 0 deletions src/common/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ type Experimental = {
};
};

type PythonSettings = {
ty?: {
disableLanguageServices?: boolean;
};
};

export interface ISettings {
cwd: string;
workspace: string;
Expand All @@ -27,6 +33,7 @@ export interface ISettings {
logLevel?: LogLevel;
logFile?: string;
experimental?: Experimental;
python?: PythonSettings;
}

export function getExtensionSettings(namespace: string): Promise<ISettings[]> {
Expand Down Expand Up @@ -82,6 +89,20 @@ export function getInterpreterFromSetting(namespace: string, scope?: Configurati
return config.get<string[]>("interpreter");
}

function getPythonSettings(workspace?: WorkspaceFolder): PythonSettings | undefined {
const config = getConfiguration("python", workspace?.uri);
const disableLanguageServices = config.get<boolean>("ty.disableLanguageServices");
if (disableLanguageServices !== undefined) {
return {
ty: {
disableLanguageServices,
},
};
} else {
return undefined;
}
}

export async function getWorkspaceSettings(
namespace: string,
workspace: WorkspaceFolder,
Expand All @@ -106,6 +127,7 @@ export async function getWorkspaceSettings(
logLevel: config.get<LogLevel>("logLevel"),
logFile: config.get<string>("logFile"),
experimental: config.get<Experimental>("experimental"),
python: getPythonSettings(workspace),
};
}

Expand All @@ -130,6 +152,7 @@ export async function getGlobalSettings(namespace: string): Promise<ISettings> {
logLevel: getOptionalGlobalValue<LogLevel>(config, "logLevel"),
logFile: getOptionalGlobalValue<string>(config, "logFile"),
experimental: getOptionalGlobalValue<Experimental>(config, "experimental"),
python: getPythonSettings(),
};
}

Expand All @@ -144,6 +167,7 @@ export function checkIfConfigurationChanged(
`${namespace}.logLevel`,
`${namespace}.logFile`,
`${namespace}.experimental.completions.enable`,
"python.ty.disableLanguageServices",
];
return settings.some((s) => e.affectsConfiguration(s));
}
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
await runServer();
}),
onDidChangeConfiguration(async (e: vscode.ConfigurationChangeEvent) => {
// TODO(dhruvmanila): Notify the server with `DidChangeConfigurationNotification` and let
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you plan to work on this as part of the client settings issue where you also want to explore a pull configuration model.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

// the server pull in the updated configuration.
if (checkIfConfigurationChanged(e, serverId)) {
await runServer();
}
Expand Down