Giter VIP home page Giter VIP logo

nshader's Introduction

NShader

Build status

This is a fork of Issam Khalil's Visual Studio 2013 fork of Alexandre Mutel's NShader syntax highlighting Visual Studio extension for shader languages. I've cloned it into my own github repository as I prefer to use github rather than CodePlex. The original nshader project is available here:

https://nshader.codeplex.com/

I have made some changes to Issam's version. You may now override the file type detection by specifying, on the first line of a shader file, a comment like so:

// shadertype=<type>

where <type> is one of:

hlsl
glsl
cg
unity

This will force the file to use the specified syntax highlighter. This is case sensitive and must appear exactly as above. Otherwise if the shadertype tag is not present, the file extension will be used to decide what type of highlighting to use. The extension mapping is as follows:

HLSL syntax highlighter - .fx, .fxh, .hlsl, .vsh, .psh, .fsh, .usf, .slfx
GLSL syntax highlighter - .glsl, .frag, .vert, .fp, .vp, .geom, .xsh, .comp, .sfx
CG syntax highlighter - .cg, .cgfx
Unity syntax highlighter - .shader, .cginc, .compute

You can also add extra extensions in Tools->Options->Text Editor->File Extension. Type in the file extension, select "NShader Editor" in the dropdown, and click "Add". Then when you open a file with any of those extensions they will use the NShader syntax highlighter. It seems that there is a bug in at least Visual Studio 2013 and possibly earlier versions where the setting can be forgotten and when you open a file in the list the syntax highlighting is not applied. However, the extension still appears in the list. To work around this you must remove and re-add the extension to the list. Also in Visual Studio 2015 if you load a file from the "recently used" list it doesn't seem to use the syntax highlighter, but if you load it from elsewhere (e.g. file->open or the Solution Explorer) it will work. This seems like a bug in Visual Studio, because it worked in VS 2013.

Note that if you add a file extension or use the shadertype tag you will need to close and re-open any currently open files to reflect the changes.

The existing file extensions that NShader previously recognised are still recognised, so if you are using any of those file types you don't have to do anything extra.

The user keyword mapping files now override the built-in mappings (in Issam's version duplicates were ignored). NShader will look inside %APPDATA%\NShader for custom map files with the following names:

GLSLKeywords.map
HLSLKeywords.map
UNITYKeywords.map

Any keywords in these files will replace the built-in mapping. For example, if float is mapped as a type in the built-in mapping, it can be changed to a keyword by adding it to the override file. Note that the CG highlighter is the same as the HLSL highlighter, so it doesn't have its own mapping. I've also made some small changes to the built-in mappings so that certain keywords are now 'types' instead of 'keywords'.

Finally, there is now an additional colour setting for the 'type' keywords (available in the Fonts and Colors dialog).

The latest build is available from Github in the releases section:

https://github.com/samizzo/nshader

The above build can be used to install NShader in VS 2013, 2015, and 2017.

This README and the built-in mappings are available in the zip file for reference.

nshader's People

Contributors

ikhalil avatar nicolaichuk avatar samizzo avatar yazgoo avatar

Watchers

 avatar  avatar

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.