How to invoke a VS code extension by clicking on file? - visual-studio-code

I have the vscode-pdf extension installed which let's me directly view pdf files in VS code. Is there any possibility to open pdf files directly with the said extension by just clicking on the file?
The current behaviour when clicking on a pdf file is the following message:
The file is not displayed in the editor because it is either binary or uses an unsupported text encoding. Do you want to open it anyway?
Edit: I use VS Code version 1.40.2 1.60.0
Edit2: The feature mentioned in the answer to this question now seems to be integrated. Any update on this?

Not as of VS Code 1.41
However this is a good potential use case for the proposed custom editor api

Related

How to keep open file input in Visual Studio Code when I change of window?

I would like to know if it is possible to keep this search engine (Ctrl-P) open if I change the window, in Visual Studio Code.
It is a not very relevant functionality but it would help me when I forget part of the name of the file I want to search for or I have to change the window to solve another situation, however, when returning to Visual Studio Code the file browser closed itself and I must return to write part of the file path from the start.
Is there a configuration or extension with this functionality?
Thank you very much!
No, you cannot keep that open when you change windows. Since the search engine provides compilers or lints for various languages that you are editing in the ide space. So when you open a new window by default VS code provides a different configuration for the script, so the search engine cannot be kept open.
A detailed description can be found here https://code.visualstudio.com/docs/getstarted/settings

How do you get the python colour scheme while using sage on VS code?

Currently, I name my files as .py while working on them, and then change them to .sage when I need to execute. Is there a way to get the python colour scheme for sage files on VS code?
There is an extension called SAGE enterprise management that claims to do it, but the instructions are a bit unclear:
It says:
Create a x3-code named folder inside your ~/.vscode/extensions/;
Copy all files in yours recent created folder;
Reload VS Code and enjoy;
I tried both copying my sage files into the folder, and the contents of the x3-extension into the folder, both of which didn't work.
The instructions referred to in the question are for Sage the
accounting software, not for SageMath the Sage mathematics
software system.
In the case of SageMath, we need to tell VS Code to apply Python
formatting not only to files ending in .py, but also to files
ending in .sage. One way to do that is to use the "file to
language association" setting:
https://code.visualstudio.com/updates/vMarch#_file-to-language-association
One would add associations from "*.sage" to "python".
This related question has answers explaining where Visual
Studio Code's language extension files are located on macOS
and Windows:
Stack Overflow question 42498117
Following the first link provided in the prior answer, I got it worked. In details,
go to Settings, type "files.associations" in the search box for Search settings.
It shows you a list of (item, value) in which you can add a new item (*.sage, python). See my screenshot below
Hope it works for you!

Is it possible to synchronize vscode terminal emulator's working directory with an editor's?

I'll like to have the terminal automatically change directory to the editor's current directory anytime I switch editor.
I'm used to this in Emacs so I was thinking if it was possible to make VSCode have this same behavior.
I do not believe this is supported out of box as of VS Code 1.24. However this could be implemented by an extension (see discussion here)
Implementing this will likely require this VS Code extension API addition: https://github.com/Microsoft/vscode/issues/46192
I have implemented a simple extension that does just this. Take a look at https://marketplace.visualstudio.com/items?itemName=maciejdems.terminal-sync.

Fuzzy file opening in vscode

I am exploring vscode after using atom for a long while. One of the things I'm missing is an equivalent of the lovely package advanced-open-file. Is there something similar to this in vscode?
I found the advanced-new-file extension, but it is only helpful when it comes to new files. I would like to be able to quickly open files from all over my local files (not only the workspace).
Edit: I found the option of workbench.action.quickOpen; but it doesn't allow opening files from the whole file system.
Sorry, but currently the answer is no. The problem is that input box doesn't provide a way to listen to key events:
GitHub issue,
so even the extensions can't do that currently. Here's the comment from advanced-new-file extension creator:
Because VSCode extensions don't yet have the ability to do type-ahead autocomplete within the text input box (See https://github.com/Microsoft/vscode/issues/426), we work around this limitation and provide autocomplete using a two-step workflow of selecting existing path, then providing new filename/path relative to the selection.
The good news is that there is a new API addressing this issue, but it's currently in 'proposed' state and can't be used for published extensions.
One workaround could be typing code -r some/path in integrated terminal and using 'tab' for autocomplete.
The Fuzzy search extension seems to work for me.
It adds a new action to the command palette which allows you to search for files in the current project and open them.

Visual studio code extension: How can I add error markers to files in the explorer?

I have written a validator for my vscode extension, which uses a DiagnosticCollection to set errors for files. This works and the errors are shown when a file is opened.
I would now like to mark files in the explorer, so that it is easy to find files with errors. Here is an example]of how it looks in Eclipse:
Is it possible to do this in a vscode extension? Is there already an extension doing this?
Unfortunately, you can't do that.
There is an open issue asking something related to Git, but not as open as you want. Maybe using the API described in this another issue you could create a new panel with the marked files.
It is still experimental, BTW...