GDQuest / zed-gdscript

Zed support for the GDScript language
MIT License
37 stars 10 forks source link

Issues with indentation/scope #10

Closed zedzee37 closed 3 months ago

zedzee37 commented 4 months ago

Tested Versions

System Information

Ubuntu 24.04 LTS

Issue Description

When using this extension, the indentation of the code is often lost, specifically with for loops or if statements, where it just goes to the start of the line or the indentation level of the function.

Steps to Reproduce

Writing code such as:

func foo() -> void:
    for i in range(5):

and creating a new line results in the indentation level being lost.

zedzee37 commented 4 months ago

I should note that I have 'hard tabs' enabled for GDScript, simply to follow Godot's usage of tabs instead of spaces, but the same issue occurs when using spaces (and enabling spaces on the Godot side).

NathanLovato commented 3 months ago

Reopening because the attempted fix did not fully fix the issue. I reverted it for now.

I tried adding a generic query to target blocks on Python's model but couldn't get it working even if the query would compile, unfortunately. GDScript's parser doesn't have the notion of blocks in its grammar so I'm not sure how to capture them for indentation purposes.

NathanLovato commented 3 months ago

Here are issues that I can spot right now:

NathanLovato commented 3 months ago

Found the cause and a fix, Zed has some settings that don't seem to be documented that we kinda need to use for an indent-based language. I couldn't get indentation working great with tree sitter queries, but they're working well with these settings now.