nvimtools / none-ls.nvim

null-ls.nvim reloaded / Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
The Unlicense
2.39k stars 69 forks source link

fix: remove use of deprecated vim.tbl_add_reverse_lookup #127

Closed Kazy closed 3 months ago

Kazy commented 3 months ago

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

AThePeanut4 commented 3 months ago

@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 commented 3 months ago

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