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

Replace vim.tbl_add_reverse_lookup (deprecated in neovim v0.10) #904

Merged
merged 1 commit into from
May 19, 2024

Conversation

cttttt
Copy link
Contributor

@cttttt cttttt commented May 17, 2024

Problem

After rebuilding neovim from from master (specifically, 06135cc21571b2707121e31176f544a0e0901e1d), I'm noticing the following deprecation warning on startup:

vim.tbl_add_reverse_lookup is deprecated. :help deprecated
stack traceback:
        vim/shared.lua: in function 'tbl_add_reverse_lookup'
        ...nvim/lazy/bufferline.nvim/lua/bufferline/diagnostics.lua:10: in main chunk
        [C]: in function 'require'
        ...are/nvim/lazy/bufferline.nvim/lua/bufferline/buffers.lua:8: in main chunk
        [C]: in function 'require'
        .../share/nvim/lazy/bufferline.nvim/lua/bufferline/lazy.lua:11: in function '__index'
        ...local/share/nvim/lazy/bufferline.nvim/lua/bufferline.lua:56: in function <...local/share/nvim/lazy/bufferline.nvim/lua/buffer
line.lua:54>

Looking at neovim's deprecation help page, this function was deprecated as of neovim 0.10 and will not be replaced when it's removed.

How does this fix?

By crudely reimplementing tbl_add_reverse_lookup and using it in your diagnostics module.

Reviewer notes

I didn't take a super close look at the actual use of this reversed table (if you really need to have forward and also reverse mappings in the table). I simply reimplemented what is now missing from the vim module. If you don't need the mirrored mappings, utils.tbl_reverse_lookup() would suffice.

Version

neovim/neovim 06135cc21571b2707121e31176f544a0e0901e1d:

NVIM v0.11.0-dev-6+g06135cc21
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068

@tan-wei
Copy link

tan-wei commented May 18, 2024

Great!

Copy link
Owner

@akinsho akinsho left a comment

Choose a reason for hiding this comment

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

Thanks

@akinsho akinsho merged commit 9ae49d7 into akinsho:main May 19, 2024
0 of 2 checks passed
sstallion pushed a commit to sstallion/bufferline.nvim that referenced this pull request Jul 3, 2024
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.

3 participants