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

fix: remove use of deprecated vim.tbl_add_reverse_lookup #127

Merged
merged 1 commit into from
May 17, 2024

Conversation

Kazy
Copy link
Contributor

@Kazy Kazy commented May 17, 2024

Not sure if the deepcopy is needed, in some languages iterating while mutating can give weird results.

@AThePeanut4
Copy link

AThePeanut4 commented May 17, 2024

@Kazy vim.tbl_add_reverse_lookup looks like this (with error checking removed):

function vim.tbl_add_reverse_lookup(o)
  local keys = vim.tbl_keys(o)
  for _, k in ipairs(keys) do
    o[o[k]] = k
  end
  return o
end

So vim.tbl_keys would be the function to use.

A quick Google shows that adding new keys while iterating is indeed undefined in Lua.

@Kazy
Copy link
Contributor Author

Kazy commented May 17, 2024

@AThePeanut4 thank you, I've updated it to match that !

@mochaaP mochaaP merged commit a0c3020 into nvimtools:main May 17, 2024
3 of 4 checks passed
@Kazy Kazy deleted the fix-deprecated-methods branch May 17, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants