views:

148

answers:

2

Hi Guys,

So I'm now about to look at getting visual studio integration working for our port of the Less ruby library: www.dotlesscss.com. This is basically a CSS preprocessor that extends on the CSS language to give you variables, mixins, nested rules etc...

What we want is to have our .Less file type take advantage of VS's intelligence and syntax highlighting. Now as the Less language is pretty much CSS with a few extra niceties, it would seem sensible to extend on the existing VS support for CSS files.

We have started to look at VS SDK and managed to get as far as colouring all text blue (its a start). But before we start looking at the Lexer impl I really want to know if we can somehow extend whats already been done with CSS support.

Any pointers in the right direction would be appreciated.

Chris.

+1  A: 

This is straightforward in Visual Studio 2010, which is now in beta 2. The text editor is completely new and is designed to support this scenario. If you dig into the SDK you'll find a number of related examples.

For VS 2008 and earlier, you can't extend an existing editor. You have to provide a completely new editor that happens to duplicate all the functionality of the existing editor.

Steve Pudloski
-1: Extensibility API for adding support for a new language differs between 2008 and 2010, but the fact that you have to write a language service does not. You can't "extend" the built in languages aside from the user keywords in the C++ syntax highlighter (if that even counts).
280Z28
+1: you don't need to write a language service to modify colors in any document displayed in the vs2010 editor
sean e
+1  A: 

Regardless of whether you choose 2005, 2008, or 2010, you'll face the same choice - you can pick one or the other but in no way can pick both.

  1. Set .less files to open in Visual Studio's CSS editor - as is.
  2. Write a new language service for Visual Studio from the ground up, with a syntax highlighter and IntelliSense, for your language.

If you choose #2, then you'll be writing what's called a language service for Visual Studio, and there are lots of resources here and on the web (my blog has some). Be warned it's a non-trivial task once you get past simple syntax highlighting.

280Z28
Ok, well thats not quite what I wanted to hear but as long as I know that's fine. One other thing, do you usually find that your writing two parsers impls one for your DSL and a simpler one for VS integration or have you had success getting a single parser to work for both scenarios?
Owen
I've done it both ways, but currently I use one "light" lexer for syntax highlighting and another lexer/parser for semantics, IntelliSense, etc. Outlining and several IntelliSense operations are sometimes best handled by special-purpose parsers as well.
280Z28