vscode-extensions

Change title of untitled tab in Visual Studio Code

若如初见. 提交于 2020-01-03 13:55:08
问题 I'm building a VS Code extension which includes changing the name/title of untitled-1 tab (unsaved file). I tried running the below code in debugger console of extension but it didn't reflect in the editor: vscode.workspace.textDocuments[0].fileName="myFile" Is it not possible or am I missing something? 回答1: It's not possible - if you check out the source code for the API definition in vscode.d.ts, you'll see that fileName is declared as readonly : export interface TextDocument { // ...

Visual Studio Code: How to Include another language in a user defined language?

时光毁灭记忆、已成空白 提交于 2020-01-03 05:54:08
问题 I have downloaded a plugin for Language A. It is at %USERPROFILE%.vscode\extensions\langA\syntaxes. There is a file langA.tmLanguage. It is XML. I am creating "language B". I have a JSON tmLanguage file. I have already added some custom coloring and folding rules. I would like to inherit language A's syntax when it is embedded in Language B between START_MARKER and END_MARKER. Is this possible? Can someone help with the JSON syntax to accomplish this? Bonus Q: Can anyone point me to a real

Visual Studio Code: How to Include another language in a user defined language?

坚强是说给别人听的谎言 提交于 2020-01-03 05:54:02
问题 I have downloaded a plugin for Language A. It is at %USERPROFILE%.vscode\extensions\langA\syntaxes. There is a file langA.tmLanguage. It is XML. I am creating "language B". I have a JSON tmLanguage file. I have already added some custom coloring and folding rules. I would like to inherit language A's syntax when it is embedded in Language B between START_MARKER and END_MARKER. Is this possible? Can someone help with the JSON syntax to accomplish this? Bonus Q: Can anyone point me to a real

visual studio language extension, how do I call my own functions?

丶灬走出姿态 提交于 2020-01-02 19:29:47
问题 I've implemented my own language server (based on the lsp-sample in the visual studio sample extensions git tree). It does basic language parsing ..etc. I would like to provide some simple functions in the client side of my extension, that need access to data that is already parsed in the server portion of my extension. how do I add my own calls to the client/server so I can ask my server for stuff ? I'm looking to send commands/calls from the client side, to the server side and get an answer

sending a command from a virtual document in a vscode extension

匆匆过客 提交于 2020-01-02 10:23:09
问题 I am making a Visual Studio Code extension, where I make a virtual document let provider = new TextDocumentContentProvider(); let registration = vscode.workspace.registerTextDocumentContentProvider('nucleus-preview', provider); And I register a command with: vscode.commands.registerCommand('extension.sendMessage', (message) => { console.log('the message is ', message) }); In the virtual document I want to send a message back to the extension using JavaScript. If I have a link in the virtual

Dynamic snippet evaluation in VSCode

笑着哭i 提交于 2020-01-02 01:25:48
问题 Is it possible for a snippet to insert a dynamically computed completion or snippet in Visual Studio Code? I would like a snippet for inserting date and time strings of various formats. For example if you type date , the current date in ISO format would automatically be expanded. There is a facility in Sublime Text to do this in the python API via the on_query_completions method in the EventListener class. There the implementation would be very simple: def on_query_completions(self, view,

How to programmatically close vscode.window's showInformationMessage box

好久不见. 提交于 2020-01-01 04:59:06
问题 I just began learning about vscode extensions and I'm wondering if there is a simple way to programmatically close the information message box that is generated via vscode.window.showInformationMessage() . If you want to reproduce, I started with the WordCount demo here, and after copy/pasting the body of extension.ts , as outlined in the tutorial, I made some modifications to activate() like so... export function activate(context: ExtensionContext) { let wordCounter = new WordCounter(); let

How to create a custom dialog in vscode?

隐身守侯 提交于 2020-01-01 04:28:05
问题 I'm developing an extension for vscode, and I want to display a custom dialog to help the user configure an ini file. It's possible to create a custom dialog, with labels and inputs? 回答1: You cannot create new UI elements, but if you want to get inputs from the user you can use code like below: let options: InputBoxOptions = { prompt: "Label: ", placeHolder: "(placeholder)" } window.showInputBox(options).then(value => { if (!value) return; answer1 = value; // show the next dialog, etc. });

How to make a click event in 'vscode.window.showInformationMessage'

▼魔方 西西 提交于 2019-12-31 05:03:07
问题 I have a Information Box which contains a button, So when I click the button I need it to navigate to a web site in the button click event. I was able to add a button inside Information box but now I don't have a clear understanding about how to make the button click event in 'vscode.window .showInformationMessage' since I'm new to typescript and extension development.So can anyone please guide me with this? vscode.window .showInformationMessage("Click for more Info","Go to Help") .then

How to add a new file to the workspace when developing a new vscode extension?

时间秒杀一切 提交于 2019-12-25 16:48:43
问题 Just as I had trouble and it is not that obvious: How can I add a new file when developing vscode extension? 回答1: First you have to create a command (when using the vscode extension example put it in extension.ts) -> For example the hello world command. You have to use openTextDocument method on the workspace and get the path for your project. Don't forget that you have to use "\" instead of "/" for the path: let manifest = await vscode.workspace.openTextDocument(vscode.Uri.parse("untitled:"