当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript workspace.onDidChangeConfiguration方法代码示例

本文整理汇总了TypeScript中vscode.workspace.onDidChangeConfiguration方法的典型用法代码示例。如果您正苦于以下问题:TypeScript workspace.onDidChangeConfiguration方法的具体用法?TypeScript workspace.onDidChangeConfiguration怎么用?TypeScript workspace.onDidChangeConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vscode.workspace的用法示例。


在下文中一共展示了workspace.onDidChangeConfiguration方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: activate

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);
                }
            });
    }
}
开发者ID:JuliaEditorSupport,项目名称:julia-vscode,代码行数:52,代码来源:extension.ts

示例2: constructor

	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();
	}
开发者ID:rlugojr,项目名称:vscode-extension-samples,代码行数:52,代码来源:extension.ts

示例3: activate

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
				});
		}
	}));
}
开发者ID:tonycleveland,项目名称:vscode,代码行数:52,代码来源:extension.ts

示例4: activate

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)
  )
}
开发者ID:bookman25,项目名称:vscode-jest,代码行数:51,代码来源:extension.ts

示例5: activate

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();
}
开发者ID:jskulski,项目名称:vscode-vim,代码行数:51,代码来源:extension.ts

示例6: activate

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);
}
开发者ID:CalebOuellette,项目名称:SCCopy,代码行数:50,代码来源:extension.ts

示例7: activate

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()));
}
开发者ID:scytalezero,项目名称:vscode-npm-scripts,代码行数:14,代码来源:main.ts

示例8: activate

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;
    });
}
开发者ID:gdziadkiewicz,项目名称:vscode-ghc-mod,代码行数:49,代码来源:extension.ts

示例9: activate

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);
}
开发者ID:awebdeveloper,项目名称:code-bing,代码行数:49,代码来源:extension.ts

示例10: constructor

    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);
    }
开发者ID:DavideCanton,项目名称:vscode-colorbraces,代码行数:15,代码来源:brace-colorer-controller.ts


注:本文中的vscode.workspace.onDidChangeConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。