Skip to content

mikavilpas/tsugit.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ A blazingly fast lazygit + Neovim integration

Lazygit is a powerful terminal UI for git. This is a Neovim plugin I built for myself to make it even more powerful.

tsugit is a blend of the words tsugi (次, Japanese for "next") and git

shield image for plugin usage
tsugit-demo.mov

✨ Features

  • Blazingly fast: No more waiting for lazygit to start up. After starting it once, it's always running in the background.
    • When you quit lazygit (default: q), it's automatically restarted in the background.
    • Alternatively, toggle lazygit on/off. Instantly bring it back with the same key.
    • Kill lazygit (in case it gets stuck) with <c-c>.
  • Seamless integration: Use lazygit as if it's a part of Neovim. No extra applications are required.
    • You can edit files in Neovim while lazygit is open.
    • See below for 🎁 Goodies on how to write commit messages in Neovim.

📦 Installation

Requires lazy.nvim.

---@module "lazy"
---@type LazySpec
return {
  "mikavilpas/tsugit.nvim",
  keys = {
    {
      "<right>",
      function()
        require("tsugit").toggle()
      end,
      { silent = true, desc = "toggle lazygit" },
    },
    {
      "<leader>gl",
      function()
        local absolutePath = vim.api.nvim_buf_get_name(0)
        require("tsugit").toggle_for_file(absolutePath)
      end,
      { silent = true, desc = "lazygit file commits" },
    },
  },
  -- NOTE: opts is required in lazy.nvim so that setup() is called
  ---@type tsugit.UserConfig
  opts = {
    -- The key mappings that are active when lazygit is open. They are
    -- completely unusable by lazygit, so set the to rare keys.
    --
    -- If you want to completely disable keys, you can set them to `false`.
    -- You can also set `keys = false` to disable automatically creating keymaps.
    keys = {
      toggle = "<right>",
      force_quit = "<c-c>",
    }
  },
}

See permalink to my personal config or the latest version

🎁 Goodies

These are cool features that can be enabled manually with a bit of extra work.

Tip

I'm looking for a way to make it easier to integrate these features. For now, you can add these manually to your config.

Write commit messages in Neovim

With the following config, lazygit uses the parent nvim to edit commit messages. :bd[elete] when you are done to return to lazygit.

When using lazygit outside of Neovim, lazygit will open a new Neovim instance.

# /Users/mikavilpas/.config/lazygit/config.yml
os:
  edit: "nvim {{filename}}"
  editAtLine: "nvim +{{line}} {{filename}}"
  editAtLineAndWait: "nvim +{{line}} {{filename}}"

AI assisted commit messages in Neovim

If you use an AI assistant that can complete text in Neovim, you can use it to write commit messages. It should get activated automatically when you follow the previous step.

I also recommend giving the assistant more context by providing the full diff of the change as text. This feature is built-in to git, but it's not enabled by default. You can enable it with the following config:

# /Users/mikavilpas/.gitconfig
[commit]
	verbose = true

The documentation for this feature can be found in the git docs here.

Lazygit color scheme (💤 lazygit feature)

Note

This is a lazygit feature and not related to tsugit.nvim.

Nerd font icons (💤 lazygit feature)

https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#display-nerd-fonts-icons

Better diff syntax highlighting (💤 lazygit feature)

This feature improves lazygit's diff syntax highlighting by providing

  • nice colors for your files based on the file type
  • improved syntax highlighting for diffs

You can see it being used in the main demo.