aniseed icon indicating copy to clipboard operation
aniseed copied to clipboard

vim.tbl.flatten is deprecated

Open raoulmillais opened this issue 7 months ago • 8 comments

Im getting this warning when I :checkhealth deprecated:

- ⚠️ WARNING vim.tbl_flatten is deprecated. Feature will be removed in Nvim 0.13
  - ADVICE:
    - use vim.iter(…):flatten():totable() instead.
    - stack traceback:
        /home/raoul/.local/share/nvim/lazy/conjure/lua/conjure/aniseed/deps/nvim.lua:205
        /home/raoul/.local/share/nvim/lazy/conjure/lua/conjure/mapping.lua:192
        [C]:-1
        /home/raoul/.local/share/nvim/lazy/conjure/lua/conjure/aniseed/autoload.lua:19
        /home/raoul/.local/share/nvim/lazy/conjure/lua/conjure/aniseed/autoload.lua:28
        /home/raoul/.local/share/nvim/lazy/conjure/lua/conjure/main.lua:18

I had a bit of a dig and it seems the deps/nvim.lua hasn't changed in 6 years so its not surprising, I got stuck though because my knowledge of the compiler isnt good enough to make any progress. If you give me some pointers I can try to help fix iit 🙏

raoulmillais avatar Jun 02 '25 08:06 raoulmillais

Thank you for reporting this! Although I'm not really maintaining Aniseed and am instead slowly ushering people over to nfnl, I'll try to keep on top of these sorts of issues where possible. I appreciate the heads up!

That nvim.lua is actually from https://github.com/norcalli/nvim.lua which was merged (mostly) into Neovim as a core feature many moons ago. It's no longer maintained but I'll manually alter the copy inside Aniseed to avoid this issue for now. Ideally we would update every call to this nvim library to instead use vim.api.nvim_... functions, but that'd take a while and that work is already done in nfnl anyway.

So I'll go for a quick patch for now.

Olical avatar Jun 02 '25 09:06 Olical

Please try out the fix-flatten-warning branch, I don't have any Neovim setups using Aniseed now so I don't have a good real world test case to check that everything is okay.

Olical avatar Jun 02 '25 09:06 Olical

I’ll check it out in the morning but this is weird - I have nfnl and have for a long time. I got aniseed via conjure for some reason (see the stack trace). My lazy-lock.json shows a very old commit for conjure but I have updated and cleaned lazy many times in the last week. My plugin spec for conjure is the simplest it could be and I thought lazy defaulted to a "version" of false meaning take latest git HEAD so I don’t really understand why I have aniseed at all!

raoulmillais avatar Jun 02 '25 21:06 raoulmillais

OH! My mistake, yeah, Conjure ships with a copy but it's used less and less and is almost ready to be deleted. Thanks for this then, it'll be required during this interim period while I finish removing references to it.

Ignore me 😅

On Mon, 2 Jun 2025, 22:32 Raoul Millais, @.***> wrote:

raoulmillais left a comment (Olical/aniseed#149) https://github.com/Olical/aniseed/issues/149#issuecomment-2932586473

I’ll check it out in the morning but this is weird - I have nfnl and have for a long time. I got aniseed via conjure for some reason. My lazy-lock.json shows a very old commit for conjure https://github.com/raoulmillais/dotfiles/blob/294fe78ee8f13080dd3d503f366980b71fca5f89/.config/nvim/lazy-lock.json#L5 but I have updated and cleaned lazy many times in the last week. My plugin spec for conjure https://github.com/raoulmillais/dotfiles/blob/main/.config/nvim/lua/plugins/lisps.lua is the simplest it could be and I thought lazy defaulted to a "version" of false meaning take latest git HEAD https://github.com/folke/lazy.nvim/blob/6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a/lua/lazy/core/config.lua#L13 so I don’t really understand why I have aniseed at all!

— Reply to this email directly, view it on GitHub https://github.com/Olical/aniseed/issues/149#issuecomment-2932586473, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XKDMYY2IWY3QKVLTCL3BS7IFAVCNFSM6AAAAAB6MJDTX2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMZSGU4DMNBXGM . You are receiving this because you were assigned.Message ID: @.***>

Olical avatar Jun 02 '25 21:06 Olical

Looks good 👍

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = { { "olical/aniseed", branch = "fix-flatten-warning", } },
})

vim.api.nvim_create_autocmd("VimEnter", {
  pattern = "*",
  command = "checkhealth deprecated"
})
nvim -u repro.lua 

Image

raoulmillais avatar Jun 03 '25 06:06 raoulmillais

In case you wanted to automate this - here's a version that doesn't rely on lazy and could be easily adapted for any of your plugins:

#/bin/bash

export NVIM_APPNAME="./"
export PACK_DIR="${NVIM_APPNAME}site/pack/test/opt/"

trap cleanup 1 2 3 6

cleanup()
{
  rm -rf "${NVIM_APPNAME}site/" >/dev/null 2>&1
  rm -rf health.log >/dev/null 2>&1
  exit
}

mkdir -p "${PACK_DIR}"
pushd "${PACK_DIR}"
git clone https://github.com/Olical/aniseed/
popd
nvim --headless +'packadd aniseed' +'checkhealth deprecated' +'w!health.log' \
  +'qa'&> /dev/null && cat health.log
cleanup

raoulmillais avatar Jun 03 '25 07:06 raoulmillais

This doesn't work 😿 - aniseed never gets loaded. I spent an hour fiddling with variations of packpath and packadd without any success. I think its to do with either of these things:

  • the $PACK_DIR - $NVIM_APPNAME can't be "." neovim errors unless it has the trailing slash but when it has the trailing slash it modifies the rtp and packpath adding versions of site/ with a leading double slash. (trying to set the packpath to the correct thing doesn't work either though)
  • aniseed doesn't have a vimscript shim and packadd maybe doesn't work with pure lua plugins.

I'll leave this here in case someone smarter than me with more time on their hands can fiigure it out. This is why I use a package manager!

In case you wanted to automate this - here's a version that doesn't rely on lazy and could be easily adapted for any of your plugins:

#/bin/bash

export NVIM_APPNAME="./" export PACK_DIR="${NVIM_APPNAME}site/pack/test/opt/"

trap cleanup 1 2 3 6

cleanup() { rm -rf "${NVIM_APPNAME}site/" >/dev/null 2>&1 rm -rf health.log >/dev/null 2>&1 exit }

mkdir -p "${PACK_DIR}" pushd "${PACK_DIR}" git clone https://github.com/Olical/aniseed/ popd nvim --headless +'packadd aniseed' +'checkhealth deprecated' +'w!health.log'
+'qa'&> /dev/null && cat health.log cleanup

raoulmillais avatar Jun 03 '25 07:06 raoulmillais

Thank you for trying! Please leave it with me, I'll get it checked and deployed in Conjure ASAP.

On Tue, 3 Jun 2025, 08:53 Raoul Millais, @.***> wrote:

raoulmillais left a comment (Olical/aniseed#149) https://github.com/Olical/aniseed/issues/149#issuecomment-2933987212

This doesn't work 😿 - aniseed never gets loaded. I spent an hour fiddling with variations of packpath and packadd without any success. I think its to do with either of these things:

  • the $PACK_DIR - $NVIM_APPNAME can't be "." neovim errors unless it has the trailing slash but when it has the trailing slash it modifies the rtp and packpath adding versions of site/ with a leading double slash. (trying to set the packpath to the correct thing doesn't work either though)
  • aniseed doesn't have a vimscript shim and packadd maybe doesn't work with pure lua plugins.

I'll leave this here in case someone smarter than me with more time on their hands can fiigure it out. This is why I use a package manager!

In case you wanted to automate this - here's a version that doesn't rely on lazy and could be easily adapted for any of your plugins:

#/bin/bash

export NVIM_APPNAME="./" export PACK_DIR="${NVIM_APPNAME}site/pack/test/opt/"

trap cleanup 1 2 3 6

cleanup() { rm -rf "${NVIM_APPNAME}site/" >/dev/null 2>&1 rm -rf health.log >/dev/null 2>&1 exit }

mkdir -p "${PACK_DIR}" pushd "${PACK_DIR}" git clone https://github.com/Olical/aniseed/ popd nvim --headless +'packadd aniseed' +'checkhealth deprecated' +'w!health.log' +'qa'&> /dev/null && cat health.log cleanup

— Reply to this email directly, view it on GitHub https://github.com/Olical/aniseed/issues/149#issuecomment-2933987212, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XPSIMHNMDNYUSGBTH33BVH7LAVCNFSM6AAAAAB6MJDTX2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMZTHE4DOMRRGI . You are receiving this because you were assigned.Message ID: @.***>

Olical avatar Jun 03 '25 13:06 Olical

I hate leaving something incomplete so did some more investigation! None of the approaches I've found for testing adding packages (amongst neovim issues that I've seen) have used NVIM_APPNAME - I don't think NVIM_APPNAME is designed to do anything other than change the config dir and used in combination with a modified packpath or rtp probably was never considered in its design.

Lazy.vim modifies the XDG env dirs inside vim in its minit script but then lazy does all sorts of things with the runtimepath so I'm not sure following its lead is going to be helpful.

Gregory Anders uses a pure lua approach to testing packpath/rtp moodifications so that looks like it might be a better approach. When I get some more time - I'll have a play with this.

raoulmillais avatar Jun 05 '25 07:06 raoulmillais

I’ll check it out in the morning but this is weird - I have nfnl and have for a long time. I got aniseed via conjure for some reason (see the stack trace). My lazy-lock.json shows a very old commit for conjure but I have updated and cleaned lazy many times in the last week. My plugin spec for conjure is the simplest it could be and I thought lazy defaulted to a "version" of false meaning take latest git HEAD so I don’t really understand why I have aniseed at all!

I got to the bottom of this. Conjure was stuck on the old 'master' branch. Lazy would never update beyond the last commit on the 'master' branch and was quite happy telling me I was up-to-date. I only discovered this because I got the conjure popup with a message about it when I opened a sql file. There's no mention of conjure in the message and the message wasn't appearing for clojure files. I had completely forgotten conjure had a SQL client in so I was baffled where the message was even coming from. It was by bisecting through my installed plugins that I tracked it down. Do you want me to put an issue in on the conjure repo? I can't be the only one cluelessly stuck on an ancient version of conjure :)

You have to uninstall and reinstall conjure via lazy to get back up-to-date on main.

raoulmillais avatar Jun 10 '25 14:06 raoulmillais

Sorry about the delay on this one, had a bunch on my plate recently. I've pushed this into Conjure's copy of this file too although it may actually never get loaded these days but worth addressing.

And I actually added a notification to the master branch of Conjure so it'd add a line to the log on startup every time warning you that you're on an old branch. Maybe you were behind even that commit somehow!

My apologies for any inconveniences caused anyway! You had to waste a lot of time on this and that's not on, I'll try my best to prevent things like this from happening in the future.

Aniseed will also be gone for good from the Clojure codebase soon, just need to do a push to essentially s/aniseed/nfnl then fix any small incompatibilities.

Olical avatar Jun 12 '25 08:06 Olical

Ugh, oh no, just realised this new method Neovim wants us to use isn't supported by Neovim 0.9.5, so I'll have to either branch / shim it or drop support for 0.9.5 over this. The breaking changes are painful!

Olical avatar Jun 12 '25 08:06 Olical

Fixed, I've added a branch that uses tbl_flatten if vim.iter isn't there. Thus is the life of a plugin maintainer 🎉

Olical avatar Jun 12 '25 08:06 Olical

You don't owe me any apology at all. I was happy to do some poking around: that comes with the territory when you use neovim. Thank you for all your hard work - it makes editing Clojure in Neovim absolute joy 🙏

raoulmillais avatar Jun 17 '25 10:06 raoulmillais