Visual Studio Code + Lua
Asked Answered
D

3

8

From what I can see, currently Visual Studio Code for Lua supports only syntax colorization and we can have formatting and some snippets with extensions. What I need to know is if there are or is planned some kind of Intellisense.

Dilly answered 10/10, 2016 at 16:50 Comment(5)
Any special reason why you are using visual studio code?Overstock
Yes, 'cause it's the best in it's category. Do you have some alternatives to suggest to me?Dilly
Apparently not with lua. I'd recommend you check out ZeroBrane Studio. It has autocomplete, syntax highlighting and colorization, debugging features, is really lightweight, and fully open source. It would be great if someone made an extension for lua in VS Code though.Overstock
I need something extensible for adding support (autocomplete/intellisense) for a specific modding context. Something like TypeScript descriptor, but since in LUA is not supported something like this, I need to implement it as an extension for the editor.Dilly
what is a specific modding context? don't speak in riddles if you want help.Thier
D
2

For custom syntax highlighting and code completion.
In VSCode, install extension: Lua by sumneko
I don't know how to properly use emmyLua so my example is not perfect, but it's easy to setup with minimal effort. My use case is NLua integrated in C#. Just need to edit files with some code completion.

create file: Demo.lua

-- set the class a dummy name, since creator is the same name
-- eg. class name Point, creator name also Point will work
--     but will result in messy suggestions
---@class cPoint
---@field X number
---@field Y number

-- creator
---@type fun( x:number, y:number ) : cPoint
Point = {};

---@class Shapes
---@field Origin cPoint
local Shapes = nil;

---@type fun( x:number, y:number )
function Shapes:Move( x, y ) end

---@class cCircle : Shapes
---@field Radius number
local cCircle = {};           -- define to be able to ...

---@type fun( angle:number )
function cCircle:Roll( angle ) end  --    ... add methods

---@type fun( x:number, y:number, r:number ) : cCircle
Circle = {};

---@class cRectangle:Shapes
---@field Width number
---@field Height number
local cRectangle = {};

---@type fun( origin:cPoint, w:number, h:number ) : cRectangle
Rectangle = nil;

-- no method overload, so just force it
---@type fun( x:number, y:number, w:number, h:number ) : cRectangle
Rectangle = nil;

create another file: test.lua

c = Circle( 10, 10, 10 );
c.Origin.X = 10;
c.Move( 10, 10 );
c.Roll( 10 );

r = Rectangle( Point( 0, 0 ), 10, 10 );
r = Rectangle( 10, 10, 10, 10 );

-- DETECTED ERRORS
c.origin.X = 10;
s = Shapes();
r.Roll( 10 );

-- NOT DETECTED
r = Rectangle( "hello" );
c = Circle(10,10);
c = Circle();
c.Roll();
Rectangle()

result

Demon answered 26/8, 2021 at 3:55 Comment(0)
W
4

Three years later and we have vscode-lua. From what I gather it has some kind of Intellisense and could possibly pe configured to find paths to the needed libraries, version specification (5.1, 5.2, 5.3), indent, line-width and other formatting related things... Give it a try!

Whelm answered 16/12, 2019 at 14:23 Comment(0)
D
2

For custom syntax highlighting and code completion.
In VSCode, install extension: Lua by sumneko
I don't know how to properly use emmyLua so my example is not perfect, but it's easy to setup with minimal effort. My use case is NLua integrated in C#. Just need to edit files with some code completion.

create file: Demo.lua

-- set the class a dummy name, since creator is the same name
-- eg. class name Point, creator name also Point will work
--     but will result in messy suggestions
---@class cPoint
---@field X number
---@field Y number

-- creator
---@type fun( x:number, y:number ) : cPoint
Point = {};

---@class Shapes
---@field Origin cPoint
local Shapes = nil;

---@type fun( x:number, y:number )
function Shapes:Move( x, y ) end

---@class cCircle : Shapes
---@field Radius number
local cCircle = {};           -- define to be able to ...

---@type fun( angle:number )
function cCircle:Roll( angle ) end  --    ... add methods

---@type fun( x:number, y:number, r:number ) : cCircle
Circle = {};

---@class cRectangle:Shapes
---@field Width number
---@field Height number
local cRectangle = {};

---@type fun( origin:cPoint, w:number, h:number ) : cRectangle
Rectangle = nil;

-- no method overload, so just force it
---@type fun( x:number, y:number, w:number, h:number ) : cRectangle
Rectangle = nil;

create another file: test.lua

c = Circle( 10, 10, 10 );
c.Origin.X = 10;
c.Move( 10, 10 );
c.Roll( 10 );

r = Rectangle( Point( 0, 0 ), 10, 10 );
r = Rectangle( 10, 10, 10, 10 );

-- DETECTED ERRORS
c.origin.X = 10;
s = Shapes();
r.Roll( 10 );

-- NOT DETECTED
r = Rectangle( "hello" );
c = Circle(10,10);
c = Circle();
c.Roll();
Rectangle()

result

Demon answered 26/8, 2021 at 3:55 Comment(0)
T
-1

If you want to know if a software has certain features or if they are planned, StackOverflow is the wrong place.

Go and read the information provided by the software's developer. If you don't find and answer there, contact the software's developer and ask them.

Think of a restaurant. If you want to know if they have something special on the menu or if they plan to put it on there, you better look into the menu and ask the chef or manager. Don't ask random people on the street if someone can help you...

As already mentioned in some comments there is a nice lightweight Lua IDE called ZeroBrane. Other than that there are plenty of extensible text editors.

http://lua-users.org/wiki/LuaIntegratedDevelopmentEnvironments

Thier answered 11/10, 2016 at 7:16 Comment(2)
Lots of Microsoft developers are on Stack Overflow and Microsoft flag this web site as a place where developer can find answers, then i think this is the right place for asking about Visual Studio Code.Dilly
And about ZeroBrane, yes it's good but I'm not searching for a Lua IDE but as I said I'm searching a way to bring Lua development on VSCode. If you can help nice, otherwise you don't have to respond.Dilly

© 2022 - 2024 — McMap. All rights reserved.