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

Added command to bind qute.inlayHint.enabled to editor.inlayHints.enabled #517

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions src/qute/commands/commandConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ export namespace QuteClientCommandConstants {
* Client command to execute an XML command on XML Language Server side.
*/
export const EXECUTE_WORKSPACE_COMMAND = 'qute.workspace.executeCommand';

/**
* Bind Qute inlay hint setting to editor inlay hint setting.
*/
export const BIND_QUTE_INLAY_HINT = 'bind.qute.inlayHint.enabled';
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/qute/commands/registerCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function registerVSCodeQuteCommands(context: ExtensionContext) {
registerJavaDefinitionCommand(context);
registerConfigurationUpdateCommand(context);
registerQuteValidationToggleCommand(context);
registerQuteInlayHintBindToEditorSetting(context);
context.subscriptions.push(
workspace.onDidOpenTextDocument((document) => {
updateQuteLanguageId(context, document, true);
Expand Down Expand Up @@ -184,6 +185,20 @@ export function registerConfigurationUpdateCommand(context: ExtensionContext) {
}));
}

export function registerQuteInlayHintBindToEditorSetting(context: ExtensionContext) {
context.subscriptions.push(commands.registerCommand(QuteClientCommandConstants.BIND_QUTE_INLAY_HINT, async () => {
const editorInlayHintSetting = workspace.getConfiguration().get<string>(`editor.inlayHints.enabled`, "on");
if (editorInlayHintSetting === "off") {
const edit = {
value: false,
editType: ConfigurationItemEditType.Add,
section: QuteSettings.QUTE_INLAY_HINT
} as ConfigurationItemEdit;
await commands.executeCommand(QuteClientCommandConstants.COMMAND_CONFIGURATION_UPDATE, edit);
}
}));
}

/**
* Sets the `editorQuteValidationEnabled` based on `qute.command.validation.template.status` and `qute.validation.enabled`.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/qute/languageServer/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export namespace QuteSettings {
*/
export const QUTE_OVERRIDE_LANGUAGE_ID = 'qute.templates.override.languageId';

/**
* Qute inlay hint setting.
*/
export const QUTE_INLAY_HINT = 'qute.inlayHint.enabled';

export function getQuteTemplatesLanguageMismatch(): QuteTemplateLanguageMismatch {
return workspace.getConfiguration().get<QuteTemplateLanguageMismatch>(QUTE_TEMPLATES_LANGUAGE_MISMATCH);
}
Expand Down