-
-
Notifications
You must be signed in to change notification settings - Fork 854
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
Fix LSP References Single-Result Jump Behavior #2281
base: master
Are you sure you want to change the base?
Conversation
@Conni2461 sorry for the ping, but do I need to directly assign someone for the CI workflow and/or a review? Thanks! |
lua/telescope/builtin/__lsp.lua
Outdated
end | ||
end | ||
|
||
return list_or_jump("textDocument/references", "LSP References", opts) |
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.
params.context = { includeDeclaration = vim.F.if_nil(opts.include_declaration, true) }
we can either pass in params as opts.
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.
Not sure what this is referring to, sorry!
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.
I think this comment is referring to the need to support the include_declaration
option for lsp_references
.
See the following code:
telescope.nvim/lua/telescope/builtin/__lsp.lua
Lines 17 to 19 in 5fff2a1
params.context = { includeDeclaration = vim.F.if_nil(opts.include_declaration, true) } | |
vim.lsp.buf_request(opts.bufnr, "textDocument/references", params, function(err, result, ctx, _) |
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.
@gbroques thanks for the clarification! I added some logic in list_or_jump
to handle this case.
lua/telescope/builtin/__lsp.lua
Outdated
-- jump to location | ||
local location = locations[1] | ||
local bufnr = opts.bufnr | ||
if location.filename then | ||
bufnr = vim.uri_to_bufnr(vim.uri_from_fname(location.filename)) | ||
end | ||
vim.api.nvim_win_set_buf(0, bufnr) | ||
vim.api.nvim_win_set_cursor(0, { location.lnum, location.col - 1 }) |
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.
maybe look at: #2229 (comment)
I've not check what they said but if you say it works, i'll will do some investigating/testing
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.
Maybe something changed upstream and now the objects are the same. But we still have 0.7 support so we need to make sure it works for both versions.
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.
I didn't run into the problem in the linked issue, but I've been making changes with NeoVim v0.8.1 so you might be right.
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.
@Conni2461 let me know if anything needs to be updated here.
I am sorry about the late review. There is no excuse i should have done it a long time ago :| Thanks for the PR :) I've also thought that using the same function should be possible, so thanks for implementing it. I've done a quick review. To fix CI you just have to rebase your branch because we fixed the tests already on master. There should be no conflicts, so rebase should be straight forward |
6f16402
to
9dce80b
Compare
No worries on the delay! End of the year is always a busy time :) I added docs for the affected pickers, but I'm not sure if anything else needs to be done besides the CI pushing the changes to the branch once the workflow permissions are granted. Also, I noticed a subtle bug with my initial implementation -- if someone passed in a Let me know if you need anything else! |
Thank you for the work on this @Conni2461 and @jls83! This PR looks stale. Anything I could do to help? |
Upping this one ☝️ could also help if need be :) |
uff thats a 2022 PR, i'll finish it this weekend. thanks for the ping |
d86ab9e
to
a46205f
Compare
skip-checks: true
@Conni2461 I fixed up my branch with master & made some of the requested changes. Let me know if you need anything else! |
Description
When there is only a single result for a call to
lsp_references
, the previous cursor position is not added to the jumplist. This is inconsistent with the behavior of other Telescope built-ins.This PR changes the implementation of the
lsp.references
method to use thelist_or_jump
helper function already in use for other LSP-related items (e.g.definitions
,type_definitions
,implementations
). It also adds an optional results filter tolist_or_jump
via theresults_filter
attribute inopts
.Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list relevant details about your configuration
require('telescope.builtin').lsp_references()
. Try jumping back (via<C-o>
) to the previous cursor position.Configuration:
Checklist: