export async function activate(context: vscode.ExtensionContext) {  
    telemetry.init();

    telemetry.traceEvent('activate');

    g_lscrashreportingpipename = telemetry.startLsCrashServer();

    g_context = context;

    console.log('Activating extension language-julia');

    g_settings = settings.loadSettings();

    // Status bar
    g_serverstatus = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
    g_serverstatus.show()
    g_serverstatus.text = 'Julia';
    context.subscriptions.push(g_serverstatus);

    // Config change
    context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(configChanged));

    // Language settings
    vscode.languages.setLanguageConfiguration('julia', {
        indentationRules: {
            increaseIndentPattern: /^(\s*|.*=\s*|.*@\w*\s*)[\w\s]*\b(if|while|for|function|macro|immutable|struct|type|let|quote|try|begin|.*\)\s*do|else|elseif|catch|finally)\b(?!.*\bend\b[^\]]*$).*$/,
            decreaseIndentPattern: /^\s*(end|else|elseif|catch|finally)\b.*$/
        }
    });

    // Active features from other files
    juliaexepath.activate(context, g_settings);
    repl.activate(context, g_settings);
    weave.activate(context, g_settings);
    tasks.activate(context, g_settings);
    smallcommands.activate(context, g_settings);
    packagepath.activate(context, g_settings);
    openpackagedirectory.activate(context, g_settings);
    jlpkgenv.activate(context, g_settings);

    // Start language server
    startLanguageServer();

    if (vscode.workspace.getConfiguration('julia').get<boolean>('enableTelemetry')===null) {
        vscode.window.showInformationMessage("To help improve the julia extension, you can anonymously send usage statistics to the team. See our [privacy policy](https://github.com/JuliaEditorSupport/julia-vscode/wiki/Privacy-Policy) for details.", 'Yes, I want to help improve the julia extension')
            .then(telemetry_choice => {
                if (telemetry_choice == "Yes, I want to help improve the julia extension") {
                    vscode.workspace.getConfiguration('julia').update('enableTelemetry', true, true);
                }
            });
    }
}
	constructor() {
		this._inNormalMode = new ContextKey('vim.inNormalMode');
		this._hasInput = new ContextKey('vim.hasInput');
		this._statusBar = new StatusBar();

		this._controller = new Controller()

		vscode.window.onDidChangeActiveTextEditor((textEditor) => {
			if (!textEditor) {
				return;
			}
			this._ensureState();
		});

		vscode.window.onDidChangeTextEditorSelection((e) => {
			let isVisual = this._controller.getVisual();

			if (!isVisual) {
				// a selection in the editor brings us to visual mode
				let goToVisualMode = false;

				if (e.selections.length > 1) {
					goToVisualMode = true;
				} else {
					goToVisualMode = !e.selections[0].isEmpty;
				}

				if (goToVisualMode) {
					this._controller.setVisual(true);
				}
			} else {
				// a collapsed selection in the editor brings us to normal mode
				let leaveVisualMode = false;
				if (e.selections.length === 1) {
					leaveVisualMode = e.selections[0].isEmpty;
				}
				if (leaveVisualMode) {
					this._controller.setVisual(false);
				}
			}

			this._ensureState();
		});

		var ensureConfig = () => {
			this._controller.setWordSeparators(getConfiguredWordSeparators());
		};
		ensureConfig();
		vscode.workspace.onDidChangeConfiguration(ensureConfig);

		this._ensureState();
	}
Example #3
0
export function activate(context: vscode.ExtensionContext) {
	const telemetryReporter = loadDefaultTelemetryReporter();
	context.subscriptions.push(telemetryReporter);

	const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState);
	const engine = new MarkdownEngine();
	const logger = new Logger();

	const selector = 'markdown';

	const contentProvider = new MarkdownContentProvider(engine, context, cspArbiter, logger);
	loadMarkdownExtensions(contentProvider, engine);

	const webviewManager = new MarkdownPreviewWebviewManager(contentProvider);
	context.subscriptions.push(webviewManager);

	context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(selector, new MDDocumentSymbolProvider(engine)));
	context.subscriptions.push(vscode.languages.registerDocumentLinkProvider(selector, new LinkProvider()));

	const previewSecuritySelector = new PreviewSecuritySelector(cspArbiter, webviewManager);

	const commandManager = new CommandManager();
	context.subscriptions.push(commandManager);
	commandManager.register(new commands.ShowPreviewCommand(webviewManager, telemetryReporter));
	commandManager.register(new commands.ShowPreviewToSideCommand(webviewManager, telemetryReporter));
	commandManager.register(new commands.ShowSourceCommand());
	commandManager.register(new commands.RefreshPreviewCommand(webviewManager));
	commandManager.register(new commands.RevealLineCommand(logger));
	commandManager.register(new commands.MoveCursorToPositionCommand());
	commandManager.register(new commands.ShowPreviewSecuritySelectorCommand(previewSecuritySelector));
	commandManager.register(new commands.OnPreviewStyleLoadErrorCommand());
	commandManager.register(new commands.DidClickCommand());
	commandManager.register(new commands.OpenDocumentLinkCommand(engine));

	context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
		logger.updateConfiguration();
		webviewManager.updateConfiguration();
	}));

	context.subscriptions.push(vscode.window.onDidChangeTextEditorSelection(event => {
		if (isMarkdownFile(event.textEditor.document)) {
			const markdownFile = getMarkdownUri(event.textEditor.document.uri);
			logger.log('updatePreviewForSelection', { markdownFile: markdownFile.toString() });

			vscode.commands.executeCommand('_workbench.htmlPreview.postMessage',
				markdownFile,
				{
					line: event.selections[0].active.line
				});
		}
	}));
}
Example #4
0
export function activate(context: vscode.ExtensionContext) {
  // To make us VS Code agnostic outside of this file
  const pluginSettings = getExtensionSettings()
  const jestPath = pathToJest(pluginSettings)
  const configPath = pathToConfig(pluginSettings)
  const currentJestVersion = 20
  const workspace = new ProjectWorkspace(pluginSettings.rootPath, jestPath, configPath, currentJestVersion)

  // Create our own console
  const channel = vscode.window.createOutputChannel('Jest')

  // We need a singleton to represent the extension
  extensionInstance = new JestExt(workspace, channel, pluginSettings)

  const languages = [
    { language: 'javascript' },
    { language: 'javascriptreact' },
    { language: 'typescript' },
    { language: 'typescriptreact' },
  ]
  context.subscriptions.push(
    registerStatusBar(channel),
    vscode.commands.registerTextEditorCommand(`${extensionName}.start`, () => {
      vscode.window.showInformationMessage('Started Jest, press escape to hide this message.')
      extensionInstance.startProcess()
    }),
    vscode.commands.registerTextEditorCommand(`${extensionName}.stop`, () => extensionInstance.stopProcess()),
    vscode.commands.registerTextEditorCommand(`${extensionName}.show-channel`, () => {
      channel.show()
    }),
    ...registerSnapshotCodeLens(pluginSettings.enableSnapshotPreviews),
    ...registerSnapshotPreview(),
    ...registerCoverageCodeLens(extensionInstance),
    registerToggleCoverageOverlay(pluginSettings.showCoverageOnLoad),
    vscode.commands.registerCommand(`${extensionName}.run-test`, extensionInstance.runTest),
    vscode.languages.registerCodeLensProvider(languages, extensionInstance.debugCodeLensProvider),
    vscode.workspace.onDidChangeConfiguration(e => {
      if (e.affectsConfiguration('jest')) {
        const updatedSettings = getExtensionSettings()
        extensionInstance.triggerUpdateSettings(updatedSettings)
      }
    }),

    vscode.workspace.onDidCloseTextDocument(document => {
      extensionInstance.onDidCloseTextDocument(document)
    }),

    vscode.window.onDidChangeActiveTextEditor(extensionInstance.onDidChangeActiveTextEditor, extensionInstance),
    vscode.workspace.onDidChangeTextDocument(extensionInstance.onDidChangeTextDocument, extensionInstance)
  )
}
Example #5
0
export function activate(context: vscode.ExtensionContext) {

    let editorOpt: IVSCodeEditorOptions;
    let vimOpt: IVimStyleOptions;
    function loadConfiguration() {
        let conf = vscode.workspace.getConfiguration("vimStyle");
        editorOpt = {
            showMode: conf.get<boolean>("showMode", true),
            changeCursorStyle: conf.get<boolean>("changeCursorStyle", true)
        };
        vimOpt = {
            useErgonomicKeyForMotion: conf.get<boolean>("useErgonomicKeyForMotion", false),
            editorKeyBindings: VSCodeEditorKeyBindngs
        };
    }
    loadConfiguration();

    let editor = new VSCodeEditor(editorOpt);
    context.subscriptions.push(editor);
    let vim = new VimStyle(editor, vimOpt);

    let disposable = vscode.workspace.onDidChangeConfiguration(() => {
        loadConfiguration();
        vim.ApplyOptions(vimOpt);
        editor.ApplyOptions(editorOpt);
    });
    context.subscriptions.push(disposable);
    disposable = vscode.window.onDidChangeActiveTextEditor((textEditor) => {
        editor.ChangePositionByUser();
    });
    context.subscriptions.push(disposable);
    disposable = vscode.window.onDidChangeTextEditorSelection((textEditor) => {
        editor.ChangePositionByUser();
    });
    context.subscriptions.push(disposable);

    context.subscriptions.push(vscode.commands.registerCommand("type", (args) => {
        if (!vscode.window.activeTextEditor) {
            return;
        }
        if (vim.GetMode() === VimMode.Insert) {
            vscode.commands.executeCommand("default:type", args);
        }
        vim.PushKey(args.text);
    }));
    context.subscriptions.push(vscode.commands.registerCommand("vim.Esc", () => {
        vim.PushEscKey();
    }));

    vim.PushEscKey();
}
Example #6
0
export function activate(context: vscode.ExtensionContext) {

    var copyHolder = new Copy;
    var _statusBarHandler = new StatusBarHandler;
    var paste = new Paste;

    let keys = 9;
    let copyCommands = [];
    let pasteCommands = [];

    for (let index = 0; index < keys; index++) { //build the 10 copy commands. Can't pass data into commands to this seems like the best way?
        let copyName = 'copy ' + index;
        let pasteName = 'paste ' + index;

        let copyCmd = vscode.commands.registerCommand(copyName, () => {
            copyHolder.saveHighlight(copyName);
            _statusBarHandler.updateStatusBar(copyHolder);

        })
        copyCommands.push(copyCmd);

        let pasteCmd = vscode.commands.registerCommand(pasteName, () => {
            paste.pasteText(copyName, copyHolder);
        })
        pasteCommands.push(copyCmd);

    }



    vscode.workspace.onDidChangeConfiguration(() => {
        //show statusBarHandler setting
        var settings = vscode.workspace.getConfiguration('scc.setting');
        if (settings.has('showStatusBar')) {            
            _statusBarHandler.showstatusBar = settings.get('showStatusBar') as boolean;
            _statusBarHandler.updateStatusBar(copyHolder);
        }
        else{
            _statusBarHandler.showstatusBar = true;
            _statusBarHandler.updateStatusBar(copyHolder);
        }


    });


    let disposable: any = [...copyCommands];

    context.subscriptions.push(disposable);
}
Example #7
0
export function activate(context: ExtensionContext) {
	registerCommands(context);

	diagnosticCollection = languages.createDiagnosticCollection('npm-script-runner');
	context.subscriptions.push(diagnosticCollection);

	workspace.onDidChangeConfiguration(_event => loadConfiguration(context), null, context.subscriptions);
	loadConfiguration(context);

	outputChannel = window.createOutputChannel('npm');
	context.subscriptions.push(outputChannel);

	context.subscriptions.push(languages.registerCodeActionsProvider('json', new NpmCodeActionProvider()));
}
export function activate(context: ExtensionContext): void {
    setLogLevel();
    workspace.onDidChangeConfiguration(setLogLevel);

    // The server is implemented in node
    let serverModule = context.asAbsolutePath(path.join('server', 'src', 'server.js'));
    // The debug options for the server
    let debugOptions = { execArgv: ['--nolazy', '--debug=6004'] };

    // If the extension is launch in debug mode the debug server options are use
    // Otherwise the run options are used
    let serverOptions: ServerOptions = {
        run : { module: serverModule, transport: TransportKind.ipc },
        debug: { module: serverModule, transport: TransportKind.ipc, options: debugOptions }
    };

    // Options to control the language client
    let clientOptions: LanguageClientOptions = {
        // Register the server for plain text documents
        documentSelector: ['haskell'],
        synchronize: {
            // Synchronize the setting section 'ghcMod' to the server
            configurationSection: 'haskell'
        }
    };

    // Create the language client and start the client.
    let languageClient = new LanguageClient('ghc-mod server', serverOptions, clientOptions);
    let disposable = languageClient.start();

    // Push the disposable to the context's subscriptions so that the
    // client can be deactivated on extension deactivation
    context.subscriptions.push(disposable);
    Commands.register(context, languageClient);

    languageClient.onRequest<string, string, void>(OpenSettingsRequest.type, (action): Promise<string> => {
        switch (action) {
            case 'Workspace':
                commands.executeCommand('workbench.action.openWorkspaceSettings');
                break;
            case 'User':
                commands.executeCommand('workbench.action.openGlobalSettings');
                break;
            default:
                break;
        }
        return null;
    });
}
Example #9
0
export function activate(context: vscode.ExtensionContext) {

	validateConfig();
	// Use the console to output diagnostic information (console.log) and errors (console.error)
	// This line of code will only be executed once when your extension is activated
	console.log('Congratulations, your extension "code-bing" is now active!');
	// The command has been defined in the package.json file
	// Now provide the implementation of the command with  registerCommand
	// The commandId parameter must match the command field in package.json
	var disposable = vscode.commands.registerCommand(cInfo.command("search"), () => {
		// The code you place here will be executed every time your command is executed

		// Get the active editor
		let editor = vscode.window.activeTextEditor;
		let selectedText = "";
		if (editor) {
			// Get the selected text
			let selection = editor.selection;
			selectedText = editor.document.getText(selection);
		}
		// Get config settings
		let config = vscode.workspace.getConfiguration(cInfo.group);
		let useDefaultOnly = config.get<boolean>(cKeys.useDefaultProviderOnly)
		let useDefaultForSelection = config.get<boolean>(cKeys.alwaysUseDefaultForSelection)
		let skipInputForSelection = config.get<boolean>(cKeys.noInputBoxIfTextSelected)

		if (!utils.isNullOrEmpty(selectedText) && skipInputForSelection) {
			searchFor(selectedText, true);
		} else {
			if (!utils.isNullOrEmpty(selectedText) && useDefaultForSelection) {
				useDefaultOnly = true
			}
			// In order to do so, setup some options. 
			let options: vscode.InputBoxOptions = {
				prompt: "Enter provider code followed by query",	// <- The text to display underneath the input box. 
				value: selectedText,								// <- The value to prefill in the input box. Here we use the selected text.
				placeHolder: "Query"								// <- An optional string to show as place holder in the input box to guide the user what to type.
			}
			vscode.window.showInputBox(options).then((q) =>
				searchFor(q, (useDefaultOnly || utils.startsWith(q, selectedText)))
			);
		}
	});
	context.subscriptions.push(disposable);
	
	// check configuration every time the user changes it.
	disposable = vscode.workspace.onDidChangeConfiguration(validateConfig);
	context.subscriptions.push(disposable);
}
    constructor(colorer: BraceColorer) {
        this.colorer = colorer;

        // subscribe to selection change and editor activation events
        let subscriptions: Disposable[] = [];
        window.onDidChangeTextEditorSelection(this.onEvent, this, subscriptions);
        window.onDidChangeActiveTextEditor(this.onEvent, this, subscriptions);        
        workspace.onDidChangeConfiguration(this.updateConf, this, subscriptions);    

        this.updateConf();
        this.colorer.colorize();

        // create a combined disposable from both event subscriptions
        this.disposable = Disposable.from(...subscriptions);
    }
Example #11
0
	constructor(
		private readonly client: TypeScriptServiceClient,
		private readonly description: LanguageDescription,
		private readonly commandManager: CommandManager,
		private readonly telemetryReporter: TelemetryReporter,
		private readonly typingsStatus: TypingsStatus,
		private readonly fileConfigurationManager: FileConfigurationManager,
		private readonly onCompletionAccepted: (item: vscode.CompletionItem) => void,
	) {
		super();
		vscode.workspace.onDidChangeConfiguration(this.configurationChanged, this, this._disposables);
		this.configurationChanged();

		client.onReady(() => this.registerProviders());
	}
	constructor() {
		const subscriptions: Disposable[] = [];

		// Listen for changes in the active text editor
		subscriptions.push(window.onDidChangeActiveTextEditor(textEditor => {
			if (textEditor && textEditor.document) {
				this._onDidOpenDocument(textEditor.document);
			}
		}));

		// Listen for changes in the configuration
		subscriptions.push(workspace.onDidChangeConfiguration(
			this._onConfigChanged.bind(this)
		));

		// Listen for saves to ".editorconfig" files and rebuild the map
		subscriptions.push(workspace.onDidSaveTextDocument(savedDocument => {
			if (path.basename(savedDocument.fileName) === '.editorconfig') {
				// Saved an .editorconfig file => rebuild map entirely and then
				// apply the changes to the .editorconfig file itself
				this._rebuildConfigMap();
				// TODO The transformations should be applied to the `.editorconfig` file as well after the config
				// has been rebuilt
				// this._rebuildConfigMap().then(applyOnSaveTransformations.bind(
				// 	undefined,
				// 	savedDocument,
				// 	this
				// ));
				return;
			}
		}));

		subscriptions.push(workspace.onWillSaveTextDocument(e => {
			const edits = calculatePreSaveTransformations(e.document, this);

			e.waitUntil(Promise.resolve(edits));
		}));

		// dispose event subscriptons upon disposal
		this._disposable = Disposable.from.apply(this, subscriptions);

		// Build the map (cover the case that documents were opened before
		// my activation)
		this._rebuildConfigMap();

		// Load the initial workspace configuration
		this._onConfigChanged();
	}
Example #13
0
	constructor(private logger: Logger) {
		this._onDidChange = new vsc.EventEmitter<Configuration>();

		this.load().then(() => {
			logger.log('Configuration loaded');
		});

		this._eventHandler = vsc.workspace.onDidChangeConfiguration(event => {
			if (event.affectsConfiguration(ConfigurationKey)) {
				this.load().then(() => {
					logger.log('Configuration reloaded');
					this._onDidChange.fire(this);
				});
			}
		});
	}
Example #14
0
    constructor(controller: ctrl.Controller) {
        this._controller = controller;
        //this._controller.runOne();

        // subscribe to events
        let subscriptions: Disposable[] = [];
        window.onDidChangeTextEditorSelection(this.handler, this, subscriptions);
        window.onDidChangeActiveTextEditor(this.handler, this, subscriptions);
        workspace.onDidChangeConfiguration(this.configChangeHandler, this, subscriptions);

        // update the counter for the current file
        this._controller.runOne(true);

        // create a combined disposable from both event subscriptions
        this._disposable = Disposable.from(...subscriptions);
    }
Example #15
0
	constructor(
		private readonly client: TypeScriptServiceClient,
		private readonly description: LanguageDescription,
		private readonly commandManager: CommandManager,
		private readonly telemetryReporter: TelemetryReporter,
		private readonly typingsStatus: TypingsStatus,
		private readonly fileConfigurationManager: FileConfigurationManager
	) {
		super();
		vscode.workspace.onDidChangeConfiguration(this.configurationChanged, this, this._disposables);
		this.configurationChanged();

		client.onReady(async () => {
			await this.registerProviders();
		});
	}
Example #16
0
export function activate(context: vscode.ExtensionContext) {
	const telemetryReporter = loadDefaultTelemetryReporter();
	context.subscriptions.push(telemetryReporter);

	const contributions = getMarkdownExtensionContributions(context);

	const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState);
	const engine = new MarkdownEngine(contributions, githubSlugifier);
	const logger = new Logger();

	const selector: vscode.DocumentSelector = [
		{ language: 'markdown', scheme: 'file' },
		{ language: 'markdown', scheme: 'untitled' }
	];

	const contentProvider = new MarkdownContentProvider(engine, context, cspArbiter, contributions, logger);
	const symbolProvider = new MDDocumentSymbolProvider(engine);
	const previewManager = new MarkdownPreviewManager(contentProvider, logger, contributions);
	context.subscriptions.push(previewManager);

	context.subscriptions.push(vscode.languages.setLanguageConfiguration('markdown', {
		wordPattern: new RegExp('(\\p{Alphabetic}|\\p{Number})+', 'ug'),
	}));
	context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(selector, symbolProvider));
	context.subscriptions.push(vscode.languages.registerDocumentLinkProvider(selector, new LinkProvider()));
	context.subscriptions.push(vscode.languages.registerFoldingRangeProvider(selector, new MarkdownFoldingProvider(engine)));
	context.subscriptions.push(vscode.languages.registerWorkspaceSymbolProvider(new MarkdownWorkspaceSymbolProvider(symbolProvider)));

	const previewSecuritySelector = new PreviewSecuritySelector(cspArbiter, previewManager);

	const commandManager = new CommandManager();
	context.subscriptions.push(commandManager);
	commandManager.register(new commands.ShowPreviewCommand(previewManager, telemetryReporter));
	commandManager.register(new commands.ShowPreviewToSideCommand(previewManager, telemetryReporter));
	commandManager.register(new commands.ShowLockedPreviewToSideCommand(previewManager, telemetryReporter));
	commandManager.register(new commands.ShowSourceCommand(previewManager));
	commandManager.register(new commands.RefreshPreviewCommand(previewManager));
	commandManager.register(new commands.MoveCursorToPositionCommand());
	commandManager.register(new commands.ShowPreviewSecuritySelectorCommand(previewSecuritySelector, previewManager));
	commandManager.register(new commands.OpenDocumentLinkCommand(engine));
	commandManager.register(new commands.ToggleLockCommand(previewManager));

	context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
		logger.updateConfiguration();
		previewManager.updateConfiguration();
	}));
}
Example #17
0
	constructor(client: TypeScriptServiceClient, description: LanguageDescription) {
		this.description = description;
		this._validate = true;

		this.bufferSyncSupport = new BufferSyncSupport(client, description.modeIds);
		this.syntaxDiagnostics = Object.create(null);
		this.currentDiagnostics = languages.createDiagnosticCollection(description.id);

		workspace.onDidChangeConfiguration(this.configurationChanged, this);
		this.configurationChanged();

		client.onReady().then(() => {
			this.registerProviders(client);
		}, () => {
			// Nothing to do here. The client did show a message;
		});
	}
Example #18
0
export function activate(context: vscode.ExtensionContext): void {
	if (!vscode.workspace.workspaceFolders) {
		return;
	}

	taskProvider = vscode.workspace.registerTaskProvider('npm', {
		provideTasks: () => {
			return provideNpmScripts();
		},
		resolveTask(_task: vscode.Task): vscode.Task | undefined {
			return undefined;
		}
	});
	configureHttpRequest();
	vscode.workspace.onDidChangeConfiguration(() => configureHttpRequest());

	context.subscriptions.push(addJSONProviders(httpRequest.xhr));
}
Example #19
0
export function activate(context: ExtensionContext) {
	let activated: boolean;
	let openListener: Disposable;
	let configurationListener: Disposable;
	function didOpenTextDocument(textDocument: TextDocument) {
		if (activated) {
			return;
		}
		if (shouldBeValidated(textDocument)) {
			openListener.dispose();
			configurationListener.dispose();
			activated = true;
			realActivate(context);
		}
	}
	function configurationChanged() {
		if (activated) {
			return;
		}
		for (let textDocument of Workspace.textDocuments) {
			if (shouldBeValidated(textDocument)) {
				openListener.dispose();
				configurationListener.dispose();
				activated = true;
				realActivate(context);
				return;
			}
		}
	}
	openListener = Workspace.onDidOpenTextDocument(didOpenTextDocument);
	configurationListener = Workspace.onDidChangeConfiguration(configurationChanged);

	let notValidating = () => Window.showInformationMessage(`${linterName} is not validating any files yet.`);
	dummyCommands = [
		Commands.registerCommand('standard.executeAutofix', notValidating),
		Commands.registerCommand('standard.showOutputChannel', notValidating)
	];

	context.subscriptions.push(
		Commands.registerCommand('standard.enable', enable),
		Commands.registerCommand('standard.disable', disable)
	);
	configurationChanged();
}
Example #20
0
export function activate(context: vscode.ExtensionContext) {
    const outputChannel = vscode.window.createOutputChannel('GHC');

    const ext: ExtensionState = {
        context,
        outputChannel,
        workspaceType: computeWorkspaceType(),
        sessionManagers: new Map(),
        singleManager: null
    }
    
    registerRangeType(ext);
    
    registerCompletion(ext);
    
    const diagInit = registerDiagnostics(ext);
    
    async function restart(): Promise<void> {
        const stops = [];

        for (const [doc, session] of ext.sessionManagers) {
            if (session.ghci)
                stops.push(session.ghci.stop());
        }
        ext.sessionManagers.clear();

        if (ext.singleManager && ext.singleManager.ghci)
            stops.push(ext.singleManager.ghci.stop());
        
        await Promise.all(stops);

        ext.workspaceType = computeWorkspaceType();

        diagInit();
    }

    context.subscriptions.push(
        vscode.workspace.onDidChangeConfiguration(restart),
        vscode.commands.registerCommand('vscode-ghc-simple.restart', restart));

    registerDefinition(ext);
}
export function activate(context: ExtensionContext) {

    // Create a status bar item
    const status = window.createStatusBarItem(StatusBarAlignment.Left, 1000000);
    context.subscriptions.push(status);

    // Update status bar item based on events for multi root folder changes
    context.subscriptions.push(workspace.onDidChangeWorkspaceFolders(e => updateStatus(status)));

    // Update status bar item based on events for configuration
    context.subscriptions.push(workspace.onDidChangeConfiguration(e => this.updateStatus(status)));

    // Update status bar item based on events around the active editor
    context.subscriptions.push(window.onDidChangeActiveTextEditor(e => updateStatus(status)));
    context.subscriptions.push(window.onDidChangeTextEditorViewColumn(e => updateStatus(status)));
    context.subscriptions.push(workspace.onDidOpenTextDocument(e => updateStatus(status)));
    context.subscriptions.push(workspace.onDidCloseTextDocument(e => updateStatus(status)));

    updateStatus(status);
}
Example #22
0
export async function activate(context: vscode.ExtensionContext): Promise<void> {
	taskProvider = registerTaskProvider(context);
	const treeDataProvider = registerExplorer(context);
	configureHttpRequest();
	vscode.workspace.onDidChangeConfiguration((e) => {
		configureHttpRequest();
		if (e.affectsConfiguration('npm.exclude')) {
			invalidateScriptsCache();
			if (treeDataProvider) {
				treeDataProvider.refresh();
			}
		}
		if (e.affectsConfiguration('npm.scriptExplorerAction')) {
			if (treeDataProvider) {
				treeDataProvider.refresh();
			}
		}
	});
	context.subscriptions.push(addJSONProviders(httpRequest.xhr));
}
Example #23
0
export function activate(context: vscode.ExtensionContext) {
	const telemetryReporter = loadDefaultTelemetryReporter();
	context.subscriptions.push(telemetryReporter);

	const contributions = getMarkdownExtensionContributions();

	const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState);
	const engine = new MarkdownEngine(contributions);
	const logger = new Logger();

	const selector = 'markdown';

	const contentProvider = new MarkdownContentProvider(engine, context, cspArbiter, contributions, logger);

	const previewManager = new MarkdownPreviewManager(contentProvider, logger, contributions);
	context.subscriptions.push(previewManager);

	context.subscriptions.push(vscode.languages.registerDocumentSymbolProvider(selector, new MDDocumentSymbolProvider(engine)));
	context.subscriptions.push(vscode.languages.registerDocumentLinkProvider(selector, new LinkProvider()));
	context.subscriptions.push(vscode.languages.registerFoldingProvider(selector, new MarkdownFoldingProvider(engine)));

	const previewSecuritySelector = new PreviewSecuritySelector(cspArbiter, previewManager);

	const commandManager = new CommandManager();
	context.subscriptions.push(commandManager);
	commandManager.register(new commands.ShowPreviewCommand(previewManager, telemetryReporter));
	commandManager.register(new commands.ShowPreviewToSideCommand(previewManager, telemetryReporter));
	commandManager.register(new commands.ShowLockedPreviewToSideCommand(previewManager, telemetryReporter));
	commandManager.register(new commands.ShowSourceCommand(previewManager));
	commandManager.register(new commands.RefreshPreviewCommand(previewManager));
	commandManager.register(new commands.MoveCursorToPositionCommand());
	commandManager.register(new commands.ShowPreviewSecuritySelectorCommand(previewSecuritySelector, previewManager));
	commandManager.register(new commands.OnPreviewStyleLoadErrorCommand());
	commandManager.register(new commands.OpenDocumentLinkCommand(engine));
	commandManager.register(new commands.ToggleLockCommand(previewManager));

	context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
		logger.updateConfiguration();
		previewManager.updateConfiguration();
	}));
}
    /*-------------------------------------------------------------------------
     * Entry Constructor
     *-----------------------------------------------------------------------*/
    public constructor(docommentDomain: IDocommentDomain) {
        this._docommentDomain = docommentDomain;

        /* Load Configuration File (.vscode/settings.json) */
        this.loadConfig();

        const subscriptions: Disposable[] = [];

        /* Add Text Change Event */
        workspace.onDidChangeTextDocument(event => {
            const activeEditor: TextEditor = window.activeTextEditor;
            if (activeEditor && event.document === activeEditor.document) {
                this._onEvent(activeEditor, event.contentChanges[0]);
            }
        }, this, subscriptions);

        /* Add Config File Change Event */
        workspace.onDidChangeConfiguration(() => {
            this.loadConfig();
        }, this, subscriptions);

        this._disposable = Disposable.from(...subscriptions);
    }
Example #25
0
	client.onReady().then(() => {
		let tagRequestor = (document: TextDocument, position: Position) => {
			let param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position);
			return client.sendRequest(TagCloseRequest.type, param);
		};
		disposable = activateTagClosing(tagRequestor, { html: true, handlebars: true, razor: true }, 'html.autoClosingTags');
		toDispose.push(disposable);

		disposable = client.onTelemetry(e => {
			if (telemetryReporter) {
				telemetryReporter.sendTelemetryEvent(e.key, e.data);
			}
		});
		toDispose.push(disposable);

		initFoldingProvider();
		toDispose.push(workspace.onDidChangeConfiguration(c => {
			if (c.affectsConfiguration(foldingSetting)) {
				initFoldingProvider();
			}
		}));
		toDispose.push({ dispose: () => foldingProviderRegistration && foldingProviderRegistration.dispose() });
	});
Example #26
0
function registerLinters(ctx: ExtensionContext) {
	const globalConfig = getGlobalConfig();
	const linters = new LintCollection(globalConfig, vscode.workspace.getConfiguration("ruby").lint, vscode.workspace.rootPath);
	ctx.subscriptions.push(linters);

	function executeLinting(e: vscode.TextEditor | vscode.TextDocumentChangeEvent) {
		if (!e) return;
		linters.run(e.document);
	}

	ctx.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(executeLinting));
	ctx.subscriptions.push(vscode.workspace.onDidChangeTextDocument(executeLinting));
	ctx.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
		const docs = vscode.window.visibleTextEditors.map(editor => editor.document);
		console.log("Config changed. Should lint:", docs.length);
		const globalConfig = getGlobalConfig();
		linters.cfg(vscode.workspace.getConfiguration("ruby").lint, globalConfig);
		docs.forEach(doc => linters.run(doc));
	}));

	// run against all of the current open files
	vscode.window.visibleTextEditors.forEach(executeLinting);
}
Example #27
0
export async function activate(context: ExtensionContext) {
  const config = Workspace.getConfiguration();
  const installationType = checkInstallation();
  const releaseNotesView = new ReleaseNotesWebview(context);

  writeChangelog();

  // Listen on set theme: when the theme is Material Theme, just adjust icon and accent.
  Workspace.onDidChangeConfiguration(onChangeConfiguration);

  // Delete old configuration, must remove with next major release
  if (config.has('materialTheme.cache.workbench')) {
    config.update('materialTheme.cache.workbench', undefined, true);
  }

  if (installationType.isFirstInstall) {
    const enableAutoApply = await installationMessage();
    await setCustomSetting('autoApplyIcons', enableAutoApply);
    // Set true always on new installation
    await setCustomSetting('showReloadNotification', true);
  }

  const shouldShowChangelog = (installationType.isFirstInstall || installationType.isUpdate) && await changelogMessage();
  if (shouldShowChangelog) {
    releaseNotesView.show();
  }

  // Registering commands
  Commands.registerCommand('materialTheme.setAccent', async () => {
    const wasSet = await ThemeCommands.accentsSetter();
    handleAutoapply(wasSet);
  });
  Commands.registerCommand('materialTheme.fixIcons', () => ThemeCommands.fixIcons());
  Commands.registerCommand('materialTheme.toggleApplyIcons', () => ThemeCommands.toggleApplyIcons());

  Commands.registerCommand('materialTheme.showReleaseNotes', () => releaseNotesView.show());
}
Example #28
0
function realActivation(): void {
    realActivationOccurred = true;
    console.log("starting language server");
    clients = new ClientCollection();
    ui = getUI();

    // Check for files left open from the previous session. We won't get events for these until they gain focus,
    // so we manually activate the visible file.
    if (vscode.workspace.textDocuments !== undefined && vscode.workspace.textDocuments.length > 0) {
        onDidChangeActiveTextEditor(vscode.window.activeTextEditor);
    }

    disposables.push(vscode.workspace.onDidChangeConfiguration(onDidChangeSettings));
    disposables.push(vscode.workspace.onDidSaveTextDocument(onDidSaveTextDocument));
    disposables.push(vscode.window.onDidChangeActiveTextEditor(onDidChangeActiveTextEditor));
    disposables.push(vscode.window.onDidChangeTextEditorSelection(onDidChangeTextEditorSelection));

    disposables.push(vscode.languages.setLanguageConfiguration('c', multilineCommentRules));
    disposables.push(vscode.languages.setLanguageConfiguration('cpp', multilineCommentRules));

    reportMacCrashes();

    intervalTimer = setInterval(onInterval, 2500);
}
Example #29
0
export function activate(_context: vscode.ExtensionContext): void {
	if (!vscode.workspace.workspaceFolders) {
		return;
	}

	function onConfigurationChanged() {
		let autoDetect = vscode.workspace.getConfiguration('npm').get<AutoDetect>('autoDetect');
		if (taskProvider && autoDetect === 'off') {
			taskProvider.dispose();
			taskProvider = undefined;
		} else if (!taskProvider && autoDetect === 'on') {
			taskProvider = vscode.workspace.registerTaskProvider('npm', {
				provideTasks: () => {
					return provideNpmScripts();
				},
				resolveTask(_task: vscode.Task): vscode.Task | undefined {
					return undefined;
				}
			});
		}
	}
	vscode.workspace.onDidChangeConfiguration(onConfigurationChanged);
	onConfigurationChanged();
}
Example #30
0
export function activate(context: vscode.ExtensionContext) {
	const telemetryReporter = loadDefaultTelemetryReporter();
	context.subscriptions.push(telemetryReporter);

	const contributions = getMarkdownExtensionContributions(context);
	context.subscriptions.push(contributions);

	const cspArbiter = new ExtensionContentSecurityPolicyArbiter(context.globalState, context.workspaceState);
	const engine = new MarkdownEngine(contributions, githubSlugifier);
	const logger = new Logger();

	const contentProvider = new MarkdownContentProvider(engine, context, cspArbiter, contributions, logger);
	const symbolProvider = new MDDocumentSymbolProvider(engine);
	const previewManager = new MarkdownPreviewManager(contentProvider, logger, contributions);
	context.subscriptions.push(previewManager);

	context.subscriptions.push(registerMarkdownLanguageFeatures(symbolProvider, engine));
	context.subscriptions.push(registerMarkdownCommands(previewManager, telemetryReporter, cspArbiter, engine));

	context.subscriptions.push(vscode.workspace.onDidChangeConfiguration(() => {
		logger.updateConfiguration();
		previewManager.updateConfiguration();
	}));
}