godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.15k stars 97 forks source link

Unify language server with in-editor autocompletion provider #10977

Open atirut-w opened 1 week ago

atirut-w commented 1 week ago

Describe the project you are working on

N/A

Describe the problem or limitation you are having in your project

The autocompletion in Godot's built-in editor and LSP seems to be running on very different logic, as evidenced by frequent unrelated autocomplete entries when using the LSP.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

This proposal aims to resolve the aforementioned disparity by having both the built-in editor and the LSP use the same source of autocompletions. This effectively dogfoods the autocompletion system and makes the LSP act more like an adapter, and also make tracking LSP-related bugs easier as there would no longer be two sources of autocompletion. This can also be expanded to cover symbol lookup and other LSP-related things, too.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Current implementation

graph TD
    subgraph "Godot Engine"
        A[GDScript]
        B[Built-in Autocomplete]
        C[Built-in Editor]
        D[LSP Server]

        A --> B --> C
        A --> D
    end

    E[External Editors]
    D --> E

Proposed implementation

graph TD
    subgraph "Godot Engine"
        A[GDScript]
        B["Unified Language Server
        (Autocomplete, symbols, types, rename)"]
        C[Built-in Editor]
        D[LSP Adapter]

        A --> B
        B --> C
        B --> D
    end

    E[External Editors]
    D --> E

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

Built-in editor and LSP server is core.

HolonProduction commented 1 week ago

The LSP already uses the autocompletion behavior off the builtin editor and acts as adapter. The only problem was that till 4.3 the LSP will apply "smart resolve" if the builtin autocompletion yields no results. This was changed in https://github.com/godotengine/godot/pull/96684 so starting with 4.4 the results should hopefully be the same. Feel free to report disparities that you find.

You can disable "smart resolve" in the settings (which we should make the default IMO), this should align a lot of things more closely. The only feature I know of, that is directly implemented in the LSP is rename symbol.