New Defold Plugin for IntelliJ

Hey folks :waving_hand:

You can install it from the marketplace: https://plugins.jetbrains.com/plugin/29184-defold-support.

More details on its README: GitHub - aridclown/Intellij-Defold: Defold coding and debugging support in IntelliJ

So far, it supports:

  • :file_folder: Project awareness – Detects Defold workspaces and keeps paths in sync.
  • :brain: Smart Lua editing – EmmyLua2 + LSP4IJ provide completion, annotations, syntax highlighting, linting, navigation, refactors, and other editor goodies for your Lua scripts.
  • :page_facing_up: Script templates – Create scripts from IntelliJ with the expected boilerplate.
  • :beetle: Debugger – Full mobdebug experience without starting the Defold editor: conditional breakpoints, run-to-cursor, expression evaluation, watches, inline values, call stacks, and coroutine support.
  • :rocket: Build + Run + Debug – Trigger clean, build, run, and debug from IntelliJ with automatic engine launching and port management.
  • :fire: Hot reloading – Reflect changes to Lua scripts with a simple hotkey.
  • :desktop_computer: Multi-platform – Works on Windows, macOS, (Linux untested).

Why?

As someone who has been using IntelliJ for over a decade, when I first started exploring Defold, I found it a bit challenging to adapt to VS Code.

Although I really appreciate all the effort the community has put into VS Code, I’ve never quite felt at home with that editor.

Anyways, it felt like the perfect time to start an IntelliJ plugin that goes a little beyond code highlighting.

No wheels reinvented?

I was sure to verify that we didn’t already have something started in the open-source community (GitHub), but I couldn’t find anything.

The projects I found are mainly focused on type checking, syntax highlighting, Lua annotations, and autocomplete:

  • IntelliJ-EmmyLua → the most mature plugin for Lua development in IntelliJ.
    • Most people use EmmyLua (version 1), which is great. However, it has a few drawbacks, particularly in terms of performance.
  • IntelliJ-Luanalysis → an EmmyLua fork for statically typed Lua.
    • It’s not been maintained for a while, it doesn’t work in the latest versions of IntelliJ, and most of its features are already supported by EmmyLua2.
  • @d954mas’s Defold-api-emmylua → a Defold API annotations generator for IntelliJ.
    • I wanted to remove the friction of manually having to generate these whenever a new Defold version pops up.

However, I wanted something more comprehensive, specifically that allowed me to leverage IntelliJ’s excellent debugging features. So I decided to make it from scratch.

Why EmmyLua?

The ā€˜Defold Support’ plugin is built on top of Intellij-EmmyLua2, which is much faster than its first version, has better support for type checking, supports various Lua versions (including Luajit), and leverages LuaLS instead of local Lua annotations for code completion, syntax highlighting, error detection, code navigation, etc.

It’s a mature and well-maintained ecosystem. The repository owner is super responsive, so whenever we hit a roadblock, we can help improve their repository (I’ve done it a few times already). Maturing Lua in the IntelliJ ecosystem means Defold in IntelliJ benefits as well.

What now?

While I made sure to test the plugin extensively, I’m sure I missed some important scenarios or didn’t catch all the bugs.

If you enjoy coding with IntelliJ as much as I do, I would appreciate your input and feedback on testing the plugin. Please share how it works with your Defold workflows, any missing features, desired additions, or potential bugs.

For instance, I haven’t tested it on Linux yet, so Linux users would be especially helpful :folded_hands:

11 Likes

I’ll have a go and see if I have a better time with Intellij than with VS Code. I’m on Linux. :wink:

Is this what the default Defold configurations do? I expected to see multiple Defold related configurations but instead it is empty. Not sure if a bug or intended. When I added a Defold configuration and ran it I get an error for some reason. I have only ever build from the editor so I don’t know much about bob.

ERROR:SCRIPT: log/log.lua:334: attempt to index global 'chronos' (a nil value)
stack traceback:
  log/log.lua:334: in function get_logger
  log/log.lua:365: in main chunk
  [C]:-1: in function require
  main/scenes/main/main.script:3: in main chunk

Arch Linux / Defold 1.11.2 / IntelliJ IDEA 2025.2.4 (Community Edition)

No other issues after a quick test afaik.

Edit: One thing I miss is this: Annotations Ā· LuaLS/lua-language-server Wiki Ā· GitHub automatically adding the annotation lines based on the function params after typing `---`is such a time saver. Not sure if this would need to be added in the emmylua ls though.

Also seems when pressing enter on a line that starts with ---does not automatically add new dashes on the next line. Not sure if this is a configuration thing somewhere hidden.

2 Likes

This looks like if the dependencies have not been fetched/downloaded (you can do that from bob using the fetch resolve command).

1 Like

You mean using the ā€œresolveā€ command in bob.jar?

Yes, thanks, updated my answer

1 Like

Cleaning doesn’t need to be the default behavior (I’m not sure whether you made it default or if users can configure it). We invested a lot of work into making cache invalidation reliable, and even in the editor we avoid performing a clean in most situations.

1 Like

That’s a good call! I never added the option for resolving the dependencies, so it seems like a good menu option, just like VS Code extension has done.

@NaakkaDev I’m gonna work on an update to include that, thank you very much for testing it out on Linux.

Thanks for the call. I have not. Today, the actions are mapped as follows:

  • Build: runs bob with build
  • Clean Build: runs bob with distclean
  • (TBD) Resolve: runs bob with resolve

2 Likes

I tried to set the beta build for the ā€œDefold install directoryā€ and this happens when intellij is opened (makes sense though):

Failed to fetch Defold annotations release asset url

org.json.JSONException: JSONObject["assets"] not found.

image

Another thing (1.11.2); I renamed my .emmyrc.json file, that I used with VS Code & Emmylua. Everything blow up. :smiley: All the defold globals are now unknown etc. I presume the defold annotations are somewhere where emmylua doesn’t look for them by default. I wonder if the plugin should create an .emmyrc.json file with related configs if its missing from the project root. Or maybe it wouldn’t be needed and something is broken.

Edit: Did not notice that the plugin would create a .luarc.json file. I had one so it didn’t and that resulted to derps.

Testing! I’m so thankful for your work on this plugin, as I’m also a long time Jetbrains IDE user :slight_smile:

3 Likes

Version 0.2.0 published with following improvements:

  • Plugin validated and working on Linux. Thanks @NaakkaDev for all the help here.
  • New Project menu to handle resolve dependencies - plugin also runs it once per project opening.
  • New Run config to allow running the build via Defold editor (better performance than using default bob). This allows devs to choose what tradeoff they prefer.
  • Better .luarc.json handling. Now, the plugin checks for the JSON file existence and only increments what it needs in case it’s already created (for other plugins use such as VS Code’s EmmyLua).
  • A handful of minor bugs.
9 Likes

@aridclown
I was very happy when I saw your post. Like you, I have been working with IntelliJ for many years, and switching to VS Code was difficult for me. However, after testing the Defold plugin several times, I noticed a few issues and inconveniences.

Some of the issues are here:

When I encounter an error and click on it in the Defold editor, the editor highlights the line with a noticeable delay (around 7 seconds). This is quite annoying. In addition, some errors are not detected at all. For instance, if I call a function without parentheses, no error is shown, whereas VS Code correctly reports it.

The editor also does not automatically insert parentheses when calling a function. It seems that IntelliJ sometimes cannot recognize that the symbol is a function. When I press ⌘B or ⌘ + click on a function, I expect it to either list all usages of that function, or jump directly to the location if it is used only once, but this does not work as expected.

I also receive warnings for some existing API constants, such as:

  • gui.EASING_OUTBOUNCE

  • gui.PROP_SCALE

  • gui.PROP_COLOR

The warning message is:

expected (string | constant) but found nil (EmmyLua: param-type-mismatch)

Similarly, I get the following warning:

Undefined field cancel_animation (EmmyLua: undefined-field)
on gui.cancel_animation

Additionally, code suggestions and autocomplete do not work when requiring Lua modules.

Based on your explanation, I feel that these issues may be related to an incorrect plugin setup on my side, or possibly a conflict with other plugins. I previously used the following plugin, which did not work for me and is now disabled:
https://github.com/d954mas/defold-api-emmylua

Nevertheless, I would like to thank you for your work, and I hope these issues can be resolved in the future. I am familiar with Kotlin and have been working as an Android developer for several years. Unfortunately, I have no experience developing IDE plugins, but if you can guide me, I would be happy to help and collaborate.

3 Likes

Hey @thawri, thank you so much for the thorough feedback and willingness to contribute.

Most of these items are already being discussed/tackled in their respective repositories. I dm-ed you so I can grab more details :slight_smile:

2 Likes