Emacs gdscript-mode lsp-mode. How to setup lsp server?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By VanDeiMin

Do You have any advices how to configure lsp server for gdscript in emacs? On module site (GitHub - godotengine/emacs-gdscript-mode: An Emacs package to get GDScript support and syntax highlighting.) is only enigmatic:“To use it, you need to install lsp-mode on top of gdscript-mode and configure it. To install and configure lsp-mode, see the lsp-mode documentation.”
What does it mean “install lsp-mode on top of gdscript-mode”? Are there any special commands or techniques to do it in emasc? Lsp instalation page says gdscript lsp server must be installed manually and redirects user to main page of godot’s github.

If I try ‘M-x lsp’ in gdscript-mode i receive an error:
LSP :: Failed to connect to localhost:6005 with error message make client process failed: Connection refused, :name, gdscript::tcp, :buffer, nil, :host, localhost, :service, 6005, :nowait, nil, :tls-parameters, nil, :coding, no-conversion

:bust_in_silhouette: Reply From: AmusedBored

Changing this to an answer as it evolved

On my install of gdscript, the lsp server had been set to port 6008. This can be changed to 6005 in the editor settings. Once I did this and restarted Godot, gdscript-mode managed to connect to the server. Unfortunately, I cannot claim it is actually working well so far.

Overall, I’ve given up on connecting the gdscript-mode to the Godot lsp service. Even in the first few minutes of use, it was just too unstable. For clarity, I believe the problems are in gdscript-mode or lsp-mode, not Godot.

Big Thanks for Your answer.

It confirms what I deduced from lsp-server error I found in emacs day after I asked a question. I’ve changed the port as You suggested. (I have no idea how to change the port on the emacs-lsp-server).

Part of the problem was that, I supposed, there is no need to start up the engine to use the lsp-server. Im to nooby as a programmer to understand why is that. I suppose lsp-server is some kind of an object, not a library as I thougt, and must be somehow initialized to the memory.

However Godot must be started directly from emasc. If I start the engine from command prompt as usual, it shoots lots of errors, telling me the resource is not initilized and creates empty copy of edited script but with strange name: “.#NameOfTheSript.gd”.

Anyway it started to work just fine for Me, even if Emacs with lsp-mode enabled seems to be a little bit slower. Now i think the meaning of “install lsp-mode on top of gdscript-mode” is: 1. Install gdscript-mode. 2. Install lsp-mode. 3. Open script You want to edit in Emacs. 4. Turn on gdscript-mode 5. Start Godot from Emacs. 6. Enable lsp-mode.

Thats it for now. I’m willing to dive the subject deeper beacuse Emacs and Lisp had thrown a charm on me.

VanDeiMin | 2023-02-12 23:58

:bust_in_silhouette: Reply From: alcenium

There’s two solution for this problem:

  1. [Emacs] Change the value of lsp-gdscript-port to 6008 by:

    • Add (setq lsp-gdscript-port 6008) to your config file
    • Change the value using C-h v lsp-gdscript-port
  2. [Godot] Change godot language server port to 6005
    (Editor - Editor settings - General - Language Server - Remote Port)

Thank You for the answer.

VanDeiMin | 2023-04-11 16:07