# 11. Gitsigns minor improvements to git in Neovim

The great thing about coding is seeing deleted or modified lines in real time.

Neovim doesn't support this by default, so we use gitsigns:

in our init.vim we add:

    call plug#begin('~/.config/nvim/plugged')

    " gitsigns
    Plug 'lewis6991/gitsigns.nvim'

    call plug#end()

Note: gitsigns requires `nvim-lua/plenary.nvim`. Since we installed it using `telescope` 04. How to install Telescope in the Neovim editor, we are covered.

You already know what to do - Save, source and `:PlugInstall`.

Gitsigns requires a call and setup in your configuration to make it work. Let's create a `gitsigns.lua` file in our name directory:

`nvim ~/.config/nvim/lua/your-directory/gitsigns.lua`

And inside this file we start:

    require('gitsigns').setup {}

If you don't specify any options, the plugin will start with the default settings.

Now we'll add gitsigns.luado our namespace directory init.lua file:

    require('your-directory/telescope')
    require('your-directory/lightline')
    require('your-directory/gitsigns')

Mine looks like this:

    require('kankys/telescope')
    require('kankys/lightline') require
    ('kankys/gitsigns')

Restore the source of this file using the :source command. You can see Gitsigns in action when you navigate to a project on your machine that is managed by git. Any watched file that has been modified will show this modification .

While this is technically what we want, the placement of the sign is a bit off. This is because we need to tell Vim to display the diagnostic characters in the number column, not to the left of the number. Open your init.vim file and add a new setting:

    " ... general settings
    set signcolumn=number

Save and restore the `:source` init.vim file. Now your characters should appear in the number column, not on the left. To learn more about signcolumn run the following command in Neovim:

`:h signcolumn`

There is a feature in VSCode that is sorely missed in Neovim. When you are in a project that uses Git, leaving the cursor on a line for a certain amount of time will cause some virtual text to appear in a dull color. The text will read the name of the developer who last modified the line, the modification date, and the commit message.

I love this feature. The `vim-fugitive` has a `:Git blame` command that handles the same use case, but I prefer the virtual text. To enable this, simply add the following to your Git signage configuration:

    require('gitsigns').setup {
     -- signs config
     current_line_blame = true,
     current_line_blame_opts = {
     virt_text_pos = 'right_align
     ' }
    }

And that's it!

Copyright © 2024 - 2025 🚀 ApolloNvim / Lukáš Kaňka