nvim-tree.lua icon indicating copy to clipboard operation
nvim-tree.lua copied to clipboard

git submodule icons in nvim-tree

Open adimail opened this issue 1 year ago • 2 comments

It would be helpful to have a dedicated icon for Git submodules in the nvim-tree file explorer. Currently, while nvim-tree supports various Git status icons (e.g., staged, unstaged, untracked), there isn’t an option to display a unique icon for submodules.

This would improve the visual distinction of submodule folders and make it easier for users to identify them in the tree view.

Proposed Solution

Allow users to define a custom icon for Git submodules in the renderer.icons.git configuration. For example:

renderer = {
    -- other configurations...
    icons = {
        -- other icons...
        git = {
            -- existing git icons...
            submodule = '',  -- Git submodule icon
        },
    },
},

References

This feature idea was originally discussed here: Does nvim-tree have webicon for git submodules?.

Request

I’d appreciate guidance on how to proceed with implementing this feature.

adimail avatar Dec 23 '24 05:12 adimail

I see, the request is for the module directory itself, rather than the module file.

I've moved this issue from web-devicons to nvim-tree itself and closed the other issue, to keep discussion in one place.

This is possible, but a non-trivial amount of work:

  • nvim-tree is aware of multiple git repos in the tree, however a submodule is just another repo.
  • We'd need to add submodule awareness to lua/nvim-tree/git/init.lua and cache it GitProject
  • We can't simply query at display time, as that is a very expensive operation.

I'm very open to pull requests, as this would be a useful feature, see CONTRIBUTING.md

alex-courtis avatar Dec 28 '24 03:12 alex-courtis

Hi, long time user of nvim-tree here and I am looking forward to this feature! However, git performance is already not ideal especially for large repos so it would be nice that this doesn't regress the existing git integrations. My idea is that all submodules paths can be listed once with git submodule status --recursive and that can be cached, then it could be refreshed whenever .gitmodules changes - so basically never unless a submodule is added or removed

Pistonight avatar Jan 31 '25 08:01 Pistonight