• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Notepad++ Jass/vJass syntax highlighter (2023-v8)

This bundle is marked as pending. It has not been reviewed by a staff member yet.

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!

Big image (140KB), test code:


Code repository (development): https://github.com/Luashine/notepadpp-jass-syntax


Installation


  1. (Recommended): Set Notepad++ theme to Obsidian:
    1. Notepad++ toolbar (top) > Settings > Style configurator > Make sure "Global Styles" is selected on the left > Choose "Select theme: Obsidian" above
  2. Notepad++ toolbar (top) > Language > (at the bottom) User Defined Language > Open User Defined Language Folder...
    1. Extract the .xml file to this folder (XML file has both Jass and vJass)
  3. Restart Notepad++
  4. Now you can select Jass/vJass syntax highlighting under Language
PS: If someone creates a color scheme for the white background/other themes, send it to me and I will include it.


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 ;)

PS: If you know/used other syntax highlighters, PM me the link so I can create a list of older stuff here.

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:
JASS:
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

225346-5a709714ea1989bc31e5005fac1de871.png


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

JASS:
native ForForce takes force whichForce, code callback returns nothing
// versus
function receivesCallback takes code someFunc returns nothing
    call someFunc()
endfunction

function passAFunction takes nothing returns nothing
    call receivesCallback(function someGlobalFunction)
endfunction

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:
  1. "function" can be used as a standalone keyword, when passing a function as an argument
  2. 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.

Changelog​

Actually fix HEX numbers (did not recognize A-F,a-f characters because I put them in the wrong "Extra" field)
Make Jass comments non-italic (vJass untouched)
Test file: Fix actual syntax errors in the plain jass example file
Update the screenshot accordingly
Jass & vJass: Fix incorrect hexadecimal prefix (only 0x, 0X and $ are valid).
Jass & vJass: bump version to 6, fix the hardcoded background style in this language style. I.e. unless "Enable global background colour" is checked, the letter background appeared white. Thanks @DrTema

vJass: Added to definitions of external preprocessors: "external, externalblock, endexternalblock"

If I remember correctly: removed incorrectly set Bold style from deep-blue colored natives.
Previews
Contents

Notepad++ Jass/vJass syntax highlighter (Binary)

Level 13
Joined
Jun 23, 2009
Messages
297
I've tried this plugin a bunch and it's alright but I decided to go back to the one by nestharus after a while. Summarizing my thoughts:

Things your highlighter does better:
  • You actually defined a bunch of things that aren't in nestharus's, so far I noticed "interface", "else" and "elseif", there might be more.
  • Since your highlighter is newer I imagine it includes at least a bunch, if not all, of the new natives added since "the modern patches" (1.28+).
Things nestharus's plugin does better:
  • It actually includes its own autocomplete that's perfectly functional and usable.
  • (Subjective) It only defines vJass, I feel like defining both JASS and vJass is not working well with your plugin right now for the simple reason that Notepad++ defaults to JASS upon loading .j files, at least as-is. vJass includes everything JASS has so if I had to open a JASS file in vJass mode it would still be perfectly readable, the opposite on the other hand looks bad and as somebody who mostly uses vJass having to switch language at every file is definitely annoying.
    Keeping both in but having your highlighter default to vJass for .j files and to JASS for .ai files (or even better to a JASS-AI defined language for them since you can't use blizzard.j stuff in .ai files) would be the best of both worlds.
    EDIT: Before you tell me .vjass is the "standard" extension for saving vJass files... never seen that one ever in my whole life. Also I'll admit .j files opened as JASS is a minor, subjective thing that can be overlooked since there's probably a way to change this behavior.
Things you both fail at:
  • No .ai only natives/functions (they're in common.ai), in other words no actual JASS-AI support. Seriously dudes, I can write JASS/vJass in the World Editor with syntax highlighting and autocomplete already but I can only write AI files in Notepad++, so what's up with that?
  • Not complete on the vJass syntax side. (No biggie imo)
  • You only ship with a dark theme, nestharus's one only ships with a clear theme. Maybe join forces to solve at least this? :gg: (This is also unimportant)
No, but seriously, ask nestharus if you can at least snag his autocomplete stuff to incorporate in this one. The best highlighter possible right now would be a merge of both your versions.

If I had to rate this right now I'd give it a 3/5 for both commitment shown and actual functionality, but I'll reserve judgment and keep an eye on this highlighter because it's clear it has potential and you can definitely make it better with time.

Good job so far, but it needs work. Just give us autocomplete and JASS-AI support and it becomes a 5 for me. :)
 
Last edited:
Level 19
Joined
Jan 3, 2022
Messages
320
@Michael Peppers Thanks for your review!

You actually defined a bunch of things
Yes I went by the JassHelper manual and added as much as was possible with the Notepad++ highlighting syntax.

new natives added
It says I added 1.33 natives and since there were none new added. Yes it's up to date in this regard.

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!
Auto-completion depends on this (I am waiting for) and will be eventually automatically generated. As far as I know, N++ doesn't need a code plugin for this. I am adding Trigger Editor definitions to jassdoc after that's done, auto-complete will make sense. Otherwise there are too few contributors to cover most simple usage scenarios.

for the simple reason that Notepad++ defaults to JASS upon loading files
Valid point. Here's my reasoning:
1. For working with only Jass, I don't want to be confused by vJass. Especially when opening raw war3map.j. My idea was to clearly separate vJass from Jass (not compatible with the game anyway): Use .j for Jass and .vjass for vJass as file extensions.
2. vJass highlighter evolved from the basic Jass version and I kept it this way until now in case of bugs. The vJass highlighter became very complex. If anything goes wrong with it, the base version is still alright. If people reported bugs (or lack thereof) I would be more inclined to merge them... but see point 1...

If you want to only work with vJass, you can import only the vJass version and/or add/remove the .j file extension from Jass highlighter.

That's a limitation of Notepad++, how many different functions can be added for highlighting. The input box is limited. I had to split up the lists. If I open an issue on their Github, would you help comment? I decided to exclude AI for this reason :(

Dark theme
I had ideas to allow color customization. Do you really use a light theme? Though I understand, not everybody uses Obsidian.
 
Level 13
Joined
Jun 23, 2009
Messages
297
That's a limitation of Notepad++, how many different functions can be added for highlighting. The input box is limited. I had to split up the lists. If I open an issue on their Github, would you help comment? I decided to exclude AI for this reason :(
Hm, I see, that's fair. I don't know how Notepad++ plugins work, would it be doable if the AI-version of JASS is defined as a separate language? It is more limited than JASS (doesn't support/accept blizzard.j functions), also standard JASS doesn't support common.ai natives/functions (unless defined into the code) so maybe that would work fine?
If you add an issue about it on github I'll be commenting no problem, just let me know in some way :)
I had ideas to allow color customization. Do you really use a light theme? Though I understand, not everybody uses Obsidian.
It's not a big deal, it's my personal preference and I flip-flop around themes in Notepad++. I could edit the files to change colors anyway.
 
Last edited:
Level 3
Joined
Mar 13, 2021
Messages
5
I made a parser for natives, functions, types and names to npp's auto complete but i gave up on adding descriptions since as far as i'm aware npp's baked in solution only supports plain text descriptions, perhaps it might need a plugin?

I think i got everything right but do tell if there's any issues and i'm reminded that i need a bigger screen. Also, i filtered a a few swapped functions, just the ones that have Swap in their name.

To install any file just drop them inside Notepad++\autoCompletion, filename or the defined language inside the xml file (<AutoComplete language="...">) must match with the language for it to work.

Edit: made it parse with ignore case by default and didn't include types (there's a switch for this now) and lastly, i added filtering for constants, i'm not aware if these are useful for ai files but i could add a switch for not parsing them in a file basis if needed, or make it easier to add them by using a txt file instead.
I filtered TRUE and FALSE since i don't believe anybody uses them and just gets in the way of typing these.
 

Attachments

  • hBAgZbQoPp.png
    hBAgZbQoPp.png
    64.5 KB · Views: 10
  • j2npp.7z
    207.8 KB · Views: 4
Last edited:
Level 3
Joined
Mar 13, 2021
Messages
5
Posting again to give an update. Added the following things to the parser:
  • Text wrapping.
  • Max description size.
  • Parsed md and parameters with slight changes (it's still just plain text and escaping isn't supported because i'm bad at this).
  • Code inside code blocks has its new lines accounted for so it looks nicer.
  • The ability to shorten parameter names and its types.
  • The ability to parse up to a specific version based on patch labels (patch labels need to be updated first for this to work correctly though).
  • Filtering is now done with an .ini-esque file
  • Cleaned up settings a bit
More or less what it should have been initially, the only issues left are that text wrapping could be done more orderly, code not marked as such isn't line respected and md escaping being ignored.
And autocomplete not working while typing with function hints but that's a npp issue
 

Attachments

  • notepad++_CVFxuyVB1D.png
    notepad++_CVFxuyVB1D.png
    14.2 KB · Views: 7
  • notepad++_e0ZeWLtsck.png
    notepad++_e0ZeWLtsck.png
    24.6 KB · Views: 7
  • ouS5yAfPm3.png
    ouS5yAfPm3.png
    18 KB · Views: 8
  • j2nppac.zip
    781.6 KB · Views: 2
Last edited:
Top