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

refactor: add compatible tbl_flatten and lsp_get_clients for new version 0.10 #3154

Merged
merged 1 commit into from
May 17, 2024

Conversation

glepnir
Copy link
Member

@glepnir glepnir commented May 16, 2024

add compatible util.tbl_flatten and lsp.get_active_clients to avoid deprecated error notify on 0.10 release.

lua/lspconfig/util.lua Outdated Show resolved Hide resolved
@glepnir glepnir force-pushed the flatten branch 4 times, most recently from 7c9ebde to 53cfed6 Compare May 16, 2024 13:53
@@ -261,8 +262,12 @@ function M.search_ancestors(startpath, func)
end
end

function M.tbl_flatten(t)
return nvim_nine and vim.tbl_flatten(t) or vim.iter(t):flatten():totable()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return nvim_nine and vim.tbl_flatten(t) or vim.iter(t):flatten():totable()
return nvim_nine and vim.tbl_flatten(t) or vim.iter(t):flatten(math.huge):totable()

lua/lspconfig/util.lua Outdated Show resolved Hide resolved
lua/lspconfig/util.lua Show resolved Hide resolved
@glepnir glepnir changed the title fix: add compatible tbl_flatten avoid deprecated notify on 0.10 fix: add compatible tbl_flatten and get_clients for 0.10 May 17, 2024
@glepnir glepnir changed the title fix: add compatible tbl_flatten and get_clients for 0.10 refactor: add compatible tbl_flatten and lsp_get_clients for new version 0.10 May 17, 2024
@glepnir glepnir merged commit 45015c6 into neovim:master May 17, 2024
9 checks passed
@glepnir glepnir deleted the flatten branch May 17, 2024 06:06
@wookayin
Copy link
Member

As pointed in #3154 (comment), nvim_nine is true for all of nvim 0.9, 0.10, and 0.11, etc. So it ends up still using the deprecated vim.tbl_flatten in nvim-0.10, and vim.iter() not being called.

@glepnir
Copy link
Member Author

glepnir commented May 17, 2024

oops i didn't validate that. yup has seems like not correct

Feel-ix-343 pushed a commit to Feel-ix-343/nvim-lspconfig that referenced this pull request May 19, 2024
@lorenzo-frittoli
Copy link

lorenzo-frittoli commented May 22, 2024

This now works for me:

function M.tbl_flatten(t)
  if t ~= nil then
    return {}
  end
  if nvim_ten then
    return vim.iter(t):flatten(math.huge):totable()
  end
  return vim.tbl_flatten(t)
end

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

4 participants