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

Diffview Doesn't Load correctly with Packer #94

Closed
2 of 3 tasks
teto opened this issue Nov 14, 2023 · 6 comments
Closed
2 of 3 tasks

Diffview Doesn't Load correctly with Packer #94

teto opened this issue Nov 14, 2023 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@teto
Copy link

teto commented Nov 14, 2023

Prerequsities

  • The "Troubleshooting" section of the README did not help
  • I've installed the required dependencies
  • I'm on the latest version of the plugin

Bug Description

In lua/gitlab/reviewer/diffview.lua there is a local diffview_lib = require("diffview.lib") line that triggers

|| ...ck/home-manager/start/diffview.nvim/lua/diffview/lib.lua:12: attempt to index global 'DiffviewGlobal' (a nil value)
|| # stacktrace:
||   - ~/.local/share/nvim/site/pack/home-manager/start/diffview.nvim/lua/diffview/lib.lua:12
||   - /gitlab.nvim/lua/gitlab/reviewer/diffview.lua:5
||   - /gitlab.nvim/lua/gitlab/reviewer/init.lua:2
||   - /gitlab.nvim/lua/gitlab/init.lua:5
||   - ~/.config/nvim/lua/lazyplugins/git.lua:10 _in_ **config**
||   - ~/.config/nvim/lua/init-manual.lua:60
||   - ~/home/config/nvim/init.lua:12

if you have https://github.com/sindrets/diffview.nvim installed as well aka require("gitlab.diffview.lib") instead.

everything included should be scoped by the plugin name.

Reproduction Steps

install https://github.com/sindrets/diffview.nvim and gitlab.nvim

@teto
Copy link
Author

teto commented Nov 14, 2023

arf I had not realized diffview was a new dependency so seems like the problem might be in initialization order ? diffview must be initialized before gitlab.nvim

@harrisoncramer
Copy link
Owner

Hey Teto, thanks for reporting this.

Yes, this is why for Packer and Lazy diffview is listed in the dependencies or requires section of the plugin configuration. Are you still stuck or did you get this resolved?

@teto
Copy link
Author

teto commented Nov 14, 2023

I think it's ok. Depending on how I launch neovim I see some errors like an highlight missing for gitlab.nvim but it's not a big problem. Let's close

@teto teto closed this as completed Nov 14, 2023
@thomasgrz
Copy link

thomasgrz commented Mar 26, 2024

Thank you so much for this plugin!

Just FWIW, I'm running into the same error:

packer.nvim: Error running config for gitlab.nvim: ...ite/pack/packer/start/diffview.nvim/lua/diffview/lib.lua:12: attempt to index global 'DiffviewGlobal' (a
 nil value)

I've actually tried deleting the previous installation of diffview and re-installing with it just as a dependency of gitlab.nvim.

Here's what the config looks like in my packer.lua file:

    use {
        'harrisoncramer/gitlab.nvim',
        requires = {
            "MunifTanjim/nui.nvim",
            "nvim-lua/plenary.nvim",
            "sindrets/diffview.nvim",
            "stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
            "nvim-tree/nvim-web-devicons", -- Recommended but not required. Icons in discussion tree.
        },
        run = function() require("gitlab.server").build(true) end,
        config = function()
            require("gitlab").setup()
        end,
    }

I thought I could ignore it, but I also noticed that when I try to install with :PackerSync I get the following error (which seems related):

packer.nvim: Error running config for gitlab.nvm: [string "..."] loop or previous loading module 'gitlab'

Any idea what I could be doing incorrectly?

@harrisoncramer harrisoncramer added question Further information is requested bug Something isn't working help wanted Extra attention is needed and removed question Further information is requested labels Mar 28, 2024
@harrisoncramer
Copy link
Owner

This looks specifically like an issue with Packer, I'm not a user but would appreciate any help from the community...

Looks like diffview expects there to be a global variable DiffviewGlobal available when it's run, however for some reason it's not getting picked up. You can replicate this by using Packer's minimal configuration with this plugin.

@harrisoncramer harrisoncramer changed the title collision when diffview.nvim is installed as well Diffview Doesn't Load correctly with Packer Mar 28, 2024
harrisoncramer added a commit that referenced this issue Apr 22, 2024
fix: We require some state from Packer, this fixes the docs to reflect a way to load that state prior to running the gitlab plugin. Fixes #94.
harrisoncramer added a commit that referenced this issue Apr 22, 2024
* feat: Support for custom authentication provider functions (#270)
* feat: Support for adding "draft" notes to the review, and publishing them, either individually or all at once. Addresses feature request #223.
* feat: Lets users select + checkout a merge request directly within Neovim, without exiting to the terminal
* fix: Checks that the remote feature branch exists and is up-to-date before creating a MR, starting a review, or opening the MR summary (#278)
* docs: We require some state from Diffview, this shows how to load that state prior to installing w/ Packer. Fixes #94.

This is a #MINOR release.

---------

Co-authored-by: Jakub F. Bortlík <[email protected]>
Co-authored-by: sunfuze <[email protected]>
Co-authored-by: Patrick Pichler <[email protected]>
@harrisoncramer
Copy link
Owner

For anyone else running into this issue, you have to require Diffview before you require Gitlab due to an issue in that repository and Packer:

require("diffview") -- We require some global state from diffview
local gitlab = require("gitlab")
-- Your keybindings here...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants