tris203 / precognition.nvim

💭👀precognition.nvim - Precognition uses virtual text and gutter signs to show available motions.
MIT License
743 stars 9 forks source link

Any way to make it adjust to inlay hints #37

Closed luispinto23 closed 2 months ago

luispinto23 commented 4 months ago

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 commented 4 months ago

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!

willothy commented 4 months ago

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

tris203 commented 4 months ago

I have an experimental implementation of this in #38

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

image

luispinto23 commented 4 months ago

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 commented 4 months ago

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

luispinto23 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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 commented 4 months ago

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

JamesTeague commented 3 months ago

I tested this out as well today and lgtm.