How to create a link to a file in VSCode workspace - visual-studio-code

I'm trying to improve my VSCode extension which shows you the different values of a Jinja Template in your workspace. For now it creates a Hover message with the list of values and the location of the definition. Here is what it looks like:
I'm now trying to add a link to this definition.
I tried a markdown link like [filename](vscode://file/filePath:line:column) which works pretty well except it opens a new vscode instance even if the file is in the current workspace.
Would you have an idea on how to open the file in the current workspace or another way to create this link?

Related

Looking or an autocomplete filename vscode plugin

Is there any VSC plugin that allow to autocomplete file path within a project folder? I am used to RStudio, where I could simply start typing the name of a file, hit tab, and then rapidly find the corresponding file (see below).
I have tried Path Autocomplete and Path Intelisense, but could not get them working like this.
Thank you,
Phil
I've been using the RelativePath extention by jakob101 for the past couple of years.
It searches for files within the workspace and pastes a relative path at the cursor.
Super simple and easy to use.

how to edit advanced new file extension vs code to work without a workspace

I found this extension called advanced-new-file by patbenatar in vs code that lets you create files anywhere with a custom directory you can create on the spot and things like that, but it only works when using a workspace. There is another one called Advanced New File by Dominik Kundel that sort of does the same thing but anywhere even if you have no workspace opened, but it has a bit less features. Does anyone know how I can modify the first one so that I can use it without having to create/open a workspace?

Can you create a file or folder by path in VS Code?

In Atom, hitting Cmd+N brings up a window where you can type in basically any path to create any file or folder anywhere in the project. In VSCode, hitting Cmd+N brings up a dialog where you can create a file in the currently focused folder, and I believe you can type a path to create a file in a subfolder (whether it exists or not), but not as flexibly as in Atom.
Is there way to do it Atom-style in VSCode?
I don't know for sure whether this is what you're looking for, but still there exists this plugin which can emulate the file/directory creation feature of Atom.
Since i use vscode-vim it's fairly easy to create new folders and files using command mode. If you're familiar with using terminal, then you can use shell commands to create file/dir.
I have no idea whether one could do what you had mentioned the proper way with vanilla vscode.
Hope this helps you somehow.

Is there a way to open a workspace from an extension in VS Code?

I'm developing an extension that programmatically create a *.code-workspace file and I'd like to open it in the current window. Is there a way? Alternatively, it can open up a new window.
How about workspace.updateWorkspaceFolders(<start>,<deleteCount>,{uri: folderUriToAdd}) for opening the folder containing that .workspace file? This should preserve open files in Explorer.
Alternatively you could use commands.executeCommand("vscode.openFolder",<uri>,<newWindow>) and pass it the workspace uri, but this generates a new extension host process, either in your current window or a new one, depending on the value of newWindow.
Docs for those functions here: https://code.visualstudio.com/docs/extensionAPI/vscode-api and here: https://code.visualstudio.com/docs/extensionAPI/vscode-api-commands

Get Eclipse variable with the name of a file that is not in the project

I am trying to find a way to navigate to the folder containing the current opened file from Eclipse. I have read this tutorial which describes an External Tool that I have adapted as follows:
Location: /usr/bin/nemo (or file mananger of your choice)
Arguments: ${resource_path}
This works fine, as long as the editor contains a file that is in a project. However, if I have F3'd through an include and I am now in a system include file (for example), or I have opened some other non-project file, this method fails with the error Variable references empty selection: ${resource_path}.
I know Eclipse knows the filename, because it a) opened the file in the first place and 2) it's in the title bar. How can I get this into an External Tool?
Alternatively, is it possible to get Eclipse to use the current file's location as the default directory in the open dialog? It's annoying to have to navigate though a lot of hierarchy every time you open a resource in a new location.