# Linting and Code Navigation in the code editor

**URL:** <https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465>\
**Category:** Announcements\
**Created:** [January 19, 2023, 9:54am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465 "2023-01-19T09:54:35Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlaaad](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vlaaad/32/10538_2.png) [@vlaaad](https://forum.defold.com/u/vlaaad)\
**Post date:** [January 19, 2023, 9:54am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/1 "2023-01-19T09:54:35Z")

</div>

Today we’ve released a new version of the editor that can show lints in the code editor. The linting is implemented using [Language Server Protocol](https://microsoft.github.io/language-server-protocol/), which hopefully will enable us to add more improvements to the code editor in the future.

To try out the linting, you first need to ensure you are running the latest version of the editor ~~and then add this dependency in your `game.project`: [https://github.com/defold/lua-language-server/releases/download/v0.0.5/release.zip~~](https://github.com/defold/lua-language-server/releases/download/v0.0.5/release.zip~~)

**UPDATE #1** : A newer version will allow the editor to lint the whole project when building it.

**UPDATE #2** : The editor now supports code navigation powered by Language Servers. Use F12 for _Go to Definition_ and Shift F12 for _Find References_ actions.

**UPDATE #3** : We now include code completions from language servers in the code completion popup.

**UPDATE #4: Now Lua language server is built into the editor.**

Once you add the dependency, you need to perform **Project → Fetch Libraries** and **Project → Reload Editor Scripts** actions.

Then, the editor will use [our fork](https://github.com/defold/lua-language-server) of sumneko’s lua-language-server that uses Luacheck to lint your edited files.

Additionally, we updated our editor scripts manual with new [language servers](https://defold.com/manuals/editor-scripts/#language-servers) section that describes how to add other language servers to do linting in the editor. For example, I experimented with using vscode’s [JSON language server](https://www.npmjs.com/package/vscode-json-languageserver), to lint JSON files with JSON schema. I didn’t make it an extension though because it needs a nodeJS runtime to run which is like 80 Mb per platform. Another interesting language server to integrate into Defold would be a linter for our shader files, maybe based on [glsl-language-server](https://github.com/svenstaro/glsl-language-server) or something similar.

Try it out and tell us what you think!

---

<div class="post-metadata">

**Author:** ![gianmichele](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gianmichele/32/24028_2.png) [@gianmichele](https://forum.defold.com/u/gianmichele)\
**Post date:** [January 19, 2023, 10:58am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/2 "2023-01-19T10:58:00Z")

</div>

This is great! Looking forward to trying it.

Out of curiosity, will this stay as an extension or will it be integrated with the editor directly?

---

<div class="post-metadata">

**Author:** ![Pawel](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pawel/32/24623_2.png) [@Pawel](https://forum.defold.com/u/Pawel)\
**Post date:** [January 19, 2023, 10:59am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/3 "2023-01-19T10:59:19Z")

</div>

Wow! 🤩

Is it for beta 1.4.2 or stable 1.4.1 release Editor?

---

<div class="post-metadata">

**Author:** ![vlaaad](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vlaaad/32/10538_2.png) [@vlaaad](https://forum.defold.com/u/vlaaad)\
**Post date:** [January 19, 2023, 11:02am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/4 "2023-01-19T11:02:13Z")

</div>

Long-term: once we add support for code features like goto definition/find references, we will integrate the `lua-language-server` into the editor distribution.

---

<div class="post-metadata">

**Author:** ![vlaaad](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vlaaad/32/10538_2.png) [@vlaaad](https://forum.defold.com/u/vlaaad)\
**Post date:** [January 19, 2023, 11:03am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/5 "2023-01-19T11:03:41Z")

</div>

Currently it’s in 1.4.1 stable, but it should be in the beta soon (I merged into beta awhile ago, it’s being built on CI).

---

<div class="post-metadata">

**Author:** ![benjames171](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/benjames171/32/34759_2.png) [@benjames171](https://forum.defold.com/u/benjames171)\
**Post date:** [January 19, 2023, 1:40pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/6 "2023-01-19T13:40:13Z")

</div>

> [@vlaaad](#):
>
> Try it out and tell us what you think!

Really good so far! Have tidied up my scripts quite a bit already.

---

<div class="post-metadata">

**Author:** ![gmvbif](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gmvbif/32/21830_2.png) [@gmvbif](https://forum.defold.com/u/gmvbif)\
**Post date:** [January 19, 2023, 2:35pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/7 "2023-01-19T14:35:33Z")

</div>

Is there a window that shows all problems from linter?

---

<div class="post-metadata">

**Author:** ![vlaaad](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vlaaad/32/10538_2.png) [@vlaaad](https://forum.defold.com/u/vlaaad)\
**Post date:** [January 19, 2023, 3:09pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/8 "2023-01-19T15:09:05Z")

</div>

No, there is only highlighting in the code file

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 19, 2023, 9:57pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/9 "2023-01-19T21:57:30Z")

</div>

> [@gmvbif](#):
>
> Is there a window that shows all problems from linter?

This is will be added in an upcoming release!

---

<div class="post-metadata">

**Author:** ![MasterMind](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mastermind/32/31839_2.png) [@MasterMind](https://forum.defold.com/u/MasterMind)\
**Post date:** [January 20, 2023, 12:44pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/10 "2023-01-20T12:44:30Z")

</div>

Gave it a try and it is working great.

> [@vlaaad](#):
>
> Another interesting language server to integrate into Defold would be a linter for our shader files, maybe based on [glsl-language-server](https://github.com/svenstaro/glsl-language-server) or something similar.

I think this would be an excellent addition. For those wanting to explore and learn about shaders for the first time and experienced users as well.

---

<div class="post-metadata">

**Author:** ![aglitchman](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/aglitchman/32/19432_2.png) [@aglitchman](https://forum.defold.com/u/aglitchman)\
**Post date:** [January 20, 2023, 12:45pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/11 "2023-01-20T12:45:24Z")

</div>

> [@vlaaad](#):
>
> Try it out and tell us what you think!

Thank you so much! I thought that I was writing the perfect code (I’m kidding 😁 ) - the linter detected some really weird bugs.

Overall, it works great! Will it support `.script_api` from third-party extensions? Now the linter highlights the calls to native extensions as `accessing undefined variable`.

Plus, the console log syntax highlighting has been missing since the linter update - [IDE: The console doesn't have syntax highlighting · Issue #7297 · defold/defold · GitHub](https://github.com/defold/defold/issues/7297)

---

<div class="post-metadata">

**Author:** ![vlaaad](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vlaaad/32/10538_2.png) [@vlaaad](https://forum.defold.com/u/vlaaad)\
**Post date:** [January 20, 2023, 1:03pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/12 "2023-01-20T13:03:46Z")

</div>

I wrote down in the [linter issue](https://github.com/defold/defold/issues/3885) that we want to pipe `.script_api` information to the language server, thanks for reminding me about it 🙂

Regarding console syntax highlighting, as we discussed in the issue, the fix should be released soon.

I’m so glad linting is useful!!!

---

<div class="post-metadata">

**Author:** ![ross.grams](https://forum-defold.b-cdn.net/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ross.grams](https://forum.defold.com/u/ross.grams)\
**Post date:** [January 20, 2023, 6:01pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/13 "2023-01-20T18:01:23Z")

</div>

Is there a way to customize the LuaCheck options?

---

<div class="post-metadata">

**Author:** ![vlaaad](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vlaaad/32/10538_2.png) [@vlaaad](https://forum.defold.com/u/vlaaad)\
**Post date:** [January 20, 2023, 6:43pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/14 "2023-01-20T18:43:20Z")

</div>

Create and edit the `.luacheckrc` file in the project root.

---

<div class="post-metadata">

**Author:** ![WhiteBoxDev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/whiteboxdev/32/36080_2.png) [@WhiteBoxDev](https://forum.defold.com/u/WhiteBoxDev)\
**Post date:** [January 20, 2023, 6:49pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/15 "2023-01-20T18:49:12Z")

</div>

I don’t understand how to make this work. I added the module as a project dependency and reloaded editor scripts but nothing changed or pops up while in the script editor.

---

<div class="post-metadata">

**Author:** ![vlaaad](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/vlaaad/32/10538_2.png) [@vlaaad](https://forum.defold.com/u/vlaaad)\
**Post date:** [January 20, 2023, 7:50pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/16 "2023-01-20T19:50:10Z")

</div>

What is your editor sha in **Help → About**? Are there errors in today’s log file ( **Help → Show Logs** )?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 20, 2023, 10:12pm UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/17 "2023-01-20T22:12:36Z")

</div>

> [@vlaaad](#):
>
> Create and edit the `.luacheckrc` file in the project root.

It’s this file: [Configuration file — luacheck 0.26.0 documentation](https://luacheck.readthedocs.io/en/stable/config.html)

---

<div class="post-metadata">

**Author:** ![WhiteBoxDev](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/whiteboxdev/32/36080_2.png) [@WhiteBoxDev](https://forum.defold.com/u/WhiteBoxDev)\
**Post date:** [January 21, 2023, 2:13am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/18 "2023-01-21T02:13:58Z")

</div>

sha: e0ad4769ad5b83c60b185b54ff889f4437b0d128

I do see an error here:

```lua
2023-01-20 20:09:19.895 25585 [async-dispatch-8] ERROR editor.lsp.server - {:line 226, :message "Language server process failed to start", :launcher {:command ["./build/plugins/lsp-lua-language-server/plugins/bin/x86_64-win32/bin/lua-language-server.exe" "--configpath=build/plugins/lsp-lua-language-server/plugins/share/config.json"]}}
java.io.IOException: Cannot run program "C:\Users\MyName\Documents\Game Development\Defold\Projects\Games\MyGame\.\build\plugins\lsp-lua-language-server\plugins\bin\x86_64-win32\bin\lua-language-server.exe" (in directory "C:\Users\MyName\Documents\Game Development\Defold\Projects\Games\MyGame"): CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
	at editor.lsp.server$fn__28420.invokeStatic(server.clj:77)
	at editor.lsp.server$fn__28420.invoke(server.clj:69)
	at editor.lsp.server$fn __28405$G__ 28400__28412.invoke(server.clj:66)
	at editor.lsp.server$make$fn __28803$state_machine__ 19501 __auto____ 28820$fn __28824$fn__ 28832.invoke(server.clj:224)
	at clojure.core.async$thread_call$fn__19752.invoke(async.clj:484)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
	at java.base/java.lang.ProcessImpl.create(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:487)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:154)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
	... 10 common frames omitted
2023-01-20 20:09:19.919 25609 [clojure-agent-send-off-pool-2] INFO editor.boot-open-project - {:line 408, :message "project loaded"}
2023-01-20 20:09:20.285 25975 [JavaFX Application Thread] INFO editor.defold-project - {:line 890, :message "Cached save data in system cache.", :total 189, :retained 154, :unretained 35, :limit 20000}

```

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 21, 2023, 7:36am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/19 "2023-01-21T07:36:45Z")

</div>

Can you please check that path and see if it is missing the file or of it perhaps is a permission issue?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [January 21, 2023, 8:15am UTC](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465/20 "2023-01-21T08:15:25Z")

</div>

> [@WhiteBoxDev](#):
>
> `The system cannot find the file specified`

Could you try a path without a space ” ” in it?

[Next page](https://forum.defold.com/t/linting-and-code-navigation-in-the-code-editor/72465.md?page=2)
