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: replace deprecated table methods for neovim v0.10 #1690

Closed
wants to merge 2 commits into from

Conversation

skoch13
Copy link

@skoch13 skoch13 commented Apr 25, 2024

Credits go to sindrets/diffview.nvim#489

Fixes #1689

@mikesmithgh
Copy link

FYI @skoch13 sindrets/diffview.nvim#489 (comment)

I also do not see the error on the latest version of nvim nightly.

I made a change to sindrets/diffview.nvim#489 to add the depth of math.huge to the flatten function that should be updated in the PR.

@skoch13
Copy link
Author

skoch13 commented Apr 30, 2024

@mikesmithgh thank you, I did mention that in the issue here #1689 (comment)

I'll update the PR accordingly, thank you

Comment on lines +11 to +14
---@return function
function M.islist()
return vim.fn.has "nvim-0.10" == 1 and vim.islist or vim.tbl_islist ---@diagnostic disable-line: deprecated
end
Copy link
Contributor

@baod-rate baod-rate May 10, 2024

Choose a reason for hiding this comment

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

I'm also deprecating these functions in my code and using this as a reference. am I missing something here? or should this be:

Suggested change
---@return function
function M.islist()
return vim.fn.has "nvim-0.10" == 1 and vim.islist or vim.tbl_islist ---@diagnostic disable-line: deprecated
end
---@param t? table
---@return boolean `true` if list-like table, else `false`.
function M.islist(t)
return (vim.fn.has("nvim-0.10") == 1 and vim.islist or vim.tbl_islist)(t) ---@diagnostic disable-line: deprecated
end

or maybe just:

Suggested change
---@return function
function M.islist()
return vim.fn.has "nvim-0.10" == 1 and vim.islist or vim.tbl_islist ---@diagnostic disable-line: deprecated
end
M.islist = vim.fn.has("nvim-0.10") == 1 and vim.islist or vim.tbl_islist ---@diagnostic disable-line: deprecated

Copy link
Owner

@williamboman williamboman left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It seems like Neovim nightly temporarily broke due to the introduction of some calls that are not allowed in :h vim.in_fast_event() (in which Mason executes quite a lot of code). It seems like that issue was fixed in the next nightly release.

There are some issues with these changes currently - current usage of flatten expects support for keyed tables, the islist() function seems to return the function it's meant to call, and the introduction of functions in the utils.lua is a bit misplaced (this is a util module local to the mason-core.installer.registry module).

Thanks for brining it to my attention, I'll close this PR and open another one to replace these usages!

@skoch13 skoch13 deleted the fix-neovim-nightly branch May 12, 2024 06:58
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.

Mason is not updating on nightly
4 participants