tamton-aquib / staline.nvim

A modern lightweight statusline and bufferline plugin for neovim in lua.
MIT License
380 stars 17 forks source link

Git diff in statusbar #49

Closed abhilash26 closed 8 months ago

abhilash26 commented 1 year ago

First of all thank you for making this plugin.

I wanted to add git diff in my statusbar. I have seen #27 and used that to make up some code

      local git_status = function(type, prefix)
        local status = vim.b.gitsigns_status_dict
        if not status then
          return nil
        end
        if not status[type] or status[type] == 0 then
          return nil
        end
        return prefix .. status[type]
      end
 In the statusline 
            {
              "GitSignsAdd",
              function()
                return git_status("added", " ") or ''
              end
            },
            " ",
            {
              "GitSignsChange",
              function()
                return git_status("changed", " ") or ''
              end
            },
            " ",
            {
              "GitSignsDelete",
              function()
                return git_status("removed", " ") or ''
              end
            }

image

      I couldnot do this in one block as I needed different highlights for each type of diff.
      Is there any way to do this better?  Also, can you add this as a module as it is not a specific requirement.  
tamton-aquib commented 1 year ago

Heyyo @abhilash26,

The problem with git related info in statuslines is, it becomes sluggish if not done correctly. Even the git branch section is inefficient in staline.

I am thinking of providing integrations with gitsigns like you mentioned. Feline did something similar too. But it might take some time because I have exams 😭

abhilash26 commented 1 year ago

@tamton-aquib, Salaam Alekum, Good luck in your exams. I did not know you are young. Please let this issue opened.

tamton-aquib commented 1 year ago

Please let this issue opened.

Sure 👍🏻

tamton-aquib commented 8 months ago

Hi @abhilash26,

So I have been checking issues and PR's in all my repos and wanted to check this one too. I researched a bit and gitsigns already have statusline related config defined.

Especially :h gitsigns-config-status_formatter.

After defining it, we could just add the git_diff section to staline.

tamton-aquib commented 8 months ago

Closing this issue for now but feel free to open it if needed 👍🏻

abhilash26 commented 4 months ago

Hello @tamton-aquib,

I tried using git_diff but couldn't get the icons and colors, all of them were in one color. I have a request, please use git_diff and give us options for icons and color for each (added, modified and deleted) highlights.

abhilash26 commented 4 months ago

Nevermind, I rolled my own statusline plugin https://github.com/abhilash26/zenline.nvim