vscode-extensions

How to write async code (promises?) with vscode api: withProgress

笑着哭i 提交于 2020-02-02 06:26:28
问题 I'm pretty sorry about the title, I've got no idea how to better describe my problem. I would like to implement the withProgress API of VSCode, to be able to show progressbar while my code is runnig/progressing. Documentation is here: https://code.visualstudio.com/api/extension-capabilities/common-capabilities#progress-api I've tried to implement it: vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: "I am long running!", }, (progress, token) => { return new

How to find the parameters for a VSCode command in executeCommands()

左心房为你撑大大i 提交于 2020-01-25 10:20:29
问题 I want to write a vscode extension and use vscode.commands.executeCommands() , but I don't know what parameters the command I want to use takes. For example, when I want to use the "actions.find" command, how do I find out what parameters this specific API accepts? 回答1: I don't think there's any comprehensive documentation on commands and their arguments at this time. This page does list some of the most important ones though. For some commands, there's also args auto-completion in

Can a vscode extension create an explorer context menu for a specific file?

故事扮演 提交于 2020-01-24 13:11:38
问题 I'm writing a extension for vscode. I just want my context menu just show on when I right click on my file (ex: my_special_name_1.py ). So I added this contribution point to package.json : "contributes": { ..., "commands": [ { "command": "command.hello", "title": "Hello my file" }, ... ], "menus": { "explorer/context": [ { "when": "resourceLangId == python", "command": "command.hello" } ] }, ... } But this will show my command "Hello my file" on all .py files. How to let it just be shown only

Can a vscode extension create an explorer context menu for a specific file?

隐身守侯 提交于 2020-01-24 13:11:28
问题 I'm writing a extension for vscode. I just want my context menu just show on when I right click on my file (ex: my_special_name_1.py ). So I added this contribution point to package.json : "contributes": { ..., "commands": [ { "command": "command.hello", "title": "Hello my file" }, ... ], "menus": { "explorer/context": [ { "when": "resourceLangId == python", "command": "command.hello" } ] }, ... } But this will show my command "Hello my file" on all .py files. How to let it just be shown only

How to use Terminal API to listen to all terminal output in vscode?

只谈情不闲聊 提交于 2020-01-24 09:37:06
问题 I want to listen to terminal output from extension, such as tsc -w and catch the moment if the output contains similar text: Found 1 error. Watching for file changes. Or the error exit code or something like that. Is it possible to do with old API or Proposed API? Tried: terminal.onDidWriteData(data => { console.log('onDidWriteData: ', data.trim()); }); It just outputs autogenerated rubbish like: Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. 回答1: Looks like it

VS Code snippet to console.log selection beneath current line

荒凉一梦 提交于 2020-01-22 21:30:06
问题 This is what I'd like to achieve ( t is selected in editor): Before snippet: var t = 'Foobar'; After snippet: var t = 'Foobar'; console.log('t', t); How can I do that? Here is what I tried to do: "log_selection": { "prefix": "cls", "body": [ "console.log('$TM_SELECTED_TEXT', $TM_SELECTED_TEXT);" ], "description": "Logs selected text" } But this just replace selected text with snippet. I think that I could use TM_CURRENT_LINE here but I have no idea what to do with remaining text in the line.

JavaScript color highlighting error in VScode

荒凉一梦 提交于 2020-01-17 07:38:16
问题 I have fresh install of VScode editor (v.1.14.2). Doesn't have any installed extensions. I have problem with javaScript highlighting in very simple file. The same code in Sublime Text 3: Default VScode theme (Dark+), doesn't have this bug, and all function names and methods have the same colors. But many another themes (monokai and Abyss for example) have this bug/feature. I want to have for function names and methods the same color (line 10, 11, 13, 16). Ideally, all lines like in ST3 - blue

Contribute language association from extensions in VSCode

╄→尐↘猪︶ㄣ 提交于 2020-01-17 00:37:30
问题 How can I contribute a language association from an extension in VSCode? In settings.json it would've looked like this: "files.associations": { "*.something": "markdown" } I know that it's possible to use vscode.languages.setTextDocumentLanguage . But that seems excessive to do every time the activeEditor changes, and it's one more event listener. Using the API to write into user settings doesn't seem right either. 回答1: Yes, extensions can contribute settings via configurationDefaults.

How to get currently opened file's project folder path in visual studio code extension.js

我与影子孤独终老i 提交于 2020-01-16 14:29:29
问题 I am trying to get currently opened file's project folder path in visual studio code extension but not working for Multi-root Workspaces. Now i am getting path value is empty. Currently i opened project-ws folder files app.component.html then press ctrl+shift+p on the files tab then box will open. if i click "Get project folder path" from extension box path value should be like C:\xampp\htdocs\projects\project-ws. If i opened project-bh folder any files then press ctrl+shift+p on the files

Is it possible to write a plugin to open a directory and generate some files in it?

邮差的信 提交于 2020-01-15 05:32:27
问题 I would love to write a plugin like yo plugin but with some UI. But yo could not work before you open a directory in vscode. What I need is to select a directory in my UI and automatically generate codes. Can any one tell me which API to use to do such things and I will dig into it. 回答1: You could use the showOpenDialog() method from the vscode.window namespace to let the user pick a directory if none is currently opened. With canSelectFiles: false and canSelectFolders: true , it turns into a