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: adapt to Nvim deprecations in 0.10 #3109

Merged
merged 1 commit into from
May 17, 2024
Merged

fix: adapt to Nvim deprecations in 0.10 #3109

merged 1 commit into from
May 17, 2024

Conversation

clason
Copy link
Contributor

@clason clason commented May 16, 2024

Fixes #3108

Note that islist() checks for a specific type of table: indexed by integers without holes (so { 1 = 'a', 3 = 'b' } is not a list); the intention is to ensure that ipairs and # (length) are well-defined. I did not check whether that is indeed intended in each case here; if not, consider simply replacing by type(t) == 'table'.

On a related note, the new flatten() only works correctly for lists; {1,2,nil,3} will not be flattened to {1,2,3}. I don't know if that is an issue here, either. EDIT looks like it.
EDIT2: will be fixed upstream.

(Long-term, I would recommend moving to the new vim.iter API that allows efficiently chaining iterators. But this is of course a major refactoring effort.)

@Conni2461
Copy link
Member

thanks :) i am about to test these changes if they look good we can merge

@clason
Copy link
Contributor Author

clason commented May 16, 2024

Hold on for a second; the vim.tbl_flatten() change is not equivalent, and we will probably revert/bump the deprecation. If that happens, I'll drop those changes for now and just do islist.
EDIT Looks like that part will get fixed, so the deprecation will stay. So this PR is good as it stands.

If you can in the meantime check whether you really want to check for a list (instead of generic table or array -- which has a separate function now), that would be very helpful.

@clason
Copy link
Contributor Author

clason commented May 16, 2024

Also, I'm not happy about having to duplicate the shims, but I wanted to avoid pulling in (heavy!) modules where they weren't before.

Copy link
Contributor

@jamestrew jamestrew left a comment

Choose a reason for hiding this comment

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

I think for everything but plugin/telescope.lua, it shouldn't make a difference to included utils. By the time these modules are included, utils would have been included.

But otherwise lgtm, thanks!

@clason
Copy link
Contributor Author

clason commented May 17, 2024

Ok, removed the duplication (except in /plugin), and fixed one more deprecation I found. @Conni2461 I think this is ready to merge.

@Conni2461
Copy link
Member

thanks :) i dont think we have to run with this for that long, i wanna do a 0.2 release sometime in the next 3 months (depending on how much freetime ill have) with support for 0.10 and newer.

@Conni2461 Conni2461 merged commit bbdbb75 into master May 17, 2024
18 checks passed
@Conni2461 Conni2461 deleted the fix/deprecated branch May 17, 2024 12:39
@clason
Copy link
Contributor Author

clason commented May 17, 2024

Yes, I think 0.10 will be a good new baseline (and waiting a bit for the inevitable 0.10.1 makes sense as well ;))

@augustocdias
Copy link

Do I have to do some kind of migration in my config for this? I'm getting this error in the lsp builting functions after updating:

attempt to call field 'islist' (a nil value)

I'm on 0.10 and it is weird that when I execute :lua print(vim.fn.has "nvim-0.10" == 1 and vim.islist or vim.tbl_islist) it doesn't give me nil...

@clason
Copy link
Contributor Author

clason commented May 17, 2024

Are you on the Nvim 0.10 release or some old nighly?

@rmccord7
Copy link

Having issues on nightly

image

built_in grep_string throwing this error.

E5108: Error executing lua: ...local/bin/build/nvim/share/nvim/runtime/lua/vim/iter.lua:236: flatten() requires a list-like table
stack traceback:
[C]: in function 'error'
...local/bin/build/nvim/share/nvim/runtime/lua/vim/iter.lua:236: in function 'flatten'
...l/share/nvim/lazy/telescope.nvim/lua/telescope/utils.lua:23: in function 'flatten'
...im/lazy/telescope.nvim/lua/telescope/builtin/__files.lua:233: in function 'v'
...im/lazy/telescope.nvim/lua/telescope/builtin/__files.lua:641: in function 'v'
.../nvim/lazy/telescope.nvim/lua/telescope/builtin/init.lua:580: in function <.../nvim/lazy/telescope.nvim/lua/telescope/builtin/init.lua:539>
...2/rmccord/.config/nvim/lua/rm/plugins/telescope/util.lua:37: in function <...2/rmccord/.config/nvim/lua/rm/plugins/telescope/util.lua:36>

@clason
Copy link
Contributor Author

clason commented May 17, 2024

Will be fixed soon. Stick to releases, especially for the first few days/weeks after a release.

Conni2461 pushed a commit that referenced this pull request May 20, 2024
@augustocdias
Copy link

augustocdias commented May 21, 2024

@clason I'm on 0.10 release

NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

The last commits seem to have solved the issue... Not seeing it anymore.

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.

Adapt to deprecated Neovim API
5 participants