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

Add formatter #46

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
7 changes: 7 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ export function activate(context: ExtensionContext) {

const conf = vscode.workspace.getConfiguration('ttcn3');

vscode.languages.registerDocumentFormattingEditProvider('ttcn3', {
provideDocumentFormattingEdits(document: vscode.TextDocument) {
child_process.exec(`ntt format --in-place "${document.uri.fsPath}`);
return [];
}
});

// Our work is done, if the user does not want to run a language server.
if (!conf.get('useLanguageServer') && !conf.get('server.enabled')) {
outputChannel.appendLine('Language server is disabled. If you like to use features like go to definition, enable the language server by opening vscode settings and set ttcn3.useLanguageServer to true. For more information about the TTCN-3 language server, have a look at https://nokia.github.io/ntt/editors/');
Expand Down