godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.12k stars 21.18k forks source link

[LSP] No information returned when requesting the definition of a builtin name #43188

Open linkpy opened 4 years ago

linkpy commented 4 years ago

Godot version: 3.2.3

OS/device including version: Linux Mint

Issue description: When doing Ctrl+Click on a builtin name (print, Node, ...), the LSP server doesn't give any information back.

image

Related to https://github.com/godotengine/godot-vscode-plugin/issues/205.

Steps to reproduce: Write extends Node in a file. Ctrl-Click Node.

Minimal reproduction project: /

Notes: The expected behaviour, on the VSCode plugin side would be to open the documentation of the clicked element, which is possible to do and which is already implemented. For this the LSP server could just return a special location (for example, a JSON object like so {"documentation": true, "class": "@GDScript", "member": "print"}) which can be caught by the extension to open the relevant webviewer to show the documentation of the item or by adding a custom message, just telling VSCode to open a given class documentation.

Razoric480 commented 3 years ago

Been investigating LSP issues and got to this one.

The current issue I'm facing is that hovering over a variable/function/class and holding down the ctrl key sends a "definition" request, which is the same thing it sends when pressing F12 or doing a ctrl+click. I can modify GDScriptTextDocument::definition() to detect if we're over a native symbol that would have a documentation page, but if I make it open the documentation directly in that function, it'd do it before the click even occurs.

In the meantime, you can get around that by sending a "declaration" request (in VSCode that's right click: Go To Declaration). If you have your LSP server's Show Native Symbols In Editor turned off, that will open the native symbol's documentation in VSCode.