Skip to content

Commit

Permalink
plugin file support. better constructor detection
Browse files Browse the repository at this point in the history
  • Loading branch information
lunarwtr committed Mar 16, 2022
1 parent fdea209 commit 0c7e0ca
Show file tree
Hide file tree
Showing 7 changed files with 204 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to the "vscode-lotro-api" extension will be documented in th

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## [1.0.4] - 2022-03-15
### Added
- Improvement: Constructors on extended Turbine classes are now recognized
- Improvement: .plugin files are now supported
- Improvement: .plugincompendium files are now supported

## [1.0.3] - 2022-03-14
### Added
- Improvement: better support for opening plugin root folder as workspace
Expand Down
2 changes: 1 addition & 1 deletion Lua/Plugin/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function OnSetText(uri, text)
if altpname ~= nil then
pname = altpname
end
local def = ('---@class %s : %s\n'):format(name, pname)
local def = ('---@class %s : %s\n---@type fun():%s\n'):format(name, pname, name)
diffs[#diffs+1] = {
start = start,
finish = start-1,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "lotro-api",
"displayName": "LotRO API",
"description": "Lord of the Rings Online API",
"version": "1.0.3",
"version": "1.0.4",
"publisher": "lunarwtr",
"repository": {
"type": "git",
Expand All @@ -17,7 +17,9 @@
],
"icon": "img/vscode-lotro-api.png",
"activationEvents": [
"onLanguage:lua"
"onLanguage:plugin",
"workspaceContains:**/*.plugin",
"workspaceContains:**/*.plugincompendium"
],
"main": "./dist/extension.js",
"contributes": {},
Expand Down Expand Up @@ -49,6 +51,7 @@
"@vscode/test-electron": "^2.1.2"
},
"extensionDependencies": [
"sumneko.lua"
"sumneko.lua",
"redhat.vscode-xml"
]
}
}
15 changes: 15 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as vscode from 'vscode';
import * as path from 'path';

interface XMLSchemaAssocation {
pattern: string,
systemId: string
};

// this method is called when your extension is activated
export function activate(context: vscode.ExtensionContext) {
console.log("activate lunarwtr.lotro-api", context.extension.id);
Expand All @@ -23,6 +28,16 @@ export function activate(context: vscode.ExtensionContext) {
}
config.update("runtime.path",searchPaths);
}


const xmlConfig = vscode.workspace.getConfiguration("xml");
let schemasAssoc: XMLSchemaAssocation[] | undefined = xmlConfig.get("fileAssociations");
if (schemasAssoc) {
schemasAssoc = schemasAssoc.filter(a => !/\.plugin(compendium)?$/.test(a.pattern));
schemasAssoc.push({ pattern: '**/*.plugin', systemId: path.join(extensionPath!, 'xsds', 'lotroplugin.xsd')});
schemasAssoc.push({ pattern: '**/*.plugincompendium', systemId: path.join(extensionPath!, 'xsds', 'plugincompendium.xsd')});
xmlConfig.update("fileAssociations", schemasAssoc);
}
}

// this method is called when your extension is deactivated
Expand Down
82 changes: 82 additions & 0 deletions xsds/lotroplugin.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Plugin">
<xs:complexType>
<xs:sequence>
<xs:element name="Information">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The name used to load the plugin with the "/plugins load PluginName" as well as how it will appear in game in the "/plugins list" and "/plugins refresh" commands. If you use a plugin manager (a plugin that controls loading other plugins) this is also the name that will be listed in the manager.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Author" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The name of the plugin author and is only included for documentary/organizational purposes. This has no actual impact on the functioning of the plugin but can be accessed programatially using the Plugins table.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Version" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The version that will be displayed in the "/plugins list", "/plugins refresh" and plugin manager lists. This value can also be used programatically for tagging saved data and automatically processing data updates.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Description" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The text that will display in the Turbine Plugin Manager to describe the plugin
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Image" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The realtive path to a .JPG or .TGA file. Note, if the file is greater than 32x32 it will be cropped to 32x32. If the image is less than 32x32 it will be tiled. This image will be displayed in the Turbine Plugin Manager
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Package" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The path relative to the Plugins folder to the main Lua code file. Note that the path uses "." as a folder separator instead of "\" or "/". This is the first file that will be loaded, parsed and processed.
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element minOccurs="0" name="Configuration">
<xs:annotation>
<xs:documentation xml:lang="en">
The Configuration setting is optional and will allow a plugin to run in its own Apartment or address space.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:attribute name="Apartment" type="xs:string" use="required">
<xs:annotation>
<xs:documentation xml:lang="en"> ,
Allows a plugin to be unloaded without affecting other plugins or to prevent other plugins from
interfering with global values and event handlers. If your plugin does not need to be
unloaded and if it uses safe event handlers (discussed later) then you probably do not
need a separate apartment. Note that using a separate apartment will significantly increase
the amount of memory used by the Lua system since multiple copies of the environment and
global object must be created for each apartment.

One important thing to remember, Plugins are not unloaded, Apartments are unloaded.
That is, when you use the "/plugins unload ApartmentName" command you are unloading
all of the plugins that share that apartment.
</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
91 changes: 91 additions & 0 deletions xsds/plugincompendium.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="PluginConfig">
<xs:complexType>
<xs:sequence>
<xs:element ref="Id"/>
<xs:element ref="Name"/>
<xs:element ref="Version"/>
<xs:element ref="Author"/>
<xs:element ref="InfoUrl"/>
<xs:element ref="DownloadUrl"/>
<xs:element ref="Descriptors"/>
<xs:element ref="Dependencies"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Id" type="xs:int">
<xs:annotation>
<xs:documentation xml:lang="en">
The ID on lotrointerface.com for your plugin. This is the numeric portion in the URL that points to your plugin.
For Example: https://www.lotrointerface.com/downloads/info640-Waypoint.html would be 640
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Name" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The name of the plugin. This should match the value in your .plugin file
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Version" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The Version of the plugin. This should match the value in your .plugin file
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Author" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The author of the plugin. This should match the value in your .plugin file
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="InfoUrl" type="xs:anyURI">
<xs:annotation>
<xs:documentation xml:lang="en">
The url to view information about the plugin on lotrointerface.com
For Example: https://www.lotrointerface.com/downloads/info640-Waypoint.html
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="DownloadUrl" type="xs:anyURI">
<xs:annotation>
<xs:documentation xml:lang="en">
The url to download the plugin on lotrointerface.com
For Example: https://www.lotrointerface.com/downloads/download640-Waypoint
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Descriptors">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="descriptor"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="descriptor" type="xs:string">
<xs:annotation>
<xs:documentation xml:lang="en">
The path relative to the .plugincompendium file to a .plugin file that is to be installed
Use backslash "\\" for path separators
</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Dependencies">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="dependency"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="dependency" type="xs:int">
<xs:annotation>
<xs:documentation xml:lang="en">
The ID from lotrointerface.com of another plugin that is needed as a dependency for this plugin to operate.
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>

0 comments on commit 0c7e0ca

Please sign in to comment.