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 operations for neovim v0.10 #489

Merged
merged 4 commits into from
May 18, 2024

Conversation

mikesmithgh
Copy link
Contributor

@mikesmithgh mikesmithgh commented Apr 24, 2024

Resolves #488.

Neovim nightly deprecated some table operations resulting in diffview.nvim crashes. I've moved the operations islist and flatten to the utils package so that we can apply the appropriate function depending on the Neovim version.

Please let me know what you think, thanks!

@FunctionalHacker
Copy link

Just tested this on my machine, works well!

@serranomorante
Copy link

serranomorante commented Apr 29, 2024

Can you try with the command DiffviewFileHistory %? I believe it doesn't work after this change.

@mikesmithgh
Copy link
Contributor Author

DiffviewFileHistory %
@serranomorante I tried DiffviewFileHistory % and it looks like it working for me. Are you seeing an error?

@ctretyak
Copy link

ctretyak commented Apr 30, 2024

I am using Neogit, that uses diffview.nvim. I have the same problem on markdowns (.md) files only. Other diffs are OK (.json, etc)

@LinoWhy
Copy link

LinoWhy commented Apr 30, 2024

DiffviewFileHistory % @serranomorante I tried DiffviewFileHistory % and it looks like it working for me. Are you seeing an error?

@mikesmithgh I meet the same issue, with the following error:

   Error  14:17:56 msg_show.lua_error   DiffviewFileHistory % Error executing luv callback:
...al/share/nvim/lazy/diffview.nvim/lua/diffview/logger.lua:382: attempt to call method 'gsub' (a nil value)
stack traceback:
	...al/share/nvim/lazy/diffview.nvim/lua/diffview/logger.lua:382: in function <...al/share/nvim/lazy/diffview.nvim/lua/diffview/logger.lua:380>
	vim/shared.lua: in function 'tbl_map'
	...al/share/nvim/lazy/diffview.nvim/lua/diffview/logger.lua:380: in function 'log_job'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:345: in function <...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:308>
	[C]: in function 'wait'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:408: in function 'sync'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/utils.lua:349: in function 'exec_sync'
	...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:687: in function 'is_single_file'
	...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:696: in function 'file_history_dry_run'
	...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:820: in function 'file_history_options'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/lib.lua:93: in function 'file_history'
	...ocal/share/nvim/lazy/diffview.nvim/lua/diffview/init.lua:139: in function 'file_history'
	....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:34: in function <....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:27>
   Error  14:18:28 msg_show.lua_error Error executing Lua callback: ...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:416: Synchronous job timed out!
stack traceback:
	[C]: in function 'error'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/job.lua:416: in function 'sync'
	...cal/share/nvim/lazy/diffview.nvim/lua/diffview/utils.lua:349: in function 'exec_sync'
	...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:687: in function 'is_single_file'
	...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:696: in function 'file_history_dry_run'
	...azy/diffview.nvim/lua/diffview/vcs/adapters/git/init.lua:820: in function 'file_history_options'
	...local/share/nvim/lazy/diffview.nvim/lua/diffview/lib.lua:93: in function 'file_history'
	...ocal/share/nvim/lazy/diffview.nvim/lua/diffview/init.lua:139: in function 'file_history'
	....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:34: in function <....local/share/nvim/lazy/diffview.nvim/plugin/diffview.lua:27>

@serranomorante
Copy link

diffview-issue.webm

@mikesmithgh
Copy link
Contributor Author

@serranomorante @LinoWhy @ctretyak thank you for pointing this out.

TL;DR;

  • The original error for this issue using deprecated calls no longer seems to appear in nvim nightly. You could try updating to the latest version of nvim nightly and revert back to sindrets/main.
  • I added a fix for flatten so this branch should work

My branch accidentally reverted to main that is why I did not see the error. So, that is one thing to point out. It seems like the latest nightly nvim may no longer be crashing due to the deprecated usage. So, you may not need to point to this branch unless you would like to test this functionality.

The issue appeared to be related to flatten.

vim.iter({ 1, { 2 }, { { 3 } } }):flatten():totable()
-- result: { 1, 2, { 3 } }

vs

vim.iter({ 1, { 2 }, { { 3 } } }):flatten(math.huge):totable()
-- result: { 1, 2, 3 }

flatten defaults to the depth of 1 so it was not fully flattening the list like vim.tbl_flatten. I added a fix for this by using math.huge as the depth so that is properly flattens the arguments.

yorickpeterse added a commit to yorickpeterse/dotfiles that referenced this pull request May 17, 2024
Upstream has some issues with the latest release of NeoVim:

- sindrets/diffview.nvim#492
- sindrets/diffview.nvim#489
Copy link
Owner

@sindrets sindrets left a comment

Choose a reason for hiding this comment

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

Thank you!

I made a small change where I opted to use the old implementation of tbl_flatten() from Neovim because unlike the iter(...):flatten() alternative, it handles lists with holes.

@sindrets sindrets merged commit 5532482 into sindrets:main May 18, 2024
@mikesmithgh
Copy link
Contributor Author

Thank you!

I made a small change where I opted to use the old implementation of tbl_flatten() from Neovim because unlike the iter(...):flatten() alternative, it handles lists with holes.

Awesome! 😎

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.

[Bug] nightly nvim: DiffViewOpen fails to open
6 participants