sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.73k stars 105 forks source link

nvim-web-devicons error. #298

Closed DMunkei closed 1 year ago

DMunkei commented 1 year ago

I saw in the changelog changelog-271 that changes to the settings had to be done. I didn't have anything special in my settings, just the standard example written in the README. I simply exchanged it with the current example in the README. However, I am getting this error: [Diffview.nvim] nvim-web-devicons is required to use file icons! Set "use_icons = false" in your config to stop seeing this message. I have the dependency installed, not sure what's the issue here?

sindrets commented 1 year ago

Please show the output from :checkhealth diffview.

DMunkei commented 1 year ago
diffview: require("diffview.health").check()
========================================================================
## Checking plugin dependencies
  - OK: plenary installed.
  - WARNING: Optional dependency 'nvim-web-devicons' not found.

## Checking external dependencies
  - OK: Git found.
  - OK: Git is up-to-date.

Here's also the line in my packer.lua that is pulling the dependency

  use {'nvim-lualine/lualine.nvim',
      requires = { 'kyazdani42/nvim-web-devicons', opt = true }
    }
sindrets commented 1 year ago

You're pulling it as an opt dependency. Thus it will not be available on the 'runtimepath' until either you, or packer add it with :packadd.

Either don't install it as opt, or declare it as a dependency in diffview's packer spec as well.

DMunkei commented 1 year ago

I tried doing this :

  use { 'sindrets/diffview.nvim',
  requires = {'nvim-lua/plenary.nvim', 'kyazdani42/nvim-web-devicons', opt = true}
  }

However, that didn't seem to work. I tried doing it like you mentioned with :packadd nvim-web-devicons and then opened DiffViewOpen. Then that worked. My question is, where would I add :packadd nvim-web-devicons?

sindrets commented 1 year ago

It's a library. I don't understand why you want to lazy load it. It doesn't do anything until another plugin calls its API.

If, for whatever reason, it's really important to you to lazy load it, then I'll leave it up to you to figure out when it should be :packadd-ed. It has to happen at least before the first time you call any of diffview's commands.

It's a lot simpler if you don't care about lazy loading it:

use {
  "sindrets/diffview.nvim",
  requires = {
    "nvim-lua/plenary.nvim",
    "kyazdani42/nvim-web-devicons",
  },
}
DMunkei commented 1 year ago

No reason at all, I took it from the package docs. I just changed it to your proposed suggestion. However, it still requires me to do a manual :packadd nvim-web-devicons for it to work. I had to also remove the opt = true in the other import I had. Works properly now.

 use { 'nvim-lualine/lualine.nvim',
        requires = { 'kyazdani42/nvim-web-devicons'}
    }
    use {
        'sindrets/diffview.nvim',
        requires = {
            'nvim-lua/plenary.nvim',
            'kyazdani42/nvim-web-devicons'
        },
    }
sindrets commented 1 year ago

Right. A packer dependency can't be declared multiple times with different specs. That seems like a limitation in packer. You could raise that issue upstream if you want it addressed.

Closing, as the original problem has been solved.

tummetott commented 1 year ago

@DMunkei btw the repo is called nvim-tree/nvim-web-devicons now. The old name still links to the repo but just to be explicit, I'd use the new repo name

DMunkei commented 1 year ago

@tummetott Thanks, changed it.