Add support for Lua-debugging in IntelliJ-products.

Post your ideas and suggestions how to improve the game.

Moderator: ickputzdirwech

waitofaiorur
Inserter
Inserter
Posts: 30
Joined: Fri Aug 30, 2019 11:53 am
Contact:

Add support for Lua-debugging in IntelliJ-products.

Post by waitofaiorur »

TL;DR
Add support for EmmyLuaDebugger.
What ?
Allow instrument-mod to load the necessary c-library and make it available for use. It can be injected into the process dynamically, but I still wasn't able to actually make use of it. Sandbox is pretty tight :) As far as I can tell emmy_core is what's required.
Why ?
Support for multiple dev-environments will attract more modders. Also, diversity is nice.
Background (optional read)
Me and my friend want to develop a mod, and step-through debugging would be very helpful in that regard.
I'm aware of the awesome work of justarandomgeek, but my weapon of choice when it comes to development has always been IntelliJ. I could of course just learn to use vs-code, but after a long day of coding, learning a new language, a new API and a new editor is just too much.

I have also considered implementing support for DAP in Intellij since JetBrains are unlikely to ever do it, but I would much rather spend my spare time modding. The almost part also has me slightly worried. Old post so it might not be relevant though.

If support is added, I'd be more than happy to create a tutorial for new developers. I understand of course that allowing c-libraries to be loaded, can pose a security risk, but requiring a command-line option seems like a fair compromise.
User avatar
BiterUnion
Inserter
Inserter
Posts: 21
Joined: Fri Aug 19, 2022 7:58 am
Contact:

Re: Add support for Lua-debugging in IntelliJ-products.

Post by BiterUnion »

As an IntelliJ user myself, I would very much appreciate this.
lyvgbfh
Fast Inserter
Fast Inserter
Posts: 169
Joined: Fri Jul 10, 2020 6:48 pm
Contact:

Re: Add support for Lua-debugging in IntelliJ-products.

Post by lyvgbfh »

I would really like to use a jetbrains IDE to work on my mods, but I feel as long as Jetbrains puts off LSP support it's a pipe dream.
waitofaiorur
Inserter
Inserter
Posts: 30
Joined: Fri Aug 30, 2019 11:53 am
Contact:

Re: Add support for Lua-debugging in IntelliJ-products.

Post by waitofaiorur »

lyvgbfh wrote: Fri Apr 14, 2023 4:04 am I would really like to use a jetbrains IDE to work on my mods, but I feel as long as Jetbrains puts off LSP support it's a pipe dream.
Seems like there exists a plugin. Never tried it myself, but it does seem interesting.
There is also Fleet which I also haven't tried. Docs says it supports LSP natively.

I had some major-issues with the EmmyLua-plugin. The IDE would just hang indefinitely when opening some of the transpiled Lua-files.
LSP won't fix step-through debugging right? So I'm stuck with the plugin for now?

Luckily I have written a few IntelliJ-plugins myself, so I might just fix it, if the problem resurfaces.
I'm currently using typed-factorio and I intend to write the entire mod in TypeScript.

Seems like there are a lot of transpilers for Lua. I found one for C# as well. I know the devs aren't all that happy with Lua, so maybe transpilers can facilitate a transition towards something more modern. Preferably without killing the entire ecosystem :)
lyvgbfh
Fast Inserter
Fast Inserter
Posts: 169
Joined: Fri Jul 10, 2020 6:48 pm
Contact:

Re: Add support for Lua-debugging in IntelliJ-products.

Post by lyvgbfh »

waitofaiorur wrote: Fri Apr 14, 2023 9:48 am Seems like there exists a plugin. Never tried it myself, but it does seem interesting.
There is also Fleet which I also haven't tried. Docs says it supports LSP natively.

I had some major-issues with the EmmyLua-plugin. The IDE would just hang indefinitely when opening some of the transpiled Lua-files.
LSP won't fix step-through debugging right? So I'm stuck with the plugin for now?
lsp4intellij looks like it's for developers building for the IntelliJ platform, not for end users? I tried fleet but there's absolutely no documentation on the supposed LSP use - it looks like it's only internal for certain toolchains like rust-analyzer for now.

Debugging, yeah, you're going to be stuck with a plugin I think. LSP just makes it so people don't have to write their language analysis specifically for a certain IDE as far as I'm aware. I tried doing some tinkering in Rider with EmmyLua but I haven't found a solution for linting, as EmmyLua seems to enjoy leaving trailing spaces and the like.
waitofaiorur
Inserter
Inserter
Posts: 30
Joined: Fri Aug 30, 2019 11:53 am
Contact:

Re: Add support for Lua-debugging in IntelliJ-products.

Post by waitofaiorur »

Turns out dll-injection is actually supposed to work. I've posted an issue
Path-mapping must be handled, and it would be very helpful to break conditionally, so my suggestion still stands :)

Perhaps this plugin could be helpful? Seems pretty well maintained too.
waitofaiorur
Inserter
Inserter
Posts: 30
Joined: Fri Aug 30, 2019 11:53 am
Contact:

Re: Add support for Lua-debugging in IntelliJ-products.

Post by waitofaiorur »

I actually got it working after manually downloading some files and updating the plugin. Key was a adding a fixPath-function. The function in the picture is only almost correct. Hyphens are special in Lua apparently. They need to be prefixed with an escape-character: "%".
Post Reply

Return to “Ideas and Suggestions”