In visual studio code we have a concept who name is injection grammars and definition is
let you extend an existing grammar. An injection grammar is a regular TextMate grammar that is injected into a specific scope within an existing grammar. Example applications of injection grammars:
Highlighting keywords such as TODO in comments.
Add more specific scope information to an existing grammar.
Adding highlighting for a new language to Markdown fenced code blocks.
So as you can see in Port vscode (visual studio code) language server to Visual Studio extension I want to create ansible extension for Visual Studio 2022, for syntax highlighting, I found some syntax grammars in https://github.com/ansible/vscode-ansible , but the problem is tmLanguages exists in the vscode-ansible project uses injection grammars as you can see in package.json, and I do not know how to use injection grammars in Visual Studio 2022
Please help me to know How to use injection grammars in Visual Studio? (and describe the example to use syntaxes exists in vscode-ansible)
I request sample in https://github.com/microsoft/VSSDK-Extensibility-Samples/issues/278#issue-1589668356
Related
I am trying to create a domain specific IDE based on Visual Studio shell. I followed the walk-through to create a basic Isolated Visual Studio Shell Application.
Then I started the basic shell application and drag a C file into it. There's no syntax highlighting because no language service is included yet.
I found the GUIDs for various Visual Studio feature packages. I was expecting some kind of language feature package for C/C++ listed there so I can just add it into my IDE's feature list. But there's not.
So how can I make my IDE recognize the C/C++ language?
Or put it another way, how can I customize Visual Studio to include only features I need?
Some References
There are many extension types I can do with Visual Studio. What interests me most is the Visual Studio-based application. I will put the findings here as my research goes on.
Walkthrough: Creating a Basic Isolated Shell Application
Package GUIDs of Visual Studio Features
Legacy Language Service Extensibility
New Editor and Language Service Extensions
New Extending the Editor and Language Services]
Language Service and Editor Extension Points
Visual Studio Isolated Shell
Elements of the Isolated Shell
Customizing the Isolated Shell
Extending the Isolated Shell
Visual Studio Integrated Shell says this:
No programming language is included. However, the integrated shell
does provide a framework that allows you to add programming languages.
In the visual studio 2015 update 1 release blog post (https://blogs.msdn.microsoft.com/visualstudio/2015/11/30/visual-studio-update-1-rtm/) the ability to add textmate bundles (or grammars) is explicitly mentioned:
Editor support for new languages. The Visual Studio editor now provides built-in syntax highlighting and basic IntelliSense support for languages including Go, Java, Perl, R, Ruby, and Swift. We support the TextMate bundle
model for language grammars and snippets, allowing you to extend this with support for other languages.
I want to create a new textmate grammar for my own language, but I cannot find any documentation, how to do this in vs2015 update 1.
The best source I found is this reddit conversation: https://www.reddit.com/r/programming/comments/3uvwn3/visual_studio_2015_update_1/
It looks like it's implemented as an extension, "Visual Studio Extension for Textmate Grammars." If you search for *.tmbundle in your visual studio\Common7\IDE\Extensions directory you will find the location of the tmbundles. I just made a new folder for Julia and copied the Julia tmbundle to it. Seems to work.
Is this the supported way of doing this? Why isn't there any documentation, visual studio menu etc. for this?
You can do this the way you've done it above, or if you prefer it to be in your user profile directory rather than across the whole operating system installation, you can add the bundle here:
%USERPROFILE%\.vs\Extensions\
On most machines, that path expands to:
C:\User\<yourusername>\.vs\Extensions\
Looks like there's an extension from Mads Kristensen now that provides a large number of TextMate syntaxes into Visual Studio. Looks like it's easy to add additional languages as well... You can probably check out the repo and see exactly what's required to add additional syntax.
http://vsixgallery.com/extension/4773ce75-6f30-4269-9557-1f7c30a47be2/
I'm currently using Resharper heavily in my work. Recently I've heard that with Visual Studio 2015 there's a new product available called Refactoring Essentials.
My question is that how much of Resharper refactorings are available in Refactoring Essentials? How does it compare to Resharper in performance aspects?
The most important refactorings for me:
Convert to Linq
Extract Base Class
Introduce [Variable, Parameter, Field, Property]
Extract Method
Also I wanted to know if it supports languages other than .NET like JavaScript, TypeScript, CSS, ..
The Refactoring Essentials tools do not work with languages other than C# and VB - they rely on Roslyn, which only works with those languages. See this page for a comparison between VS2015 and ReSharper (note that this is a JetBrains product site). I don't think anyone's done anything similar with Refactoring Essentials.
Refactoring Essentials only support C# and Visual Basic.
As far as your list of features is concerned, none of these are available:
Convert to Linq
Extract Base Class
Introduce parameter
Introduce variable and field are available in a very basic form.
Extract Method is available, although it's not as feature-reach as ReSharper implementation.
There's a review that looks into most frequently used refactorings and some issues that one may encounter with this extension: Review of Refactoring Essentials extension for Visual Studio
I am trying to add support for a different language in Visual Studio 2010. I was hoping to add custom syntax highlighting, and have some sort of basic intellisense work with it. The language I am trying to add is 4Js Genero (a newer version of Informix-4GL). I basically just need support for the .4gl and .per file extensions that are used in Genero/4GL. Does anyone know how to do this, or can point me in the right direction?
It's not really for the faint of heart. Don't underestimate how much work you'll have to put in.
You'll need the Visual Studio 2010 SDK, and then to read (and re-read, and re-read(*)) all about Language Services
The purpose of a language service in Visual Studio is to provide language-specific support for editing source code in the integrated development environment (IDE). You implement a language service as part of a VSPackage.
(*) - unless it all immediately makes sense to you.
This isn't an answer on how to create custom syntax highlighting.
There is an open-source extension for visual studio 2010+ for Genero 4gl language support out of github:
https://github.com/gregfullman/VSGenero/wiki
It should do most of what you're looking for already, and it would certainly make a great starting point for you if you want to do more.
I have a domain-specific language with a certain syntax. Is it possible to make Visual Studio 2008 recognize custom languages in the usual editors? That is, associate a given file extension to a certain syntax-coloring scheme? If so, would you have any pointers as to how to do this?
I'm sorry if this is a duplicate. I searched but couldn't find a relevant answer, and yet it does sound like a simple question.
Regards.
If the Implementing Color Syntax Highlighting in Visual Studio 2008 seems like the deep end, you can download the Lua Lang Pack http://luaforge.net/projects/lualangpack/ and see how they do it.
They use the Compiler Tools in C# which are quite neat.
Failing that you can download my prototype Erlang VS plugin that currently only has simple syntax highlighting, but is based on all the above.
Dervin,
This should help you out:
Implementing Color Syntax Highlighting in Visual Studio 2008:
http://msdn.microsoft.com/en-us/library/bb165041.aspx