{"id":403,"date":"2016-09-02T20:10:06","date_gmt":"2016-09-03T03:10:06","guid":{"rendered":"http:\/\/www.teamfizzgames.com\/Matt\/?p=403"},"modified":"2016-09-02T20:10:06","modified_gmt":"2016-09-03T03:10:06","slug":"hlsl-syntax-highlighting-for-sublime-text-3","status":"publish","type":"post","link":"https:\/\/www.teamfizzgames.com\/Matt\/hlsl-syntax-highlighting-for-sublime-text-3\/","title":{"rendered":"HLSL Syntax Highlighting for Sublime Text 3"},"content":{"rendered":"<p>Don&#8217;t worry, this&#8217;ll be a quick one.<\/p>\n<p>If you write shaders, then you&#8217;ve certainly dealt with the issue of what to write them in. \u00a0Since there&#8217;s no true shader IDE (And seriously, why isn&#8217;t there? \u00a0They&#8217;re mainstream enough at this point that I can&#8217;t imagine it&#8217;s a niche market anymore, which is what I assume is the reason for ignoring it.), you find a text editor that&#8217;s lightweight and customizeable enough to help you get the job done as well as possible and you just deal with it. \u00a0And in a lot of cases, someone eventually writes a basic syntax highlighter for your editor of choice, and most of us are happy just to get <em>anything<\/em> that we embrace it and carry on. \u00a0I experienced it with NShader on Visual Studio, with MJP&#8217;s file for NotePad++, and\u00a0with what I started with for Sublime Text 3 (sorry to whoever wrote it, I honestly don&#8217;t remember where it came from at this point).<\/p>\n<p>In the year or so that I&#8217;ve been using ST3, I&#8217;ve found it easy enough to customize and extend it that I&#8217;ve been highly motivated to actually do those things. \u00a0Part of that work has been building my own syntax file for HLSL. \u00a0Now, my syntax file isn&#8217;t overly complex or even as complete as I&#8217;d like it to be, but&#8230; regex (Sidenote: \u00a0if someone much better at regex than me looks at this and laughs at my pitifulness, I fully welcome help making improvements!). \u00a0However, what I did was define function definitions and callsites, and that opens up an interesting possibility in ST3 beyond just more syntax highlighting; with that information, if you put your shader files into a sublime-project file, you get automatically hooked up to ST3&#8217;s Goto Definition framework. \u00a0Here&#8217;s what that looks like:<\/p>\n<p><a href=\"http:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1.png\" rel=\"attachment wp-att-406\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-406\" src=\"http:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1-1024x280.png\" alt=\"syntax1\" width=\"800\" height=\"219\" srcset=\"https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1-1024x280.png 1024w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1-300x82.png 300w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1-768x210.png 768w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1-250x68.png 250w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1-150x41.png 150w, https:\/\/www.teamfizzgames.com\/Matt\/wp-content\/uploads\/2016\/09\/syntax1.png 1037w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/p>\n<p>And, once you have this working, it&#8217;s a short jump to getting a library-wide autocomplete functioning. \u00a0Unfortunately, I cannot share my autocomplete indexing solution, but I can share my syntax file. \u00a0<a href=\"http:\/\/www.teamfizzgames.com\/Matt\/download\/sublimetext\/hlsl.zip\">Here<\/a> it is! \u00a0Hopefully you enjoy it, and again I fully welcome suggestions for improvements. \u00a0Also, <a href=\"http:\/\/www.teamfizzgames.com\/Matt\/download\/sublimetext\/RockLobster.tmTheme\">here<\/a> is my theme file, if you&#8217;re interested in a very HLSL-specific color coding, but it&#8217;s absolutely not required.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Don&#8217;t worry, this&#8217;ll be a quick one. If you write shaders, then you&#8217;ve certainly dealt with the issue of what to write them in. \u00a0Since there&#8217;s no true shader IDE (And seriously, why isn&#8217;t there? \u00a0They&#8217;re mainstream enough at this point that I can&#8217;t imagine it&#8217;s a niche market anymore, \u2026 <a class=\"continue-reading-link\" href=\"https:\/\/www.teamfizzgames.com\/Matt\/hlsl-syntax-highlighting-for-sublime-text-3\/\"> Continue reading <span class=\"meta-nav\">&rarr; <\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[2],"tags":[9,30],"class_list":["post-403","post","type-post","status-publish","format-standard","hentry","category-graphicsdev","tag-hlsl","tag-sublime"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p39ImV-6v","_links":{"self":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts\/403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/comments?post=403"}],"version-history":[{"count":4,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts\/403\/revisions"}],"predecessor-version":[{"id":409,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/posts\/403\/revisions\/409"}],"wp:attachment":[{"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/media?parent=403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/categories?post=403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.teamfizzgames.com\/Matt\/wp-json\/wp\/v2\/tags?post=403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}