Skip to content

Type hint via codelens for pipeline operator #251

Open

Description

@amiralies

fsharp / ionide has this feature
image

maybe we can have similar feature (note that // at end of line are not comments they are virtual texts)

Activity

  1. cristianoc commented on May 25, 2021

    @cristianoc
    Collaborator

    Is that while you type? Or just like code lenses it stays there?

  2. amiralies commented on May 25, 2021

    @amiralies
    ContributorAuthor

    It stays,
    You can give it a try on gitpod with https://github.com/ionide/playground

  3. cristianoc commented on May 25, 2021

    @cristianoc
    Collaborator

    Thanks.
    Looking at it, at least for me, it raises more questions than anything else.
    Do you really need those long pipes, to justify showing types on every step.

  4. cristianoc commented on May 25, 2021

    @cristianoc
    Collaborator

    And if you do, how much added value do you get, in particular in terms of removing resources for building some other features and prioritise this one instead.

  5. amiralies commented on May 25, 2021

    @amiralies
    ContributorAuthor

    It's quite useful imo. i find myself adding intermediate variables in pipelines when reading code to actually see what is happening.

    About priority, I think it's not a high priority feature. I'm exploring features from other extensions/language-server to see how can we improve experience of rescript extension i'm adding my ideas here to achieve this in long term. For now I think stablizing current features is more important.

  6. added
    enhancement
    on Jun 6, 2021
  7. added a commit that references this issue on Jun 6, 2021
  8. alarbada commented on Sep 6, 2021

    @alarbada

    Unfortunately with the current rescript pipe formatting this enhancement is impossible:

    let add = (x, y) => x + y
    3
    ->add(3)
    ->add(2)
    ->add(4)
    ->Js.log

    Gets formatted into:

    let add = (x, y) => x + y
    3->add(3)->add(2)->add(4)->Js.log

    However, maybe codelens could be implemented for let declarations, like the vscode-ocaml-platform plugin does:
    image

    (Sorry for the bad quality, image gotten from here)

    I don't know how difficult is this to implement, it looks easier to me than @amiralies suggestion, and it is quite helpful aswell.

    What do you guys think?

  9. amiralies commented on Sep 6, 2021

    @amiralies
    ContributorAuthor

    There's an issue on syntax repo about smart printing pipelines.

    speaking of lens fot let bindings , I also think that's an improvement we can work on but for me hover is enough for let bindings but hovering on pipelines do not give enough information.

  10. Mng12345 commented on Dec 15, 2021

    @Mng12345

    The pipe operator should get tips from ide, but only the first pipe get tips, the second and others get nothing. this make us very tired when coding with some complex library for finding the function of type.

  11. aspeddro commented on May 23, 2022

    @aspeddro
    Collaborator

    This feature is specified in LSP version 3.17. See textDocument/inlayHint Request.

    rust_analyzer and tsserver already implemented type hint.

  12. zth commented on Jun 2, 2022

    @zth
    Member

    This might be a good issue for a new contributor to experiment with. We have all we need in the analysis bin I think, just need to put the pieces together.

    However, we need to think about whether we can provide a good enough experience given that we don't have continuous type information without saving (and successfully compiling). No way around experimenting with it and seeing how it works in practice, imo.

    Please ping me if you'd be interested in taking a stab at this, and we can discuss the details. This work would mainly be in OCaml.

  13. added
    help wanted
    good first issue
    on Jun 2, 2022
  14. aspeddro commented on Jun 10, 2022

    @aspeddro
    Collaborator

    Hey @zth, I'm playing with ocaml and I did some tests.

    The behavior is not responsive on save. I need to save twice. I don't know why this happens. When I save once and run it through the CLI the type returned is correct.

    dune exec rescript-editor-analysis inlayHint ~/Desktop/learning-rescript/src/Demo.res 0 0

    0 and 0 is a range for full lines.

    • Only let bindings has type hint.
    screencast-2022-06-10_02.46.13.mp4
  15. zth commented on Jun 10, 2022

    @zth
    Member

    Very cool!! Great work! 😄

    I think we can leverage the "inlay hint refresh" LSP request here: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_inlayHint_refresh

    We already have a mechanism in the server listening to when compilation finishes. Maybe you could try hooking into that, and dispatch an inlay hint refresh request there as compilation is done?

  16. zth commented on Jun 10, 2022

    @zth
    Member

    @aspeddro let me know if you need help with that btw, I'd be happy to fix that. If so, open a PR with your changes and I can edit it there.

  17. aspeddro commented on Jun 10, 2022

    @aspeddro
    Collaborator

    @zth ok.

    I'm fixing vscode, I had to update dependencies so everything was breaking.

    moving forward.

    image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions