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

drop down menu does not contain a formatter entry #22

Open
jimp02 opened this issue May 29, 2020 · 0 comments
Open

drop down menu does not contain a formatter entry #22

jimp02 opened this issue May 29, 2020 · 0 comments
Assignees

Comments

@jimp02
Copy link

jimp02 commented May 29, 2020

The drop down menu does not contain a formatter entry for format-astyle. The problem seems to be you are not registering it as a formatter with vscode.languages.registerDocumentFormattingEditProvider(language, formatter).

Following is an example from the VS Code AStyle extension. It needs to be added to your extension at the appropriate place:

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
function activate(context) {
let formatter = new AstyleFormatter();
let additionalLanguages = vscode.workspace.getConfiguration('astyle')['additional_languages'] || [];

["c", "cpp", "objective-c", "csharp", "java"].concat(additionalLanguages).forEach(function (language) {
    let config = vscode.workspace.getConfiguration('astyle')[language];

    if (config && !config.enable) {
        return;
    }

    let disposable = vscode.languages.registerDocumentFormattingEditProvider(language, formatter);
    context.subscriptions.push(disposable);
});

context.subscriptions.push(formatter);

}

@WiRight WiRight self-assigned this Jul 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants