Skip to content

lsp inlay hints #364

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

Closed
MangoIV opened this issue May 16, 2024 · 24 comments
Closed

lsp inlay hints #364

MangoIV opened this issue May 16, 2024 · 24 comments
Labels
enhancement New feature or request

Comments

@MangoIV
Copy link
Contributor

MangoIV commented May 16, 2024

Feature description

It would be super cool if you could support the new lsp inlay hints for code lenses, they look much better than what we have now. I also wonder if there's a possibility to make code lenses look a tad nicer, e.g. not include control sequences and excessive amounts of white space (especially in imports).

This will start working with neovim version 0.10!

Thanks for considering!

@MangoIV MangoIV added the enhancement New feature or request label May 16, 2024
@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

Ah I think this is something to be supported by the hls? What kinda thing are the virtual text then? Why are they not supported by neovim proper? Hmmmm

As always I’m kinda confused

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

Hey 😄

inlay hints and code lenses are different LSP requests.
It's on the hls roadmap, but I have no idea when it will be done haskell/haskell-language-server#2938.

Activity seems to have picked up recently though.

@mrcjkb mrcjkb closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2024
@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

haskell/haskell-language-server#4131

There’s a GSOC student working on this!

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

What kinda thing are the virtual text then?

The virtual text you're seeing are code lenses. It's another LSP specification, which I believe has existed for longer than inlay hints.
That would explain why hls implemented a lot of things as code lenses, for which inlay hints would be a better fit today.

The main difference is that code lenses come with an action (e.g., you can evaluate doctest snippets, or add imports or type signatures).

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

Do you know what’s up with the control sequences and the spaces on code lenses? Is that something that hls does wrong? Or is this something that happens because all of these guys are written for vscode?

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

I'm not sure. VSCode does display code lenses differently than neovim, because neovim as a tui doesn't support different font sizes.
They are a lot smaller in vscode, so I guess that could be the reason.

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

do you just get these as strings?

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

haskell-tools doesn't do much, besides enable and auto refresh code lenses by default.
The feature itself is implemented in neovim.

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

interesting, why is it that the standard lsp client doesn’t display these then? Also do you know where I’d have to go with these issues? I e what may cause the visual noise displayed in some of the code lenses?

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

why is it that the standard lsp client doesn’t display these then?

I think that's just a decision by the maintainer. It could add quite a bit of noise and be too controversial to be enabled by default in neovim core.
@mfussenegger, maybe you can answer this better than I can? 😄

I e what may cause the visual noise displayed in some of the code lenses?

I'm not sure there's a good solution to this, because it would involve overriding vim.lsp.codelens.on_codelens.
I do this in my personal config, to add a prefix to the title, but I never really noticed any noise - Do you have a concrete example/screen shot?).
That would be too hacky for haskelll-tools though.

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

IMG_3385

this is an example. It has weird amount of spaces, no?

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

There’s also the case where it renders “line breaks” in inferred type signatures.

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

image

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

as you can see it inserts these ^@ and then again, a weird amount of spaces :D

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

image

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

Ah, I guess those could be so that it inserts formatted text on multiple lines when you call vim.lsp.codelens.run()?

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

I think so, yes, although it has also reliable been messing up these for me 😂

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

perhaps one could do something like replacing all consecutive whitespaces by one space in the code lenses? I think that would make it look a lot nicer...

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

perhaps one could do something like replacing all consecutive whitespaces by one space in the code lenses? I think that would make it look a lot nicer...

Perhaps. But I think this would have to be implemented in neovim core. Overriding the core function is a dirty hack, and would be brittle.

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

argh, that sucks; I don't know if we want to do this in general, do you think i should open an issue in the neovim repo?

@mrcjkb
Copy link
Owner

mrcjkb commented May 16, 2024

There's an open draft PR that reworks codelens rendering:

That might allow overriding the codelens handler properly once it's done.
Until then, I would suggest overriding it in your config.

@MangoIV
Copy link
Contributor Author

MangoIV commented May 16, 2024

Yeah, now I only need to find how, thank you for dropping the link :)

@MangoIV
Copy link
Contributor Author

MangoIV commented May 17, 2024

neovim/neovim#28807

I went off and fixed it 😅

@MangoIV
Copy link
Contributor Author

MangoIV commented May 17, 2024

package = pkgs.neovim-unwrapped.overrideAttrs (old: {
      patches = old.patches or [] ++ [
        (pkgs.fetchpatch {
          name = "strip-consecutive-white-spaces.patch"; 
          url = "https://github.com/mangoiv/neovim/commit/ea0a9163cb37e8444465b81abbed82c54134c12e.patch"; 
          hash = "sha256-LQwS+yJucin5AlXTPa3O95Zwjw4RerniPtNT8ctw0AU=";
        })
      ];
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants