2025-02-05 17:48:02 +01:00
<!doctype html>
< html lang = "en" >
< head >
2025-02-06 22:12:19 +01:00
< title > Gitsigns minor improvements to git in Neovim - 🚀 ApolloNvim< / title >
2025-02-05 17:48:02 +01:00
< meta charset = "utf-8" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< link rel = "stylesheet" href = "https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" >
< link rel = "stylesheet" href = "../../../assets/css/darcula-highlight.min.css" >
< link rel = "stylesheet" href = "../../../assets/css/bootstrap.min.css" >
< link rel = "stylesheet" href = "../../../assets/css/dracula-ui.min.css" >
< link rel = "stylesheet" href = "../../../assets/css/mkdocs.min.css" >
2025-02-05 19:05:58 +01:00
< link href = "../../../style/style.css" rel = "stylesheet" >
2025-02-05 17:48:02 +01:00
< link rel = "icon" type = "image/x-icon" href = "../../../assets/img/favicon.ico" >
< script src = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/highlight.min.js" > < / script >
< script > hljs . initHighlightingOnLoad ( ) ; < / script >
< / head >
< body class = "drac-bg-black-secondary drac-text-grey-ternary drac-text drac-scrollbar-purple" >
< main class = "d-flex" >
<!-- block sidebar -->
< nav id = "sidebar" class = "sidebar drac-bg-black" >
< div class = "custom-menu" >
< button type = "button" id = "sidebarCollapse" class = "btn btn-primary" >
< i class = "fa fa-bars" > < / i >
< span class = "sr-only" > Menu< / span >
< / button >
< / div >
< div class = "p-4" >
< div class = "drac-text-center" >
2025-02-05 19:05:58 +01:00
< span class = "drac-text drac-line-height drac-text-white" > 🚀 ApolloNvim< / span >
2025-02-05 17:48:02 +01:00
< / div >
< div class = "drac-box flex-column" >
< ul class = "dot-ul" >
< li > < div class = "dot-li drac-bg-cyan" > < / div > < / li >
< li > < div class = "dot-li drac-bg-green" > < / div > < / li >
< li > < div class = "dot-li drac-bg-orange" > < / div > < / li >
< li > < div class = "dot-li drac-bg-pink" > < / div > < / li >
< li > < div class = "dot-li drac-bg-purple" > < / div > < / li >
< li > < div class = "dot-li drac-bg-red" > < / div > < / li >
< li > < div class = "dot-li drac-bg-yellow" > < / div > < / li >
< / ul >
< / div >
< hr class = "drac-divider" / >
<!-- block menu -->
< ul class = "mb-5 drac-list drac-list-none" >
< li class = "drac-box" >
< a href = "../../.."
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
🏘 Home
2025-02-05 17:48:02 +01:00
< / a >
< / li >
< li class = "drac-box" >
< a href = "../../installation/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
🛠 Installation
2025-02-05 17:48:02 +01:00
< / a >
< / li >
< li class = "drac-box" >
< a href = "../../plugins/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
🗄 Plugins
2025-02-05 17:48:02 +01:00
< / a >
< / li >
< li class = "drac-box" >
< a href = "../../.."
2025-02-06 22:12:19 +01:00
class=" active
2025-02-05 17:48:02 +01:00
drac-anchor btn-toggle d-inline-flex align-items-center border-0 drac-text-purple--hover collapsed"
2025-02-05 19:05:58 +01:00
data-bs-toggle="collapse" data-bs-target="#📑-tutorials-collapse" aria-expanded="false">
📑 Tutorials
2025-02-05 17:48:02 +01:00
< / a >
2025-02-05 19:05:58 +01:00
< div class = "collapse" id = "📑-tutorials-collapse" >
2025-02-05 17:48:02 +01:00
< ul class = "mb-5 drac-list drac-list-none" >
< li class = "drac-box-ternary" >
2025-02-05 19:05:58 +01:00
< a href = "../01.%20vimplug/"
2025-02-05 17:48:02 +01:00
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
How to install vim.plug into Neovim
2025-02-05 17:48:02 +01:00
< / a >
< / li >
2025-02-05 18:12:04 +01:00
< li class = "drac-box-ternary" >
2025-02-05 19:05:58 +01:00
< a href = "../02.%20keyshortcuts/"
2025-02-05 18:12:04 +01:00
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
Default keyboard shortcuts
2025-02-05 18:12:04 +01:00
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../03.%20Jak%20nainstalovat%20Codeium%20do%20Neovim/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
How to install Codeium on Neovim
2025-02-05 19:03:46 +01:00
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../04.%20Jak%20nainstalovat%20Telescope%20do%20editoru%20Neovim/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
Telescope
2025-02-05 18:12:04 +01:00
< / a >
< / li >
2025-02-06 22:12:19 +01:00
< li class = "drac-box-ternary" >
< a href = "../05.%20Barevn%C3%A9%20sch%C3%A9ma/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Color scheme
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../06.%20Autosave/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Automatic saving
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../07.%20Kop%C3%ADrov%C3%A1n%C3%AD%20a%20Vkl%C3%A1d%C3%A1n%C3%AD%20do%20a%20z%20Neovim%20z%20extern%C3%ADch%20zdroj%C5%AF/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Copying and Pasting to and from Neovim from external sources
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../08.%20Markdown_syntax/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Markdown_syntax
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../09.%20init.vim%20z%C3%A1kladn%C3%AD%20nastaven%C3%AD/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
init.vim basic settings
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../10.%20vim-fugitive%20ovl%C3%A1dni%20Git%20v%20Neovim/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
vim-fugitive
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "./"
class=" active
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Gitsigns minor improvements to git in Neovim
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../12.%20Je%C5%A1t%C4%9B%20lep%C5%A1%C3%AD%20Neovim%20s%20Zellij%20termin%C3%A1lov%C3%BDm%20multiplexorem/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Even better Neovim with Zellij terminal multiplexer
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../13.%20Pou%C5%BE%C3%ADv%C3%A1n%C3%AD%20relativn%C3%ADch%20%C4%8D%C3%ADsel%20%C5%99%C3%A1dk%C5%AF/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Using relative line numbers
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../15.%20Jak%20na%20kop%C3%ADrov%C3%A1n%C3%AD%20a%20vkl%C3%A1d%C3%A1n%C3%AD/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
How to copy and paste
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../17.%20Jak%20opravit%20nefunk%C4%8Dn%C3%AD%20Prettier/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
How to fix a broken Prettier
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../18.%20Konfigurace%20Lua/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
Configuring plagin in Lua file
< / a >
< / li >
< li class = "drac-box-ternary" >
< a href = "../20.%20N%C3%A1hledy%20markdown%20v%20nvim/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
How to show markdown preview in browser using coc-webview
< / a >
< / li >
2025-02-05 17:48:02 +01:00
< / ul >
< / div >
< / li >
< li class = "drac-box" >
< a href = "../../../contact/"
class="
drac-anchor d-inline-flex align-items-center border-0 drac-text-purple--hover">
2025-02-05 19:05:58 +01:00
📪 Contact
2025-02-05 17:48:02 +01:00
< / a >
< / li >
< / ul >
<!-- endblock -->
< / div >
< / nav >
<!-- endblock -->
< nav class = "divider drac-bg-purple-cyan" > < / nav >
< div class = "content" >
<!-- block header -->
< header >
< nav class = "navbar navbar-expand-xl drac-bg-purple" >
< div class = "container-fluid" >
< button class = "navbar-toggler w-100 text-center" type = "button" data-bs-toggle = "collapse" data-bs-target = "#navbarsMenu"
aria-controls="navbarsMenu" aria-expanded="false" aria-label="Toggle navigation">
< span class = "navbar-toggler-icon" > < / span >
< / button >
< div class = "collapse navbar-collapse flex-column ml-auto" id = "navbarsMenu" >
< ul class = "navbar-nav text-md-center" >
<!-- block preview -->
< li class = "nav-item" >
2025-02-06 22:12:19 +01:00
< div class = "container" >
< div class = "row row-preview" >
< div class = "col" >
< a href = "../10.%20vim-fugitive%20ovl%C3%A1dni%20Git%20v%20Neovim/"
class="btn-preview drac-btn drac-btn-outline drac-text-white drac-text-cyan-green--hover">
< i class = "fa fa-arrow-left" > < / i > Previous
< / a >
< / div >
< div class = "col" >
< a href = "../12.%20Je%C5%A1t%C4%9B%20lep%C5%A1%C3%AD%20Neovim%20s%20Zellij%20termin%C3%A1lov%C3%BDm%20multiplexorem/"
class="btn-preview drac-btn drac-btn-outline drac-text-white drac-text-cyan-green--hover" style="padding-left: 3%;">
Next < i class = "fa fa-arrow-right" > < / i >
< / a >
< / div >
< / div >
< / div >
2025-02-05 17:48:02 +01:00
< / li >
<!-- endblock -->
<!-- block search -->
< li class = "nav-item" > < div role = "search" class = "search-box" >
< form id = "rtd-search-form" class = "wy-form" action = "../../../search.html" method = "get" >
< input type = "text" name = "q" class = "drac-input drac-input-search drac-input-white drac-text-white drac-bg-black-secondary"
placeholder="Search docs" title="Type search term here" />
< / form >
< / div >
< / li >
<!-- endblock -->
<!-- block source -->
< li class = "nav-item" >
< / li >
<!-- endblock -->
< / ul >
< / div >
< / div >
< / nav >
< / header >
<!-- endblock -->
<!-- block content -->
< section class = "p-md-5 section-content" >
< article >
2025-02-06 22:12:19 +01:00
< p > < h1 id = "11-gitsigns-minor-improvements-to-git-in-neovim" > 11. Gitsigns minor improvements to git in Neovim< / h1 >
< p > The great thing about coding is seeing deleted or modified lines in real time.< / p >
< p > Neovim doesn't support this by default, so we use gitsigns:< / p >
< p > in our init.vim we add:< / p >
2025-02-05 17:48:02 +01:00
< div class = "codehilite" > < pre > < span > < / span > < code > < span class = "k" > call< / span > < span class = "w" > < / span > < span class = "nl" > plug< / span > #< span class = "nv" > begin< / span > < span class = "ss" > (< / span > < span class = "s1" > ' ~/.config/nvim/plugged' < / span > < span class = "ss" > )< / span >
< span class = "err" > " gitsigns< / span >
< span class = "err" > Plug ' lewis6991/gitsigns.nvim' < / span >
< span class = "err" > call plug#end()< / span >
< / code > < / pre > < / div >
2025-02-06 22:12:19 +01:00
< p > Note: gitsigns requires < code > nvim-lua/plenary.nvim< / code > . Since we installed it using < code > telescope< / code > < a href = "https://github.com/LukasKanka/ApolloNvim/blob/main/readme/04.%20Jak%20nainstalovat%20Telescope%20do%20editoru%20Neovim.md" target = "_blank" > 04. How to install Telescope in the Neovim editor< / a > , we are covered.< / p >
< p > You already know what to do - Save, source and < code > :PlugInstall< / code > .< / p >
< p > Gitsigns requires a call and setup in your configuration to make it work. Let's create a < code > gitsigns.lua< / code > file in our name directory:< / p >
< p > < code > nvim ~/.config/nvim/lua/your-directory/gitsigns.lua< / code > < / p >
< p > And inside this file we start:< / p >
2025-02-05 17:48:02 +01:00
< div class = "codehilite" > < pre > < span > < / span > < code > require(' gitsigns' ).setup {}
< / code > < / pre > < / div >
2025-02-06 22:12:19 +01:00
< p > If you don't specify any options, the plugin will start with the default settings.< / p >
< p > Now we'll add gitsigns.luado our namespace directory init.lua file:< / p >
< div class = "codehilite" > < pre > < span > < / span > < code > require(' your-directory/telescope' )
require(' your-directory/lightline' )
require(' your-directory/gitsigns' )
2025-02-05 17:48:02 +01:00
< / code > < / pre > < / div >
2025-02-06 22:12:19 +01:00
< p > Mine looks like this:< / p >
2025-02-05 17:48:02 +01:00
< div class = "codehilite" > < pre > < span > < / span > < code > require(' kankys/telescope' )
2025-02-06 22:12:19 +01:00
require(' kankys/lightline' ) require
(' kankys/gitsigns' )
2025-02-05 17:48:02 +01:00
< / code > < / pre > < / div >
2025-02-06 22:12:19 +01:00
< p > 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 .< / p >
< p > 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:< / p >
2025-02-05 17:48:02 +01:00
< div class = "codehilite" > < pre > < span > < / span > < code > " ... general settings
set signcolumn=number
< / code > < / pre > < / div >
2025-02-06 22:12:19 +01:00
< p > Save and restore the < code > :source< / code > 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:< / p >
2025-02-05 17:48:02 +01:00
< p > < code > :h signcolumn< / code > < / p >
2025-02-06 22:12:19 +01:00
< p > 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.< / p >
< p > I love this feature. The < code > vim-fugitive< / code > has a < code > :Git blame< / code > 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:< / p >
2025-02-05 17:48:02 +01:00
< div class = "codehilite" > < pre > < span > < / span > < code > require(' gitsigns' ).setup {
2025-02-06 22:12:19 +01:00
-- signs config
current_line_blame = true,
current_line_blame_opts = {
virt_text_pos = ' right_align
' }
}
2025-02-05 17:48:02 +01:00
< / code > < / pre > < / div >
2025-02-06 22:12:19 +01:00
< p > And that's it!< / p >
2025-02-05 17:48:02 +01:00
< div style = "text-align: center;" >
2025-02-06 22:12:19 +01:00
Copyright © 2024 - 2025 🚀 ApolloNvim / Lukáš Kaňka
2025-02-05 17:48:02 +01:00
< / div > < / p >
< / article >
< / section >
<!-- endblock -->
<!-- block footer -->
< footer >
< div class = "d-flex flex-sm-row justify-content-between py-2 border-top drac-text-black drac-bg-cyan-green" >
< a href = "https://github.com/dracula/mkdocs" target = "_blank" style = "padding-left: 1%;"
class="footer-text drac-anchor drac-text-black drac-text-purple--hover">
Made with Dracula Theme for MkDocs
< / a >
< / div >
< / footer >
<!-- endblock -->
< / div >
< / main >
< script > var base _url = '../../..' ; < / script >
< script src = "../../../assets/js/jquery-3.3.1.slim.min.js" > < / script >
< script src = "../../../assets/js/bootstrap.bundle.min.js" > < / script >
< script src = "../../../assets/js/mkdocs.js" > < / script >
< script src = "../../../javascripts/extra.js" defer > < / script >
< script src = "../../../search/main.js" defer > < / script >
< / body >
< / html >