vscode-extensions

How to get file name or path in vscode extension when user right click on file in explorer/context?

落爺英雄遲暮 提交于 2019-12-14 04:18:31
问题 My extension creates a context menu in the explorer tree: "contributes": { "commands": [ ... { "command": "myextension.mycommand", "title": "Run my command" } ], "menus": { "explorer/context": [{ "when": "resourceLangId == python", "command": "myextension.mycommand", "group": "MyGroup" }] } } In extension.ts : export function activate(context: vscode.ExtensionContext) { context.subscriptions.push(vscode.commands.registerCommand('myextension.mycommand', () => { //How to get the filename or

How to implement complicated auto-indentation in VScode

跟風遠走 提交于 2019-12-14 03:53:14
问题 I am working on a language extension for SAS for VScode. I previously worked on the SAS language extension for Atom (https://github.com/akanosora/language-sas) as well as Vim (part of the default Vim packages: https://github.com/vim/vim/blob/master/runtime/indent/sas.vim). I am not very satisfied with the auto-indentation implementation in Atom and it seems that VScode provides more or less the same mechanism for auto-indentation. The proper indentation for SAS code is quite tricky as the

Set selection range in the Visual Studio Code document

喜你入骨 提交于 2019-12-14 02:56:45
问题 I have a command in an extension, before run the command, I want to change the selection range to get the whole lines... const sel = textEditor.selection; const firstLine = textEditor.document.lineAt(sel.start.line); const lastLine = textEditor.document.lineAt(sel.end.line); const range = new vscode.Range(firstLine.lineNumber, firstLine.range.start.character, lastLine.lineNumber, lastLine.range.end.character); I've created a new range, but I don't know how to set the selection of the document

How to add elements to Outline panel in custom extension?

被刻印的时光 ゝ 提交于 2019-12-13 12:32:23
问题 I have a VS Code extension for ST language support. Right now it provides only syntax highlights and some snippets. I wanted to create a tree structure of the document showing programs, functions and their parameters in the Outline panel. But I cannot find an example of how to do that. Can you refer me to the right direction but not to LSP as it is too complicated for now I want to make it programmatically. 回答1: The outline view is populated by a DocumentSymbolProvider (see also:

Visual Studio Code link to local HTML file

穿精又带淫゛_ 提交于 2019-12-13 06:17:26
问题 I have a LSP server that returns hovers/tooltips containing links. If I link to an HTML file on the web ( https://... ) when you click it it opens that link in the browser. If I link to a local HTML file ( file://... ) it opens that HTML file in VSCode, as if you wanted to edit the file. Is there any way to make it open the local HTML file in your browser? Edit 1 : I found the code that handles this. Seems it just checks for http , https or mailto and opens those externally. Everything else

How to get path for currently open tab file's root path

╄→гoц情女王★ 提交于 2019-12-13 03:07:50
问题 Tried to get project folder path in multi root workspace condition in visual studio code but facing very difficult to find the path. Below script only will work single root workspace But How to change for multi root workspace. var vscode = require("vscode"); var path = require("path"); exports.activate = context => { const searchoption = vscode.commands.registerCommand('extension.search', () => { let folderPath = vscode.workspace.rootPath; // get the open file's project folder path }); } 回答1:

Custom node version to run VSCode extensions

本小妞迷上赌 提交于 2019-12-12 20:24:15
问题 I'm making a vscode extension for my personal use. I'd really like to use a more recent node version. However, I'm not sure how does VSCode chooses which node version to use. The only node.js that I have installed is 8.1.3 . But when I debug the extension, I see that VSCode uses 7.*.* (via process.version ). I've been searching documentation for an hour, so far, without luck. Any help is appreciated. 回答1: This is not possible. Quoting the reply of one of the team members (Andre Weinand) in

How should I package my Language Server with my client?

ⅰ亾dé卋堺 提交于 2019-12-12 20:10:00
问题 I'm trying to create a language server for VSCode. It's made up of a client and a server, communicating over RPC. The official docs have a working example, with the language-server split into in two directories, the client and the server . What I want to do is to package both into a VSIX file, so I can install them together. In their example, they say cd to the client directory and run vsce package . However, If I do that and install the resultant package, VSCode says "Error: Cannot find

How do get provideTasks method of registerTaskProvider working

倖福魔咒の 提交于 2019-12-12 19:21:28
问题 I am trying to get the new registerTaskProvider method in the VSCode Task API working within my extension, and I have been unable to make this work so far. I have used the npm extension as a basis. Here are the steps that I have followed: Used yo to create a new extension Updated package.json to include a new activationEvent onCommand:workbench.action.tasks.runTask Updated package.json to include configuration and taskDefinitions sections in the contributes section Added the following code to

Show results from both word based suggestions and own completion provider

最后都变了- 提交于 2019-12-12 18:51:15
问题 I am developing a Visual Studio Code extension, that, using the Language Server Protocol, provides a completion list. My problem is that after implementing it, users have lost the completion based on the document contents. I want completion to show both my own provider's results as well as VSCode's word based suggestions. Non-Working example: Working example: (https://github.com/APerricone/harbourCodeExtension/issues/16) I tried to set isIncomplete to false , without any improvement. 回答1: