-
-
Notifications
You must be signed in to change notification settings - Fork 353
Two definitions for local function variables #2451
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
Comments
I have also been experiencing this. Seems very similar to this old ticket. |
For neovim users, here's a monkey-patch you can add to your config that should let you get around this until a fix comes around from the lua-language-server side: local locations_to_items = vim.lsp.util.locations_to_items
vim.lsp.util.locations_to_items = function (locations, offset_encoding)
local lines = {}
local loc_i = 1
for _, loc in ipairs(vim.deepcopy(locations)) do
local uri = loc.uri or loc.targetUri
local range = loc.range or loc.targetSelectionRange
if lines[uri .. range.start.line] then -- already have a location on this line
table.remove(locations, loc_i) -- remove from the original list
else
loc_i = loc_i + 1
end
lines[uri .. range.start.line] = true
end
return locations_to_items(locations, offset_encoding)
end |
disrupted
added a commit
to disrupted/dotfiles
that referenced
this issue
Mar 20, 2025
primarily for Lua LS related issues: LuaLS/lua-language-server#2451 folke/trouble.nvim#538
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How are you using the lua-language-server?
NeoVim
Which OS are you using?
Linux
What is the issue affecting?
Other
Expected Behaviour
Using vim.lsp.buf.definition() to go to the definition of a local function variable (assigned with the
=
operator), should give only a single definition at the local variable name.Actual Behaviour
Using vim.lsp.buf.definition() to go to the definition of a local function variable (assigned with the
=
operator), gives two definitions on the same line. One is located at the variable name and the other is located at the beginning of the function key word.Reproduction steps
m()
function call:lua vim.lsp.buf.definition()
Additional Notes
No response
Log File
The text was updated successfully, but these errors were encountered: