Open XVincentX opened 8 years ago
See Changing language for current file
Please ask 'how-to' questions about VS Code on Stack Overflow using the tag vscode
.
The VS Code development team together with the VS Code Community will answer question your question over there.
Here is how the development team tracks feedback on the different channels: Feedback Channels.
@ramya-rao-a ?????? Hmm...I am not talking the IDE itself, I'm talking from an extension context. I'm missing an API function to make that happen. Does that clarify?
My point is that - it seems that TextEditor
class is missing methods to set current language type, or eventually trigger the auto detect mechanism
Sorry, I thought you were talking from a user's perspective rather than an extension author. Will look into it and get back to you
@XVincentX This mostly depends on the filename and 'pasting it into the editor' will miss that information I guess.
@jrieken Is there any plan to provide an API call to trigger the auto detection? In my use cases, giving I'm providing regexp in languages I support, it would really solve my problem here.
Thanks!
@jrieken I started contributing #12035 and I liked it.
Would you be open to an user contribution here? If you could point out where I should start look, I'd love to give it a try!
Hi,
I am faced with a similar problem/scenario as the original poster. Let's say you're faced with this scenario:
Is it this possible, or is it at least something in the pipeline?
From an implementation point of view, I would do:
This is quite crude, but I hope that gets the point across.
Regardless +1 for this feature.
I want auto-detect too. when I copy a json(or other) from chrome dev tool(or webpage), paste in vscode, I hope vscode auto-detect program language, and highlight.
I need that feature as well, please.
@jrieken is the idea to provide new API vscode.languages.detectLanguage(resource: Uri, supportedLanguageIds?: string[]): Thenable<string | undefined>
which would get wired through to the detectLanguage
method of LanguageDetectionService
?
Adding that new API would be great!
I found you can also call vscode.commands.executeCommand('editor.detectLanguage') which will run the detection on the active editor.. but it's not silent, and if it does not find a match a warning notification is displayed. Would it be easier to add a silent option to that command ?
Some times I'm fetching some content from the web and pasting it into the current active editor. So far, I didn't find any way to set the current language for the window. Is there any particular API call for that?
Even better, would it be possible to trigger the auto detection mechanism with the API?