nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
6.16k stars 465 forks source link

Feat: git worktree component #1130

Open OscarCreator opened 1 year ago

OscarCreator commented 1 year ago

Requested feature

Add worktree component https://github.com/nvim-lualine/lualine.nvim/blob/master/doc/lualine.txt#L240

Motivation

When using a bare git repo with multiple worktrees it would be useful to see which worktree you are currently on.

25d96b commented 12 months ago

It works with the branch component for me. Can you include some steps to reproduce your issue?

This is what has worked for me:

  1. git clone --bare https://github.com/nvim-lualine/lualine.nvim && cd $_ Now we have a bare repo of lualine.nvim
  2. git add worktree test_work_tree master Create a worktree on branch master
  3. nvim README.md
Schermata 2023-11-01 alle 17 40 46

If this is not what you desire, let me know I'm happy to help! 😀

OscarCreator commented 12 months ago

The worktree I mean in this case is test_work_tree. So a way to display that folder name is what I am after.

Something like this could the status bar look like:

NORMAL | master | test_work_tree | README.md

It can be evaluated with:

function() 
    local res, match = vim.fn.FugitiveGitDir():gsub(".*worktrees/", "")
    if match == 1 then 
        return res 
    else 
        return "" 
    end 
end
25d96b commented 12 months ago

Something like this?

Schermata 2023-11-01 alle 22 57 49

I have maintained the same icon as the branch because I'm unable to find a specific symbol for worktrees.

OscarCreator commented 12 months ago

Yes something like that. I have to see if I can find a symbol for it, otherwise it can just be changed (or removed) at a later time.