Quantcast WoWDevelopment Sublime Package - WoWInterface
Thread Tools Display Modes
06-09-17, 12:04 PM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
WoWDevelopment Sublime Package

I updated the auto completion and syntax highlighting for WoW API Sublime package created by fRodzet, original forum here.

So whats new?
  • Added every global functions from the global namespace.
  • Added every event name.
  • Added every global constants.
  • Added every misc functions for widets (frameType, Anchors, Buttons, Strata levels, Layers, Blend modes).
  • Added Lua Enumeration globals.
  • XML support for Lua code in the script type tags.
  • Some helper snippets.
  • A new scheme. (Yep thats my scheme)

The syntax highlighing is a lot smarter and it does not depends on the default lua syntax at all. The XML one still reuses everything from the default XML syntax.

The Syntax have:
  • Support for inline anonymus functions, with proper argument coloring.
  • Highlight for: self and this.
  • Things like local string or frame.string will not color string as a global lua function.

You install it and use it the same way as before. (Sublime Package support coming soon™)

After i dump the snippet files into one big sublime-completions file, it would be nice if you guys could help me parametering the remaining API functions. Because there are a lot of them! (16k files)

Please report back any weirdness.

Download

Last edited by Resike : 06-09-17 at 03:50 PM.
  Reply With Quote
06-09-17, 06:45 PM   #2
Layback_
A Frostmaul Preserver
Join Date: Feb 2016
Posts: 297
I LOVE IT!!

The reason that I moved to Visual Studio Code was because there was an up-to-date WoW bundle created by a user.

But now I can stick to ST3 !!

btw, could I cautiously ask you to add a simple syntax highlight for TOC files if you some spare time?

Such as:
  • Tag
  • Comment

Last edited by Layback_ : 06-09-17 at 06:53 PM.
  Reply With Quote
06-10-17, 01:47 AM   #3
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Originally Posted by Layback_ View Post
I LOVE IT!!

The reason that I moved to Visual Studio Code was because there was an up-to-date WoW bundle created by a user.

But now I can stick to ST3 !!

btw, could I cautiously ask you to add a simple syntax highlight for TOC files if you some spare time?

Such as:
  • Tag
  • Comment
There is already a pacakge for that, search for: World of Warcraft TOC file Syntax

But i can put that into the package so it'll be complete.

Last edited by Resike : 06-10-17 at 02:01 AM.
  Reply With Quote
06-10-17, 12:36 PM   #4
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
  • Added TOC Syntax Highlighting
  • Added WoW Global Finder

Open a lua file, go to: Tool -> Build System -> select: WoW Global Finder
Every time you run the build (ctrl+b) it will list every global variables lines in the Sublime console window from that file.
  Reply With Quote
06-14-17, 05:58 AM   #5
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
- Updated for 7.2.5.
- Remove every files, since there was a lot of changes in the file dir tree.
  Reply With Quote
06-15-17, 06:18 AM   #6
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Okay team, the package is ready for your help.

Most work lies in the API Reference folder:

1. Pick an API from API Reference (parameterless).
2. Parameter it with arguments then move the snippet to API Reference, and delete it from API Reference (parameterless). (Would be nice to keep stuff alphabetically.)
4. If you find a function which should not be on the autocomplete list, Global Blizzard FrameXML/AddOn/GlueXML or any other Interface files, then move it to API Reference (blizzard) and delete it from API Reference (parameterless) (This file will be reviewed, saved and removed later.)
5. (If you would like to add stuff to the Widget References, just add them into the files directly. (Widget API, Widget Handlers))

How to parameter an API?

This is how a raw API will look like:
Code:
{
	"trigger": "AbbreviateLargeNumbers\t(...)",
	"contents": "AbbreviateLargeNumbers($1)$0",
},
The trigger thats triggering the autocomplete while you typing it then there is a \t in between anything after that is the description.

The contents is what the autocomplete will print out $1 is where the cursor will land first, $2 for second, $3 for third...$0 is the last cursor position.

If you want to highlight a whole words then it should looks like this: ${1:unit}, ${2:value}, \"${3:stringWithNoQuotationMark}\", ${4:\"stringWithQuotationMark\"}, ${5:[\"stringWithQuotationMarkInsideBrackets\"]}

So after we search for AbbreviateLargeNumbers in the Blizzard Interface code, we will see it accepts a single string value, and returns a formatted string. So we modify the code like this:

Code:
{
	"trigger": "AbbreviateLargeNumbers\t(\"value\")",
	"contents": "AbbreviateLargeNumbers(\"${1:value}\")$0",
},
Notes:
1. " needs to be escaped to \".
2. Tabs and new lines needs to be escaped like \t and \n.
3. Space, (, ), [, ], and , does not need escaping.

Since AbbreviateLargeNumbers has a return value that means we also want to make another snippet with _ added in front of it, which autocompletes it with the return value like this:

Code:
{
	"trigger": "_AbbreviateLargeNumbers\t(\"value\")",
	"contents": "${1:formattedValue} = AbbreviateLargeNumbers(\"${2:value}\")$0",
},
Notice that we had to change ${1:value} to: ${2:value}

It's very-very important to keep in mind if you make any typo in the .sublime-completions file than the whole file will not get loaded! Also you have to reopen Sublime sometimes after you made some changes in the completions files else you won't see the effect of the changes you made.

I plan to do 10-20 API functions per day myself. Would be nice to have some other volunteers too. The best would be if everyone could take care a whole letter of APIs, then there wouln't be any collisions.

You can fork/pull request, upload files, post here, send me a mail, send me a mail ingame, send me a pidgeon, i don't care as long as it's copyable/accessible.

Last edited by Resike : 06-15-17 at 06:29 AM.
  Reply With Quote
06-15-17, 04:37 PM   #7
Layback_
A Frostmaul Preserver
Join Date: Feb 2016
Posts: 297
I'm not sure if I'd be helpful, but I'll try to give it a shot.

Btw, would there be any style guide that you are expecting from us to follow?

Last edited by Layback_ : 06-16-17 at 02:54 AM.
  Reply With Quote
06-16-17, 12:21 AM   #8
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 834
I tried this out for a bit and it's quite nifty.

That said, your global functions scope will tag a block such as this:
Lua Code:
  1. local foo do
  2.   function foo()
  3.     -- stuff
  4.   end
  5. end

With that having been noted, why even include local/global as a highlighted scope in the syntax? Isn't that the purpose of the global finder?
__________________
Knowledge = Power; Be OP

Last edited by Gethe : 06-16-17 at 12:46 AM.
  Reply With Quote
06-16-17, 04:00 AM   #9
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Originally Posted by Gethe View Post
I tried this out for a bit and it's quite nifty.

That said, your global functions scope will tag a block such as this:
Lua Code:
  1. local foo do
  2.   function foo()
  3.     -- stuff
  4.   end
  5. end

With that having been noted, why even include local/global as a highlighted scope in the syntax? Isn't that the purpose of the global finder?
Actually fRodzet wrote the global highlight for functions it's only for making the globals even more visible. However it's not as accurate as the global finder. The question is that should i keep it or not? Because i don't think you can code it perfectly with only a syntax file, at least i don't know how to.

The better solution would a script which reads the whole file, collect all functions, and marks the global ones somehow if thats even possible.

Last edited by Resike : 06-16-17 at 04:09 AM.
  Reply With Quote
06-16-17, 04:08 AM   #10
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Originally Posted by Layback_ View Post
I'm not sure if I'd be helpful, but I'll try to give it a shot.

Btw, would there be any style guide that you are expecting from us to follow?
Noting fancy, tab indents with size 4, and keep the current indenting for readability.
  Reply With Quote
06-16-17, 08:38 AM   #11
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 834
Originally Posted by Resike View Post
The better solution would a script which reads the whole file, collect all functions, and marks the global ones somehow if thats even possible.
It is possible with SublimeLinter-luacheck. I should note that in order for this syntax to work with SublimeLinter you have to add to the syntax map.
__________________
Knowledge = Power; Be OP

Last edited by Gethe : 06-16-17 at 08:43 AM.
  Reply With Quote
06-16-17, 12:01 PM   #12
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Originally Posted by Gethe View Post
It is possible with SublimeLinter-luacheck. I should note that in order for this syntax to work with SublimeLinter you have to add to the syntax map.
That looks complicated as hell, at least for me.

Maybe we can just combine p3lims method which highlight stuff on the view, and the global finder itself. However this probably means that we need to rewrite the global finder to python and parse that through the current file. And my python knowledge is not that good.

At least i don't think we can pass the global finder tables to another python script directly, i could be wrong tho.
  Reply With Quote
06-16-17, 05:08 PM   #13
Layback_
A Frostmaul Preserver
Join Date: Feb 2016
Posts: 297
Here's what I've got so far

https://pastebin.com/UqzfiqzQ
(I'm not yet confident with GitHub, so................)

Referred from:

Last edited by Layback_ : 06-16-17 at 06:06 PM.
  Reply With Quote
06-16-17, 09:25 PM   #14
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 834
Originally Posted by Resike View Post
That looks complicated as hell, at least for me.

Maybe we can just combine p3lims method which highlight stuff on the view, and the global finder itself. However this probably means that we need to rewrite the global finder to python and parse that through the current file. And my python knowledge is not that good.

At least i don't think we can pass the global finder tables to another python script directly, i could be wrong tho.
There really isn't anything you would need to do regarding the WoW syntax.

SublimeLinter handles the indicators, and luacheck tells it what to indicate and where via the package in my previous post. It's on the user to install and set up the pieces, which imo is well worth it.
__________________
Knowledge = Power; Be OP
  Reply With Quote
06-17-17, 03:11 AM   #15
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Originally Posted by Gethe View Post
There really isn't anything you would need to do regarding the WoW syntax.

SublimeLinter handles the indicators, and luacheck tells it what to indicate and where via the package in my previous post. It's on the user to install and set up the pieces, which imo is well worth it.
But then how do you set it up then? I'm really not familiar with either of the packages.
  Reply With Quote
06-17-17, 04:17 AM   #16
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Originally Posted by Layback_ View Post
Here's what I've got so far

https://pastebin.com/UqzfiqzQ
(I'm not yet confident with GitHub, so................)

Referred from:
Looks good, i'll add em. However you really don't have to parameter the functions that belongs to frames created by Blizzard. Unless you really want to.

The goal would be to get rid of some functions so the autocompete could be more efficient and faster. And removing those blizzard functions would be the best solution, since authors don't really use those.
  Reply With Quote
06-17-17, 06:02 AM   #17
Layback_
A Frostmaul Preserver
Join Date: Feb 2016
Posts: 297
Originally Posted by Resike View Post
Looks good, i'll add em. However you really don't have to parameter the functions that belongs to frames created by Blizzard. Unless you really want to.

The goal would be to get rid of some functions so the autocompete could be more efficient and faster. And removing those blizzard functions would be the best solution, since authors don't really use those.
I'll keep that in mind !
  Reply With Quote
06-17-17, 07:36 AM   #18
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,203
Originally Posted by Layback_ View Post
I'll keep that in mind !
Also always use the latest live blizzard code, you can use mine or the townlong-yak one or extract it yourself. These are the ones that usually up to date.
  Reply With Quote
06-17-17, 11:33 AM   #19
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,597
Resike asked me on IRC to make something for highlighting globals, could look like this:

(Yes, io and arg should be highlighted, this was just an example while I work out the kinks)

The only downside is that you'd have to have Lua installed (it don't run Lua scripts, but it requires the Lua compilator to find the globals properly).

Last edited by p3lim : 06-17-17 at 11:40 AM.
  Reply With Quote
06-17-17, 05:24 PM   #20
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 834
Originally Posted by Resike View Post
But then how do you set it up then? I'm really not familiar with either of the packages.
SublimeLinter and associated plugins are installed via the Sublime Text package manager, like most other ST packages.

The actual luacheck binary can be installed in a few ways, all of which are in the GitHub README. Two of these methods will require you to install a lua interpreter, but they also have a windows .exe that bundles everything needed.


That said, my original main point was that how locals and globals are highlighted should be determined by the user and not a static part of the syntax.
__________________
Knowledge = Power; Be OP

Last edited by Gethe : 06-17-17 at 10:40 PM. Reason: grammar
  Reply With Quote

WoWInterface » Developer Discussions » Dev Tools » WoWDevelopment Sublime Package

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off