Warcraft 3 documentation
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation - Zinc documentation - WC3 Optimizer documentation

Notepad++ Jass/vJass syntax highlighter No New Posts WC3 Editing Tools

Started by
City17

0 Members and 1 Guest are viewing this topic.

Rating

Average Score - 5 / 5

« Created: August 12, 2022, 08:27:54 PM by moyack »

Notepad++ Jass/vJass syntax highlighter
on: August 12, 2022, 06:04:34 PM

Related Topics or Resources



Features:
  • 100% Jass2 syntax support
  • 95% for vJass (see below)
  • Partial support for JassHelper directives: //!
  • All current natives added for highlighting (v1.33)
  • All functions from common.j, blizzard.j, variables and constants
  • Different colors for blizzard.j, common.j's natives and variables
  • Colors made specifically for Notepad++ Obsidian theme (dark)
  • Default extensions: .j and .ai for Jass, .vjass for vJass

Jass syntax: only vanilla Jass2 keywords are highlighted. Good for learning basic Jass.
vJass syntax: extended syntax with vJass keywords and JassHelper. Good if you want to write/view vJass code.

There's no auto-completion support. (a) you can add it yourself (b) you should contribute to jassdoc to make it a reality: help describe the natives!

 


---

Installation

  • (Recommended): Set Notepad++ theme to Obsidian: Notepad++ toolbar (top) > Settings > Style configurator > Make sure "Global Styles" is selected on the left > Choose "Select theme: Obsidian" above
  • Notepad++ toolbar (top) > Language > (at the bottom) User Defined Language > Open User Defined Language Folder... > extract the .xml file to this folder (XML file has both Jass and vJass).
  • Restart Notepad++
  • Now you can select Jass/vJass syntax highlighting under Language

---

Introduction:

There were a few Notepad++ syntax highlighters made over the years to support Jass. The last one I used was by Moyack, it was alright but broke in various places like natives (very important to me). Also it's not made with a dark theme in mind. However it was last updated in 2020.

Before that, there was Nestharus' Notepad++ plugin to support Jass (2014). I don't remember if I got it working at all or didn't like something about it, but I didn't use it.

The reason Moyack updated his syntax highlighter was new "User Defined Language" features in Notepad++ and I can attest, that's very powerful (and frustrating to setup). But I did it! 12 hours spent or wasted ;)

---

vJass: What does not work?

I've gone through the entire vJass manual and copied examples from there. There's so much stuff, I doubt anyone actually knows all of it. However this piece will totally break the syntax highlighting:
Code: jass
  1. function interface Arealfunction takes real x returns real
This is a function interface prototype, after this line Notepad++'s code block detection will break. The colors will still work though (see big screenshot at the very bottom). I couldn't apply the same hack that I did for the regular Blizzard natives... that was pain too!

method/endmethod is a little broken. The colors are broken for "endmethod" and method's name. Further, methods cannot be folded as blocks (not recognized by Notepad++)

Finally I didn't know what to do with vJass'es special keywords: onInit, onDestroy, destroy, allocate, getType, typeid, create, evaluate, execute, .size, .width, .height. I left them without colored highlighting.

---

JassHelper directives

What you can see in the big screenshot is the best I could get. The syntax definitions of User Defined Languages weren't supposed to work with three different languages at once (Jass, vJass, JassHelper's macros). I had to sacrifice comment folding to highlight JassHelper's directives.

For example, "//! inject main" is the only valid directive, "//!inject main" is not. But Notepad++ will not let me do anything with spaces or multiple words. If you wanted to really improve upon that result, update the syntax plugin by Nestharus or write a new one.

---

Source included! I have left my work notes and scripts inside. If this ever becomes out-of-date, it'll be easy to update. Especially the native and functions lists.

I consider the Jass syntax file to be primary, but I had to change a lot of stuff to make vJass work. Although I left notes what keywords to add for vJass, please compare the two configurations yourself to see what had to be changed between the two.

---

How I made the "native" keyword work

It'll be only of interest, if you want to update this syntax highlighter or create your own for Notepad++.

Code: jass
  1. native ForForce takes force whichForce, code callback returns nothing
  2. // versus
  3. function receivesCallback takes code someFunc returns nothing
  4.         call someFunc()
  5. endfunction
  6.  
  7. function passAFunction takes nothing returns nothing
  8.         call receivesCallback(function someGlobalFunction)
  9. endfunction
  10.  

This was one of the reasons I started creating this highlighter and turned out to be the hardest. The issue here, you want Notepad++ to recognize function ... endfunction as a code block. You will encounter two conflicts:
  • "function" can be used as a standalone keyword, when passing a function as an argument
  • native does not start a block, it ends on the same line
So then you only have the two keywords at your disposal "takes" and "returns". Both are present in function... and native function... So if you start a new function block with either "takes" or "returns" then any native definition will break code blocks in the entire file, because they'd start a new block but never end it (with endfunction).
The workaround was to abuse delimiters. "Takes" is registered to start a new code block. However if "takes" is captured as part of a delimiter, it will NOT start a new code block. With this trick, natives are actually just highlighted "delimiter 7" keywords that grab the next "takes" word and thus suppress the creation of a code-block for native definitions.

Re: Notepad++ Jass/vJass syntax highlighter
Reply #1 on: August 12, 2022, 08:33:40 PM

Thanks for making a new version of this highlighter. When I return to Windows, I'll give a try. Keep the good work.


 

* Random Tools

SharpCraft, a managed replacement for Reinventing the Craft

Views: 7724
Replies: 0
Posted by WC3Mod
May 17, 2016, 10:20:13 PM

Jasshelper 2014-03-10

Views: 10826
Replies: 2
Posted by Glowackos
November 27, 2014, 09:39:52 AM

Oinkerwinkle's Animation Transferer

Views: 1269
Replies: 0
Posted by Oinkerwinkle
January 07, 2012, 12:53:18 AM

MDLVis

Views: 20809
Replies: 4
Posted by WC3Mod
February 19, 2011, 10:41:41 PM

vJASS Syntax Highlighter for notepad++

Views: 5398
Replies: 2
Posted by moyack
April 05, 2011, 03:43:08 PM
Vivir aprendiendo.co - A place for learning stuff, in Spanish   Chaos Realm - The world of Game modders and wc3 addicts   Diplo, a gaming community   Power of Corruption, an altered melee featuring Naga and Demon. Play it now!!!   WC3JASS.com - The JASS Vault + vJASS and Zinc   Jetcraft - A Starcraft II mod   WormTastic Clan (wTc)   Warcraft RESOURCES Reforged: Modelos, mapas, proyectos y mas...