GithubHelp home page GithubHelp logo

imposter / vscode-lua-vu Goto Github PK

View Code? Open in Web Editor NEW
6.0 4.0 2.0 293 KB

This is a Visual Studio Code extension providing Venice Unleashed type information and intermediate code generation to make mod development less tedious.

License: MIT License

TypeScript 83.33% ANTLR 16.67%

vscode-lua-vu's Introduction

logo

Vua

This is a Visual Studio Code extension providing Venice Unleashed type information and intermediate code generation to make mod development less tedious. It utilizes Sumneko's Lua extension for VS Code and adds an additional parser to read documentation from user code and generate intermediate code files to help the IntelliSense engine work with how classes and functions are defined in VU.

Usage

  • Install the extension (Currently only Windows is supported!)
  • Find Vua Commands command menu and then download and build the project templates and VU doc types using the Download and Build Content command
  • Create a new project by providing a name and a path using the Create New Project command
  • Write your code and enjoy type information

Features

The following are the supported and planned features for this extension:

  • Creating a new project
  • Updating cached project templates and documentation
  • Rebuilding intermediate code
  • Support for all Venice Unleashed types defined in the documentation
    • Frostbite types
    • Shared libraries/types
    • Server libraries/types
    • Client libraries/types
  • Support for generating type information for user code
  • Documentation support

Examples

The following is the recommended code style for user-defined classes:

---This is a customized user type containing public fields name and position
---@class MyObject
---@field name string|nil
---@field position Vec3
MyObject = class('MyObject')

---Constructor which initializes the class instance
---@param name string|nil
---@param position Vec3
function MyObject:__init(name, position)
    self.name = name
    self.position = position
end

---Get object's string representation
---@return string @ Returns a string representation of the object
function MyObject:ToString()
    return self.name .. ' : ' .. self.position
end

...

local obj = MyObject('obj', Vec3(1.0, 2.0, 3.0))

Changelog

See changelog for more information.

Acknowledgements

Some people I want to thank for their hard work.

Venice Unleashed Developers:

Contributors:

  • FlashHit For actively doing research and contributing to this extension ♥

For libraries and technologies used by this extension:

vscode-lua-vu's People

Contributors

flashhit avatar imposter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

foolhen flashhit

vscode-lua-vu's Issues

Update existing project

Maybe it would be nice to update an project. this would basically just override the project.workspace and all .vscode/settings.

Most use just the mod folder instead of a workspace/project. So maybe even that should work. So it would create a project.workspace and all .vscode/settings. And then close the folder and open the project.

Use generic annotation for GetSettings

Use —-@generics for ResourceManager:GetSettings(string: Setting)

So for example if I do local s_GameSettings = ResourceManager:GetSettings("GameSettings") it would automatically identify it as GameSettings

differ between integer & number

atm every int & float gets the type ---@type number.
It would be better to give int the type ---@type integer and float the type ---@type number. That way it's easier to know what vext is expecting.

Intermediate files still in old path

As others have observed, in v0.3.0 the intermediate files are still in the ext/component folders and not in the project root. This should not happen and needs to be investigated.

[bug] error when new project folder already exists

This error appears when creating a new project using vua when the project folder defined already exists even when empty.

Failed to execute action
ENOENT: no such file or directory, lstat
'C:\Users\*UserName*\AppData\Local\Programs\Microsoft VS Code\.git'

Error: ENOENT: no such file or directory, lstat
'C:\Users\*UserName*\AppData\Local\Programs\Microsoft VS Code\.git'

Vector types issue

Instead of just being a vector it should be also the type. ie:
SoundPatchAsset.outputNodes will only show it as a vector instead of vector|AudioGraphNodeData[]

Netsocket return type

Instead of:

---`SERVER/CLIENT`
---Attempts to read data from the socket. Returns the data and a status code. The length of the returned data will not necessarily be the same as the requested data length.
---@param length number @ The number of bytes to read.
---@return undefined
function NetSocket:Read(length) end

It should be:

---`SERVER/CLIENT`
---Attempts to read data from the socket. Returns the data and a status code. The length of the returned data will not necessarily be the same as the requested data length.
---@param length number @ The number of bytes to read.
---@return string
---@return integer
function NetSocket:Read(length) end

This way it returns both.

https://docs.veniceunleashed.net/vext/ref/shared/type/netsocket/#read

https://github.com/EmulatorNexus/VU-Docs/blob/master/types/shared/type/NetSocket.yaml

Also if there is some error or idk, it should maybe return any instead of undefined.

parser issue

---VEXT Shared ResourceManager:LoadBundles Hook
---@param p_HookCtx HookContext
---@param p_Bundles string[]
---@param p_Compartment ResourceCompartment
local s_LoadBundlesHook = Hooks:Install('ResourceManager:LoadBundles', 1, function(p_HookCtx, p_Bundles, p_Compartment)
	print("Compartment : " .. p_Compartment)

	for _, l_BundleName in pairs(p_Bundles) do
		print("Loaded bundle: " .. l_BundleName)
	end
end)

local s_LevelLoaded = false

local s_LevelLoadedEvent = Events:Subscribe('Level:Loaded', function(p_LevelName, p_GameMode)
	s_LevelLoaded = true
end)

local s_LevelDestroyedEvent = Events:Subscribe('Level:Destroy', function()
	s_LevelLoaded = false
end)

local s_PartitionLoadedEvent = Events:Subscribe('Partition:Loaded', function(p_Partition)
	if s_LevelLoaded then
		print(p_Partition.name)
	end
end)

This is causing an error:

grafik

Parser grammar incorrectly handles comments and base classes

The current grammar does not allow for specifying base classes in the doc comments. It also does not correctly handle single line comments.

The following would result in a syntax error

---@class MyClass:SomeBaseClass

The following would result in a syntax error due to being an "invalid" comment, even though it is perfectly valid.

-- [key] -> [value]

Code Snippets

Add support for code snippets for events and other common tasks.

Canceling new project creation isn't working

If you create a new project with vua it will ask for the mod name and then for the location/path. Then it says Enter to go on and ESC to abort/ cancel it, but it isn't working. If I press ESC it will still create the project. If I just minimize the window or whatever it will also create the project. So there is no way to cancel it.
The issue is that I have to enter the whole location address C:\Users\%User%\Documents\Battlefield 3\Server\Admin\Mods\<Your Mod Name>. So I would also suggest that the address that it is currently using is editable, so I don't have to write the whole path. Or at least let me minimize to copy the address from the window explorer.

Fix class usage

Atm you have to do: MyClass = class 'MyClass' instead of just class 'MyClass

Add support for nestedArrays, nestedTables and operators

The VU-Docs have nestedArrays, nestedTables and operators which are not currently implemented (or figured out) for the EmmyLua equivalent in the meta files.

This is required to finish up most of the VEXT related stuff for the 1.0 release.

Doc strings for type specification are not parsed correctly

An error is thrown by the parser when parsing the following code:

---@class TestClass
---@field array_nestedArray vector|vector[]|DataContainer[][]
---@field array_nestedTable vector|table<integer, DataContainer>[]
---@field table_nestedTable table<integer, table<integer, DataContainer>>
---@field table_nestedArray table<integer, vector|DataContainer[]>
local TestClass = class('TestClass')

The issue seems to be with the definition of the expression expDoc. This may require revision to completely support vector/array and table types.

add callback info

instead of:

---`SERVER/CLIENT`
---@param callback function @ A callback in the form `function(entity: Entity, event: EntityEvent): bool`.
---@return number
function Entity:RegisterEventCallback(callback) end

it should be

---`SERVER/CLIENT`
---@param callback fun(entity:Entity, event:EntityEvent):boolean
---@return number
function Entity:RegisterEventCallback(callback) end

Something like that if it is possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.