-
-
Notifications
You must be signed in to change notification settings - Fork 80
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
nvim use priorities to show the most relevant line #61
Conversation
Those priority calculations are handled by the LSP server, but there may be some bugs. If you encounter any issues related to underline priority, please open an issue. |
But no priorities are being passed to neovim in vim.highlight.range, which actually makes the nvim highlight be non-deterministic, i.e. sometimes the underline will be green and sometimes blue for the same variable, if the var happens to have been annotated with both If we don't pass the priorities to Maybe there is a way to get the priorities from the LSP on the nvim side and use those when doing the |
The priority is determined in the LSP server, and resolved decorations are returned. So if you find any bugs related to priority, it is an issue with the LSP server. |
I hope the screenshot makes the problem I am trying to describe easier to understand. As per the neovim docs, So this is how it works at the moment, i.e. wrong color ... ... and this is how it should look, and what this PR does. Also, looking at the hover_text = "immutable borrow",
is_display = true,
["local"] = {
fn_id = 3,
id = 14
},
range = {
["end"] = {
character = 28,
line = 3
},
start = {
character = 19,
line = 3
}
},
type = "imm_borrow"
} Please let me know if this makes the problem easier to understand. |
Thank you for your detailed and insightful explanation. I tried your example, examined the LSP response, and now I understand. First, the LSP server calculates decoration ranges so that decorations never overlap. The problem in your example is with In your example, the response includes two decorations: immutable borrow with The Neovim plugin should handle Admittedly, the name Did my response address your concern? |
Thank you for the explanation! In that case we can just check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much!
Always use the most relevant highlight group, i.e. if a token has both
lifetime
andimm_borrow
highlights, use the latter, i.e. make it blue, not green.Note:
I've tried using
vim.api.nvim_buf_set_extmark
but it didn't work properly (and even had some issue with lsp hints), but this simpler approach worked best.I've started with priority
200
as the lowest because that's what we usually get from tresitter, but in this case any will work, only the ordering is important.