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

Are Type Tooltips Possible? #469

Open
munael opened this issue Jan 3, 2024 · 0 comments
Open

Are Type Tooltips Possible? #469

munael opened this issue Jan 3, 2024 · 0 comments

Comments

@munael
Copy link

munael commented Jan 3, 2024

In some LSP implementations, like for example PyLance for Python, you can get hints like this:
image

Right now with code-d I do not see any such tooltips when hovering over variables (or aliases, or function names, and so on), or after pressing ctrl+k ctrl+i.

Further, the auto-completion are extremely limited. I don't know if that's expected or I'm missing something.

For example, I don't get any auto-complete suggestions for struct methods.
image

What limited auto-complete suggestions are available also often do not show up if I'm writing in the middle of an expression. It has to be at the end of the line.

Ideally, I'd like tooltips to work in at least each of the following situations:

struct Thing {
    int x;
    int f(int y) => x + y;
    int f2(int y) {
        return x + y;
    }
}

struct Fing(T) {
    T t;
}

void func() {
    Thing thing;
    thing.f();  // Auto-complete: Suggest function `f`.
    thing.f2(); // This works, but not the short version.
    thing;      // Tooltips: Show type of `thing`.
    alias Fint = Fing!int;
    Fing fint;
    fint.t;     // Tooltips and Auto-complete: Should show `t` as having type `int` not `T`.
}

Range copy(Range)(Range range)
if (isInputRange!Range)
{
    static if (isRandomAccessRange!Range)
    {
        const tlen = range.length;
        const slen = range.length;
        assert(tlen >= slen,
                "Cannot copy a source range into a smaller target range.");

        immutable overlaps = () @trusted {
            return source.ptr < target.ptr + tlen &&
                   target.ptr < source.ptr + slen; };
        // Can any tooltips at all be shown in this situation?
        // 1. Types in `overlaps`.
        // 2. The typing of `.length` in `range`, based on the checks in `isRandomAccessRange` which must pass for this static if branch to be active.
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant