Giter Club home page Giter Club logo

linguist's Introduction

Linguist 0.4 README

0 Description

Linguist is an extension for Visual Studio 2010 allowing customizable syntax highlighting based on file names. Support for new languages may be easily added using regular expressions to identify the various language elements and language elements may be customized using different fonts, point sizes, colors, and font styles (e.g. bold and italic). The built-in languages include C#, C++, C, Python, Makefiles, patch files, etc.

To install the extension close studio and double-click the Linguist.vsix file. To uninstall the extension select the Extension Manager…​ item from Studio’s Tool menu, select Linguist, and press the Uninstall button. To upgrade the extension uninstall the old version and install the new version.

To check for newer versions of the extension visit github. The software is distributed under the terms of the MIT.X11 licensing agreement (see Licence.txt).

1 Operation

When the extension starts up for the first time it will create standard and custom directories inside %LOCALAPPDATA%\Linguist or %USERPROFILE%\AppData\Local\Linguist (typically this will be something like C:\Users\<user name>\AppData\Local\Linguist). The standard directory will contain the built-in language and style files. The custom directory will be empty. When the extension starts up again old or missing files in the standard directory will be added or updated.

Files within the custom directory can be used to define new languages or to override files within the standard directory. Errors are written to a Log.txt file in the AppData directory.

Language and style files are written using a simple line-oriented file format. Lines that start with a # are comments. Lines with only white space are ignored. Fields start with an identifier, followed by a colon, followed by arbitrary text. Identifiers start with a letter followed by alpha-numeric characters, underscrores, and dashes.

Testing source code changes with the solution is quite simple: make your change, press F5, and a special instance of Studio will launch with the new version of the extension active. Breakpoints may be used normally.

2 Style File

The Styles.field file is used to define how to render the various language elements. For example the default style for Makefile targets is:

  • Name: target

  • ForeColor: DarkGreen

  • PointSize: 14

  • Bold: true

The following fields can be used within a style file:

  • Name: the name of the language element (this is the only required field).

  • FontName: the name of a font, e.g. Consolas or Verdana.

  • PointSize: the font size, e.g. 12.

  • ForeColor: an X11 color name (Red), a hex color (#FF0000), or a decimal color 255,0,0.

  • BackColor: an X11 color name (White), a hex color (#FFFFFF), or a decimal color 255,255,255.

  • Bold: true if the element should be in bold, and false otherwise.

  • Italic: true if the element should be italicized, and false otherwise.

The default element is special and applies to all text within a document. Other elements override any styles used by the default element. Changes to Styles.field files require a restart of Studio to take effect.

3 Language Files

Language files are used to define the language elements used by the language. The language elements are matched using globs and the elements are matched using .NET regular expressions. The regexen are compiled using RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline (so dot does not match new line characters). If parenthesis are used within a regular expression they must be non-grouping (i.e. (?: pattern)).

Here is an example:

  • Language: ini

  • Globs: *.ini

  • Comment: \x23 .* $

  • Preprocess: ^ \[ [a-zA-Z] [a-zA-Z0-9_ ]* \]

The following fields can be used within a language file:

  • Language: the name of the language, e.g. makefile.

  • Globs: space separated list of file name globs where the meta-characters are * and ?, e.g. Makefile *.mk.

  • Element: the name of a language element followed by the associated regular expression. The name may be Attribute, Command, Comment, Default, DiffLoc, Emphasis, Header1, Header2, Header3, Header4, Header5, Italic, Keyword, Keyword2, Markup, Method, Monospace, NewText, Number, OldText, Preprocess, Region, ShellVariable, String, Target, Type, or Type2.

Changes to language files in the custom directory take effect while Studio is running (although you may have to scroll to see them).

linguist's People

Contributors

jesjones avatar

Stargazers

Angus H. avatar Rick Sladkey avatar Charles Strahan avatar Mauricio David avatar Jesse Vorisek avatar

Watchers

Jesse Vorisek avatar James Cloos avatar

linguist's Issues

Multiline Regex

Hello!

I'm trying to make multiline regex but it's not working. My expression is: anything between @{ and @} (but not include @{ and @})

I try:

Header2: (?<=@{)(?:.|\n|\r)*?(?=@})

or

Header2: (?<=@{)[\s\S]*?(?=@})

does not work. Do you have any idea?

Thanks

Linguist.vsix file not present, .sln does not open properly

There is no Linguist.vsix file anywhere in the package, which makes it impossible to install the plugin easily. I tried to compile the .sln myself, but it doesn't open properly (error when opening Linguist/Linguist.csproj: "The project type is not supported by this installation."). This makes me very sad, because I would love me some Sublime Text 2 highlighting, but I need some VS features that the former does not provide. Ideas?

Linguist crashes after saving a new cpp file

Go to File->New->File...
This should create TextFile1.txt
Put some C++ code in the file, for example "#include "
Save the file as "hello.cpp".
Observe crash.

The issue seems to be a stack overflow in Linguist::GetClassificationSpans.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.