<commit_before>import * as vscode from 'vscode';
import { FormattingEditProvider } from './format';
import { validateCommand } from './validate';
import { lintCommand } from './lint';
import { liveIndex } from './live';
import { initializeIndex } from './index';
import { CompletionProvider } from './providers';

export let errorDiagnosticCollection = vscode.languages.createDiagnosticCollection("terraform-error");
export let outputChannel = vscode.window.createOutputChannel("Terraform");

export function activate(ctx: vscode.ExtensionContext) {
    ctx.subscriptions.push(errorDiagnosticCollection);

    let formattingProvider = new FormattingEditProvider;

    // we need to manually handle save events otherwise format on autosave does not work
    ctx.subscriptions.push(vscode.workspace.onDidSaveTextDocument((doc) => formattingProvider.onSave(doc)));
    vscode.languages.registerDocumentFormattingEditProvider('terraform', formattingProvider);

    ctx.subscriptions.push(vscode.workspace.onDidChangeTextDocument(liveIndex));

    ctx.subscriptions.push(vscode.commands.registerCommand('terraform.validate', () => { validateCommand(); }));
    ctx.subscriptions.push(vscode.commands.registerCommand('terraform.lint', () => { lintCommand(); }));

    ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider("terraform", new CompletionProvider, '.', '"'));

    // index operations
    initializeIndex(ctx);
}<commit_msg>Restricting language services to local files<commit_after>import * as vscode from 'vscode';
import { FormattingEditProvider } from './format';
import { validateCommand } from './validate';
import { lintCommand } from './lint';
import { liveIndex } from './live';
import { initializeIndex } from './index';
import { CompletionProvider } from './providers';

export let errorDiagnosticCollection = vscode.languages.createDiagnosticCollection("terraform-error");
export let outputChannel = vscode.window.createOutputChannel("Terraform");

const documentSelector: vscode.DocumentSelector = [
    { language: "terraform", scheme: "file" },
    { language: "terraform", scheme: "untitled" }
];

export function activate(ctx: vscode.ExtensionContext) {
    ctx.subscriptions.push(errorDiagnosticCollection);

    let formattingProvider = new FormattingEditProvider;

    // we need to manually handle save events otherwise format on autosave does not work
    ctx.subscriptions.push(vscode.workspace.onDidSaveTextDocument((doc) => formattingProvider.onSave(doc)));
    vscode.languages.registerDocumentFormattingEditProvider(documentSelector, formattingProvider);

    ctx.subscriptions.push(vscode.workspace.onDidChangeTextDocument(liveIndex));

    ctx.subscriptions.push(vscode.commands.registerCommand('terraform.validate', () => { validateCommand(); }));
    ctx.subscriptions.push(vscode.commands.registerCommand('terraform.lint', () => { lintCommand(); }));

    ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(documentSelector, new CompletionProvider, '.', '"'));

    // index operations
    if (vscode.workspace.rootPath) {
        initializeIndex(ctx);
    }
}
{'fraction_non_alphanumeric': 0.12543887647622087, 'fraction_numerical': 0.0, 'mean_word_length': 5.725321888412017, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4464828', 'n_tokens_mistral': 851, 'n_tokens_neox': 844, 'n_words': 168}