Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDscript LSP docstring and function signature problems #51617

Open
aMOPel opened this issue Aug 13, 2021 · 2 comments
Open

GDscript LSP docstring and function signature problems #51617

aMOPel opened this issue Aug 13, 2021 · 2 comments

Comments

@aMOPel
Copy link

aMOPel commented Aug 13, 2021

Godot version

3.3.2.stable

System information

Ubuntu 20.04, Intel HD graphics, GLES3

Issue description

EDIT: Added 3.

  1. Docstrings aren't found by the language server, when all arguments are spread over multiple lines.
  2. Default parameters that are a variable, aren't displayed with a type in the returned documentation.
  3. The documentation returned for .new() calls, is the one from GDScript.new(). This is useless, instead it should be the documentation from the _init() in the instantiated class. Or how else are you supposed to know what parameters the constructor takes?

Steps to reproduce

I'm using neovim with lspconfig, but i don't think that has anything to do with the documentation returned by the godot language server.
1.

# test docstring
func test(a : int, b := [], c:= defaults) -> void:

works

func test(a: int, b: Array, c) -> null

test docstring
# test docstring
func test(a : int,
b := [],
c:= defaults
) -> void:

works

func test(a: int, b: Array, c) -> null

test docstring

BUT

# test docstring
func test(
a : int,
b := [],
c:= defaults
) -> void:

doesn't return the docstring any longer. This is especially unfortunate, because gdformat from the gdtoolkit (the only gdscript formater i found) formats long function definitions like this.

func test(a : int, b := [], c:= defaults) -> void:

gives func test(a: int, b: Array, c) -> null as documentation returned by the language server.
However defaults is a Dictionary with inferred type, so it should be possible to at least display the type. But displaying the default values as well would be really nice i think.

Node.new()

Hover gives me this:

	func GDScript.new(...) -> Variant

Returns a new instance of the script.

For example:



	var MyClass = load("myclass.gd")
	var instance = MyClass.new()
	assert(instance.get_script() == MyClass)



	func NativeScript.new(...) -> Variant

Constructs a new object of the base type with a script of this type already attached.

*Note*: Any arguments passed to this function will be ignored and not passed to the native constructor function. This will change with in a future API extension.


	func PluginScript.new(...) -> Variant

Returns a new instance of the script.

Function signature this:

func GDScript.new(...) -> Variant
────────────────────────────────────────────
	func GDScript.new(...) -> Variant

Returns a new instance of the script.

For example:



	var MyClass = load("myclass.gd")
	var instance = MyClass.new()
	assert(instance.get_script() == MyClass)

Thanks a lot for the great work <3

Minimal reproduction project

No response

@Razoric480
Copy link
Contributor

Finally getting a chance to get back to this.

  1. Is already fixed in 4.0 and is only an issue in 3.x
  2. Ditto
  3. Still an issue in 4.0

Will investigate and see what I can fix, depending on my findings.

@Razoric480
Copy link
Contributor

Razoric480 commented Sep 26, 2021

Correction: 2 is fixed in 4.0 as far as showing the variable type for the default variable, but it doesn't show that there's a variable in it (and in fact reports it as null, which is wrong.)

I've issued fixes to 1 and 3. I'm not sure where to start to fix 2, however, as it's outside the scope of the LSP and into the GDScript parser proper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants