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

Any way to make it adjust to inlay hints #37

Closed
luispinto23 opened this issue May 24, 2024 · 10 comments · Fixed by #38
Closed

Any way to make it adjust to inlay hints #37

luispinto23 opened this issue May 24, 2024 · 10 comments · Fixed by #38
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@luispinto23
Copy link

First of all, thank you for this amazing plugin.

I am having a small problem though, I have lsp inlay hints active and this messes up with the plugin. Is there anyway to make it work with inlay hints?

example:
image

@tris203
Copy link
Owner

tris203 commented May 24, 2024

I haven't used inlay hints much at all, but I have just had a look at the API and I think this should be possible.

I should be able to hook the inlay hints and inject the same amount of space into the string.

I will have a play with a PoC later

Thanks for the report, I imagine there are going to be a few cases like this with different configs!

@tris203 tris203 added the enhancement New feature or request label May 24, 2024
@willothy
Copy link
Collaborator

This would be cool! Great idea now that 0.10 is released.

@tris203
Copy link
Owner

tris203 commented May 24, 2024

I have an experimental implementation of this in #38

@luispinto23 would you be able to give it some testing?

image

@luispinto23
Copy link
Author

I have an experimental implementation of this in #38

@luispinto23 would you be able to give it some testing?

image

I'd love to help, but I'm off for the weekend with no PC.
I can do it probably by Sunday night or Monday morning.

@tris203
Copy link
Owner

tris203 commented May 24, 2024

Thanks @luispinto23 that would be great

It seems to work for me, but I don't use inlay hints regularly so it won't get tested much more.

The PR needs actually tests before it can be merged. And Mac CI hasn't been updated to 0.10 yet. So a merge will be pending that anyways

@tris203 tris203 self-assigned this May 25, 2024
@tris203 tris203 mentioned this issue May 25, 2024
6 tasks
@luispinto23
Copy link
Author

I think I am using the correct version here, please correct me if I am wrong:
image

It's working correctly when no inlay hints are present:
image

But when I move to somewhere with inlays it's breaking:

error

Error 11:26:21 PM msg_show.lua_error Error detected while processing CursorMoved Autocommands for "*": 11:26:21 PM msg_show Error executing lua callback: ...re/nvim/lazy/precognition.nvim/lua/precognition/init.lua:159: attempt to index field 'location' (a nil value) stack traceback: ...re/nvim/lazy/precognition.nvim/lua/precognition/init.lua:159: in function 'build_virt_line' ...re/nvim/lazy/precognition.nvim/lua/precognition/init.lua:263: in function 'display_marks' ...re/nvim/lazy/precognition.nvim/lua/precognition/init.lua:291: in function <...re/nvim/lazy/precognition.nvim/lua/precognition/init.lua:279>

I am not used to debug this kind of things, so please let me know if I can be of any help and I'll try to provide any more info.

@tris203
Copy link
Owner

tris203 commented May 26, 2024

Hi @luispinto23

Change the commit line to
branch = "inlay_hints",

Then open :Lazy and update

You will need to remove that line and reupdate when the change is merged

I think it should work fine, I have done more on this tonight and it seems to be working well

@luispinto23
Copy link
Author

Thank you to let me know how to point to the right code.

It's working fine!
image

Is there somewhere we can donate to buy you a beer or a coffee?

@tris203
Copy link
Owner

tris203 commented May 27, 2024

Thank you to let me know how to point to the right code.

It's working fine!
image

Is there somewhere we can donate to buy you a beer or a coffee?

Brilliant

I will try and get the testing strategy fleshed out
I think I will need to mock an lsp so will look into this

Thanks for your assistance @luispinto23

I have my GitHub sponsors set up if you wanted to, but it's really not necessary

@tris203 tris203 added this to the 1.1.0 milestone Jun 3, 2024
@JamesTeague
Copy link

I tested this out as well today and lgtm.

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

Successfully merging a pull request may close this issue.

4 participants