Skip to content

A simple Neovim plugin providing a lualine component for displaying git status in the status line.

License

Notifications You must be signed in to change notification settings

abccsss/nvim-gitstatus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

nvim-gitstatus

A simple Neovim plugin providing a lualine component to display git status results in the status line.

screenshot

Caution

This plugin is still in early development. It has not been tested extensively and may not work as expected. Use at your own risk.

Prerequisites

Installation

Using lazy.nvim:

{
  "abccsss/nvim-gitstatus",
  event = "VeryLazy",
  config = true,
}

Setup

Add the component gitstatus to your lualine configuration. For example:

require("lualine").setup({
  sections = {
    lualine_a = { "mode" },
    lualine_b = {
      {
        "gitstatus",
        sections = {
          { "branch", format = " {}" },
          { "is_dirty", format = "*" },
        },
        sep = "",
      },
    },
    lualine_c = {
      {
        "gitstatus",
        sections = {
          { "ahead", format = "{}↑" },
          { "behind", format = "{}↓" },
          { "conflicted", format = "{}!" },
          { "staged", format = "{}=" },
          { "untracked", format = "{}+" },
          { "modified", format = "{}*" },
          { "renamed", format = "{}~" },
          { "deleted", format = "{}-" },
        },
        sep = " ",
      },
      -- other parts here
    },
    -- other sections here
  },
  -- other options here
})

Each item in the sections table is either a string or a table with the following fields:

  • [1]: string - The variable name to display, which must be one of the following:

    • branch - The current branch name.
    • upstream_branch - The remote branch name.
    • is_dirty - A boolean value indicating whether the working directory is dirty. Useful for e.g. showing a * next to the branch name.
    • up_to_date - A boolean value indicating whether the local branch is up to date with the remote branch.
    • up_to_date_and_clean - Equal to up_to_date and not is_dirty. Useful for showing a symbol when nothing else is displayed.
    • ahead - The number of commits ahead of the remote branch.
    • behind - The number of commits behind the remote branch.
    • conflicted - The number of conflicted items.
    • deleted - The number of deleted items.
    • modified - The number of modified items.
    • renamed - The number of renamed items.
    • staged - The number of staged items, including additions, modifications, and deletions.
    • stashed - The number of stashed items.
    • untracked - The number of new items.
  • format: string (optional) - The format string to use. The variable value is inserted at {}. If not provided, the variable value is displayed as is.

  • hl: string (optional) - The highlight group to use, which is one of the following:

    • A hex code of the form #rrggbb.
    • The name of a highlight group, such as Normal, or MiniIconsYellow, etc., if you use mini.icons. Only the foreground colour of the highlight group is used.

    The second option is preferred, as it adapts to different colour schemes.

If the value of a variable is 0 or false or an empty string, the entire section is omitted.

The sep field is either a string or a table with the following fields:

  • [1]: string - the separator between sections.
  • hl: string (optional) - the highlight group for the separator. See above for the syntax.

Options

The plugin comes with the following default options:

{
  --- Interval to automatically run `git fetch`, in milliseconds.
  --- Set to `false` to disable auto fetch.
  auto_fetch_interval = 30000,

  --- Timeout in milliseconds for `git status` to complete before it is killed.
  git_status_timeout = 1000,

  --- Whether to show debug messages.
  debug = false,
}

About

A simple Neovim plugin providing a lualine component for displaying git status in the status line.

Topics

Resources

License

Stars

Watchers

Forks

Languages