Linting and Code Navigation in the code editor

it’s literally the ‘Desktop game’ tutorial to which I added the dependency ‘https://github.com/defold/lua-language-server/releases/download/v0.0.5/release.zip’ in game.project

repro
logs

Thanks for sharing! There is nothing suspicious in the logs, and I tried the repro project and found code navigation working fine with F12/Shift F12. Have you tried restarting the Defold editor? :smiley:
Also, can you share what OS you are using, and what is the editor version? E.g. what’s editor’s SHA1 in Help → About?

Also, could it be that you are using a custom keymap? File → Preferences, General tab, Path to Custom Keymap field.

yes of course

2fa59062b9857a6eccefc43f2a90152b87c94847
Windows 10

yes and you will find it attached. however neither f12 nor shift-f12 are remapped

Keymap is probably the reason, you need to add F12 and Shift+F12 to your keymap file, see https://github.com/defold/defold/blob/dev/editor/src/clj/editor/keymap.clj for reference

I changed the mapping file by adding f12 and shift-f12 and now it works. two thoughts:

  • I downloaded the mapping file from the link found in Editor keybindings. Maybe you could consider keeping it updated
  • I thought the mapping defined locally was in addition to the default one. as it is now, for every shortcut that you add one must remember to add them locally too. anyway this is a mapping issue, not a linter one

Thank you for taking the time to find the solution

4 Likes

I tried copying the keycap.clj file vlaaad mentioned above.

It does not work and gives the error:
“java.lang.UnsupportedOperationException: nth not supported on this type: Symbol.”

What am I missing or doing wrong? I do not know where the default keyboard map is located, so I thought setting this as the keyboard shortcut file was the only way I could fix this problem.

You could try not using a custom keymap file altogether, then the F12/Shift+F12 binding will be set by the editor. Also, keymap file should not be a copy of keymap.clj, but instead it should only contain key combinations data, e.g. [["A" :add] ["Alt+Backspace" :delete-prev-word] ...].

Yeah, I tried not using a custom map, and F12 Shift+F12 did not work in that case either.

Can you describe how exactly it does not work? What’s your dependency in game.project? What happens when you press F12 on a code you want to navigate to? What’s your editor version?

For example, when I place the cursor over a function I want to navigate to the definition of and press F12, I get the message:
Screenshot 2023-10-06 at 4.23.10 AM

The game.project file has no dependencies.

The editor version is 1.6.0 (just updated it minutes ago).

Maybe the notification does not explain enough :smiley:
As described in the top post in this thread, you need to add https://github.com/defold/lua-language-server/releases/download/v0.0.5/release.zip as a dependency to game.project, then do ProjectFetch Libraries.

3 Likes

OK, that worked! I must’ve messed up something when I tried Project > Fetch Libraries before. I think I was trying to fetch from the downloaded version of release.zip file instead of getting it from the GitHub url. Or I think I also tried downloading the Lua language server, but it wasn’t your fork of it.

Anyway, thanks for the help!

3 Likes

Hello i am using Linux MX when hit F12 got this on the logs

2024-01-23 14:17:27.848 75701 [async-dispatch-5] WARN  editor.lsp.server - {:line 423, :message "Language server failed", :launcher {:command ["build/plugins/lsp-lua-language-server/plugins/bin/x86_64-linux/bin/lua-language-server" "--configpath=build/plugins/lsp-lua-language-server/plugins/share/config.json"]}}
clojure.lang.ExceptionInfo: Client response timeout: initialize
	at editor.lsp.jsonrpc$unwrap_response.invokeStatic(jsonrpc.clj:222)
	at editor.lsp.jsonrpc$unwrap_response.invoke(jsonrpc.clj:213)
	at editor.lsp.server$make$fn__29908$state_machine__19619__auto____29927$fn__29931$fn__29962$state_machine__19619__auto____30013$fn__30015.invoke(server.clj:400)
	at editor.lsp.server$make$fn__29908$state_machine__19619__auto____29927$fn__29931$fn__29962$state_machine__19619__auto____30013.invoke(server.clj:400)
	at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:978)
	at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:980)
	at clojure.core.async.impl.ioc_macros$take_BANG_$fn__19637.invoke(ioc_macros.clj:989)
	at clojure.core.async.impl.channels.ManyToManyChannel$fn__15659$fn__15660.invoke(channels.clj:99)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at clojure.core.async.impl.concurrent$counted_thread_factory$reify__15562$fn__15563.invoke(concurrent.clj:29)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.lang.Thread.run(Thread.java:833)

already have the dependency:
deps

after that clicked on “Fetch Libraries” and “Reload Editor Scripts”

restarted the editor, and still no luck, maybe i am missing a step.

best

Can you try executing the command to start the language server (it’s in the logs you posted) in the project root too see if it responds with errors there?

./build/plugins/lsp-lua-language-server/plugins/bin/x86_64-linux/bin/lua-language-server
1 Like

got this:

$ ./lua-language-server 
./lua-language-server: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by ./lua-language-server)
./lua-language-server: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./lua-language-server)

will try to solve these, thanks.

2 Likes

My distro is based on Debian 11 bullseye that have libc 2.31, to get a more recent version need to upgrade the distro.
On the other hand i downloaded lua-language-server-3.7.4-linux-x64 from

and it works, wonder if there is a way to point the plugin to use different language server?

I just tried this, at first I press F12, I see a popup saying “Cannot perform this action because of there is no LSP Language Server running…”, then I add the dependency link to game.project, press Fetch Libraries and then now I press F12, nothing happens… I don’t use a custom keymap either. What’s now? I even tried to restart the Editor but no help

F12 is Go to Definition, but currently, it works only for navigating the Lua code that exists on disk, i.e. your own files, and not dependencies. Could it be that you tried navigating to dependency or built-in definitions?

1 Like

Ah I see, it seems there are some situations it’s not showing the definition. For example: