neovim / neovim

Vim-fork focused on extensibility and usability
https://neovim.io
Other
81.63k stars 5.59k forks source link

Lua: more vim.iter functions #23233

Open justinmk opened 1 year ago

justinmk commented 1 year ago

Problem

vim.iter() was added in https://github.com/neovim/neovim/pull/23029 . This issue tracks related functions on there.

Related: vim.func https://github.com/neovim/neovim/issues/28449

Expected behavior

theHamsta commented 1 year ago

it1:chain(it2) would be nice.

stasjok commented 1 year ago

Maybe expose also ListIter.new? So that the programmer can bypass list check loop if he knows beforehand that his table is definitely a list. https://github.com/neovim/neovim/blob/558e4191f049662065984677a9c7cdbb1518092a/runtime/lua/vim/iter.lua#L781-L789

justinmk commented 1 year ago

expose also ListIter.new? So that the programmer can bypass list check loop if he knows beforehand that his table is definitely a list.

Could do this as kwargs (opt) parameter on vim.iter() itself. In general, we should probably use that pattern for all functions that accept a table/list/etc (while keep the common case low-verbosity).

stasjok commented 1 year ago

I now noticed that this loop creates a copy of the table. There probably was a reason for this. So it is unavoidable if we don't want to mutate user's table.

zjykzk commented 1 year ago

range(i, j) is fine