Jump to content

[MOOSE] Visual Studio Code - MOOSE implementation


Recommended Posts

I don't remember anyone having luck with the intellisense part so you are on your own here. If you do have any luck try sharing your findings here and on Moose Discord if possible, I know a great many people would like to move away from LDT.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

1. Install Visual Studio Code.

2. Install "Lua Language Server" extension in VSC (I use that one published by sumneko).

3. Download Moose source code ( https://github.com/FlightControl-Master/MOOSE/releases ).

4. Add that folder (from downloaded source code archive ) to your VSC Workspace: "..\Moose Development\Moose".

5. Create .lua file in that workspace.

6. Enjoy.

 

VSC with Lua Language Server treats all workspace .lua files as dictionaries, that's why I recommend you customize the Moose folder. I use everything myself and work very well. VSC at startup extends the LUA dictionaries with the content of the .lua files used in the workspace, which may take a while. For some reasons, some files are skipped (displayed "green") - just open them for a moment.

 

Pt. 5 is crucial - "Menu:> File> New File" does not work until you save the file.

 

PS: sorry for my google-translate English! :D

 

Thank You, sumneko, for Your great job!

https://github.com/sumneko

  • Like 1
Link to comment
Share on other sites

1. Install Visual Studio Code.

2. Install "Lua Language Server" extension in VSC (I use that one published by sumneko).

3. Download Moose source code ( https://github.com/FlightControl-Master/MOOSE/releases ).

4. Add that folder (from downloaded source code archive ) to your VSC Workspace: "..\Moose Development\Moose".

5. Create .lua file in that workspace.

6. Enjoy.

 

VSC with Lua Language Server treats all workspace .lua files as dictionaries, that's why I recommend you customize the Moose folder. I use everything myself and work very well. VSC at startup extends the LUA dictionaries with the content of the .lua files used in the workspace, which may take a while. For some reasons, some files are skipped (displayed "green") - just open them for a moment.

 

Pt. 5 is crucial - "Menu:> File> New File" does not work until you save the file.

 

PS: sorry for my google-translate English! :D

 

Thank You, sumneko, for Your great job!

https://github.com/sumneko

 

 

Thank you indeed for feeding back, this is a fairly common question and I will relay to MOOSE discord and sticky this information, several people will be delighted this can be done!

Cheers!!!!!

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

For several hours I was scratching my head, trying to configure something unnecessarily - it was enough to save the file ... :D But maybe it works so iteratively only for me.

 

code from sumneko does the trick!

 

In the extension settings, you can personalize something to your needs, e.g. the "library" management issue:

 

"Lua.workspace.library": {}

 

https://github.com/sumneko/lua-language-server/blob/master/.vscode/settings.json

 

However, this is not necessary. I'm glad I could help a little bit!

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

I just tried it but it seems there are still a few open points :/

 

E.g. when a group as a moose object is defined, StudioCode says "undefined Global" and it does not refer to the "GROUP" class available in the framework.

 

A part of IntelliSense is working for me, but mostly for self-written code.

 

It does look completely different if I create a new *.lua file directly within the *\Moose_Development\ folder - creating a file within the root-level of the Repository does not enable the intelli sense correctly.

 

Do you guys have it working really as good as the LUA-Tools? Because I would like getting rid of this IDE, it is very slow compared to Studio Code :(

Link to comment
Share on other sites

  • 10 months later...

I did some tests for working with Visual Studio Code (VSC) from Microsoft and Lua Development Tools (LDT) from Eclipse. In general, VSC is very optimized for this function. The main principle is that the file that will be edited (your_script.lua) needs to be in the same workspace as the moose.lua. I found that VSC can be prepared for the MOOSE framework with the following steps:

 

1. Install VSC.

 

2. Install "Lua Language Server" extension in VSC (publisher: sumneko).

 

3. Download the Moose framework. Only the Moose.lua file is required. Find the current file size in KB.

 

4. IMPORTANT STEP: Go to "Lua Language Server" extension settings and set the "Preload File Size" at any value greater than the Moose file size as found in step above (step 3). (see photo "Settings"). If the file is grater than the "Preload File Size" then the VSC will ignore the moose.lua file.

 

5.  Create a folder that will be your workspace (is the folder that the your_script.lua files will be worked). Place the file Moose.lua file in the workspace. (a folder that will contain the your_script.lua. (see photo workspace)

 

6. Open the VCS, go to "File > Open Folder" and select the workspace folder in your system. 

 

7. Create a new your_script.lua file and the IntelliSense is ready as the VSC will "scan" the moose.lua file (and any other file in the active workspace). (see workspace as the IntelliSense works as the LDT.

 

Enjoy.

Settings.png

Workspace.png

  • Thanks 2
Link to comment
Share on other sites

  • 6 months later...

Hi all!

I think we have some good news regarding this topic.

Yesterday I was able with great help from @Wingthor to configure and document all the process to have VSCode fully integrated with MOOSE and the DCS ME Debugging.

In this document you will see how to:

1) Have Intellisense configured VSCode for MOOSE (this is something already explained by @Costas_Ch in previous post).
2) Debugging MOOSE from VSCode
3) Integration between MOOSE Repo and our Missions. Making it possible to "debug individual .lua files of MOOSE", "check out between branches", "fetching changes from new commits in the repo" and all that really fast having the advantage of Dynamic Links

Note that this last step is optional, and something not many people will find it useful. Because they will be good just by dropping the big Moose.lua file into the workspace. Either way, for those that want to have a better integration between MOOSE and their workspace, in order to be able to fetch latest changes, navigate between branches, etc. And are willing to contribute to the project in the future. For those... I find this information really interesting (eventhough it's some more advanced stuff).
 

Happy Flying + Coding! 😀

VSCode_Howto_MOOSE_Intellisense_and_Debugging.pdf

  • Thanks 3
Link to comment
Share on other sites

  • 10 months later...
  • 3 months later...

I am getting the following error when trying to debug according to the guide.

Mission script error: [string "G:\DCS World OpenBeta\bin\jsDb_m.lua"]:4599: loop or previous error loading module 'debugger.transport.luasocket'

This wasn't happening before November at  some point. 

I followed the guide. Edited jsDBm.lua line 771.

All the files are in the correct place.


Edited by Apollonaut
Link to comment
Share on other sites

  • 10 months later...
  • 2 weeks later...
On 11/20/2023 at 1:07 AM, Zyll said:

can anyone confirm if they are getting intellisense for the DCS ME objects from dcs.lua? In LDT it worked great, in vscode it doesn't work for me.

For example, can you get intellisense for Group, Unit, Coalition, etc?

Thanks,

Sorry for late reply. Intellisence works for Visual Studio Code (VSC). You need to add a LUA extension to the VSC eg. EmmyLua. Then you need to add the scrips folder witin DCS world main folder to your worksspace in VSC (if you want). And/or other DCS lua libs.

If you are using Moose, you can add the uncommented version of the Moose.lua to your workspace, then not so many problems will be (falsely) reported, since Moose are using LUA docs for documentation.

Moose Include Reposotory, use then uncommented static version of Moose (Moose_lua)

 

  • Thanks 2
Link to comment
Share on other sites

Thanks @Wingthor for taking the time to respond. I unfortunately am still not quite sure I'm getting it.

So I do have intellisense working for Moose, as evidenced (I believe) in the screenshot below:
image.png

For simplicity sake, I have all my scripts in one folder, including Moose.lua, DCS.lua, mist etc. I assume the fact I'm not using the uncommented version of Moose would not impact the ability to show DCS.lua luadoc.

I'm using Sumneko's popular lua-language-server extension, which appears to work with vscode-lua-doc, and also gives credit to EmmyLua in the list of software it uses. Are you saying that EmmyLua includes other functionality that extends Sumneko's language server, and I should be loading both extensions together? 

When I try to bring up intellisense for a DCS coalition object, this is what I see:
image.png

The popup functions don't correlate to what actually is applicable to coalition (troops doesn't exist yet it came up in intellisense), and the intellisense doco gives the above error. To me, its like the luadoc in DCS.lua does not follow the same conventions used in Moose.lua, and given that its just a prototype file with no code, DCS.lua is just not working as expected for me.

LDT on the other hand worked, it seemed to know how to read the DCS.lua prototype, and I'd be thrilled to be able to make vscode behave similarly.

EDIT: 

>  Then you need to add the scrips folder witin DCS world main folder to your worksspace in VSC (if you want). And/or other DCS lua libs.

this is something I did not do, let me look into this as well.

EDIT2:

sadly the inclusion of C:\Program Files\Eagle Dynamics\DCS World OpenBeta\Scripts into the workspace didn't help


Edited by Zyll
Link to comment
Share on other sites

8 minutes ago, Zyll said:

Thanks @Wingthor for taking the time to respond. I unfortunately am still not quite sure I'm getting it.

So I do have intellisense working for Moose, as evidenced (I believe) in the screenshot below:
image.png

For simplicity sake, I have all my scripts in one folder, including Moose.lua, DCS.lua, mist etc. I assume the fact I'm not using the uncommented version of Moose would not impact the ability to show DCS.lua luadoc.

I'm using Sumneko's popular lua-language-server extension, which appears to work with vscode-lua-doc, and also gives credit to EmmyLua in the list of software it uses. Are you saying that EmmyLua includes other functionality that extends Sumneko's language server, and I should be loading both extensions together? 

When I try to bring up intellisense for a DCS coalition object, this is what I see:
image.png

The popup functions don't correlate to what actually is applicable to coalition (troops doesn't exist yet it came up in intellisense), and the intellisense doco gives the above error. To me, its like the luadoc in DCS.lua does not follow the same conventions used in Moose.lua, and given that its just a prototype file with no code, DCS.lua is just not working as expected for me.

LDT on the other hand worked, it seemed to know how to read the DCS.lua prototype, and I'd be thrilled to be able to make vscode behave similarly.

EDIT: 

>  Then you need to add the scrips folder witin DCS world main folder to your worksspace in VSC (if you want). And/or other DCS lua libs.

this is something I did not do, let me look into this as well.

 

This is what I get when typing `coalition`:

bilde.png

Here `coaltion`is picked from Moose `coalition`enum. Not sure where your intellisence is picking up the `coalition` keyword? Where you get `coalition.troops` from I don't know. Dont think its Moose database enums? Check if the coalition is defined elsewhere. It might get you in to trouble if you redefine Moose keywords.

 

 

Link to comment
Share on other sites

  • 1 month later...

Hi @Wingthor maybe coalition is a bad example, because as you pointed out there's an enumeration as part of Moose, but it also exists as an enum in the luadoc of DCS.lua.

I figured out where coalition.troops came from, I had to disable the "show words" setting in vscode intellisense which was finding all kinds of strings in my lua and suggesting them. Why that is a thing in vscode is beyond me.

So now my vscode is only making suggestions based on actual code in my lua scripts folder, great. If you wouldn't mind, would you show me what your vscode returns for country.id.?

My vscode identifies country as a table, based on an empty table called country that it finds in DCS.lua, but it has no country.id because it doesn't seem to be able to parse the luadoc to flesh out the intellisense, so vscode just has this and nothing more:

image.png

On the other hand, Eclipse with the LDT plugin seems able to parse the luadoc in DCS.lua and not just the actual lines of code, so it's intellisense returns the following:

image.png

 

these are the lines from DCS.lua where Eclipse is able to retrieve intellisense, and I'd love to be able to get vscode to do the same, because it really is a much better IDE. To me it feels like the language server support in Eclipse LDT is more robust than the lua language servers available for vscode.

do -- country

  --- [DCS Enum country](https://wiki.hoggitworld.com/view/DCS_enum_country)
  -- @type country
  -- @field #country.id id 
  
  
  --- [DCS enumerator country](https://wiki.hoggitworld.com/view/DCS_enum_country)
  -- @type country.id
  -- @field RUSSIA
  -- @field UKRAINE
  -- @field USA
  -- @field TURKEY
  -- @field UK
  -- @field FRANCE
  -- @field GERMANY
  -- @field AGGRESSORS
  -- @field CANADA
  -- @field SPAIN
  -- @field THE_NETHERLANDS
  -- @field BELGIUM
  -- @field NORWAY
  -- @field DENMARK
  -- @field ISRAEL
  -- @field GEORGIA
  -- @field INSURGENTS
  -- @field ABKHAZIA
  -- @field SOUTH_OSETIA
  -- @field ITALY
  -- @field AUSTRALIA
  -- @field SWITZERLAND
  -- @field AUSTRIA
  -- @field BELARUS
  -- @field BULGARIA
  -- @field CHEZH_REPUBLIC
  -- @field CHINA
  -- @field CROATIA
  -- @field EGYPT
  -- @field FINLAND
  -- @field GREECE
  -- @field HUNGARY
  -- @field INDIA
  -- @field IRAN
  -- @field IRAQ
  -- @field JAPAN
  -- @field KAZAKHSTAN
  -- @field NORTH_KOREA
  -- @field PAKISTAN
  -- @field POLAND
  -- @field ROMANIA
  -- @field SAUDI_ARABIA
  -- @field SERBIA
  -- @field SLOVAKIA
  -- @field SOUTH_KOREA
  -- @field SWEDEN
  -- @field SYRIA
  -- @field YEMEN
  -- @field VIETNAM
  -- @field VENEZUELA
  -- @field TUNISIA
  -- @field THAILAND
  -- @field SUDAN
  -- @field PHILIPPINES
  -- @field MOROCCO
  -- @field MEXICO
  -- @field MALAYSIA
  -- @field LIBYA
  -- @field JORDAN
  -- @field INDONESIA
  -- @field HONDURAS
  -- @field ETHIOPIA
  -- @field CHILE
  -- @field BRAZIL 
  -- @field BAHRAIN
  -- @field THIRDREICH
  -- @field YUGOSLAVIA
  -- @field USSR
  -- @field ITALIAN_SOCIAL_REPUBLIC
  -- @field ALGERIA
  -- @field KUWAIT
  -- @field QATAR
  -- @field OMAN
  -- @field UNITED_ARAB_EMIRATES
  -- @field SOUTH_AFRICA
  -- @field CUBA
  -- @field PORTUGAL
  -- @field GDR
  -- @field LEBANON
  -- @field CJTF_BLUE
  -- @field CJTF_RED
  -- @field UN_PEACEKEEPERS
  -- @field Argentinia
  -- @field Cyprus
  -- @field Slovenia
  -- @field BOLIVIA
  -- @field GHANA
  -- @field NIGERIA
  -- @field PERU
  -- @field ECUADOR

  country = {} --#country

end -- country

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...