mirror of
https://github.com/lewis6991/gitsigns.nvim
synced 2025-02-22 07:47:02 +00:00
lua | ||
.luacheckrc | ||
LICENSE | ||
Makefile | ||
README.md |
gitsigns.nvim
Git signs written in pure lua.
WIP
Features:
- Signs for added, removed, and changed lines
- Asynchronous using luv
- Navigation between diff blocks (hunks)
- Stage partial diffs
- Customisable (signs, highlights, mappings, etc)
- Status bar integration
Requirements
Neovim nightly
Installation
use 'nvim-lua/plenary.nvim'
use 'lewis6991/gitsigns.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'lewis6991/gitsigns.nvim'
Usage
For basic setup with all batteries included:
require('gitsigns').setup()
Configuration can be passed to the setup function. Here is an example with all the default settings:
require('gitsigns').setup {
signs = {
add = {hl = 'DiffAdd' , text = '│'},
change = {hl = 'DiffChange', text = '│'},
delete = {hl = 'DiffDelete', text = '_'},
topdelete = {hl = 'DiffDelete', text = '_'},
changedelete = {hl = 'DiffChange', text = '~'},
},
keymaps = {
[']c'] = '<cmd>lua require("gitsigns").next_hunk()<CR>',
['[c'] = '<cmd>lua require("gitsigns").prev_hunk()<CR>',
['<leader>hs'] = '<cmd>lua require("gitsigns").stage_hunk()<CR>',
['<leader>gh'] = '<cmd>lua require("gitsigns").get_hunk()<CR>'
},
watch_index = {
enabled = true,
interval = 1000
}
}
For information on configuring neovim via lua please see nvim-lua-guide.
Status Line
Use b:gitsigns_status
or b:gitsigns_status_dict
. b:gitsigns_status
is
a preformatted and ready to use string (e.g. +10 -5 ~1
) and ommits zero
values. b:gitsigns_status_dict
is a dictionary with the keys added
,
removed
, changed
.
Example:
set statusline+=%{get(b:,'gitsigns_status','')}