58215b9f9b
- Use a jsonschema like object to process/validate/build the config - Attempt to clean up the imports |
||
---|---|---|
doc | ||
lua | ||
.luacheckrc | ||
LICENSE | ||
Makefile | ||
README.md |
README.md
gitsigns.nvim
Git signs written in pure lua.
Status
Still very WIP. Expect things to sometimes break but please don't hesitate to raise an issue.
Features
- Signs for added, removed, and changed lines
- Asynchronous using luv
- Navigation between diff blocks (hunks)
- Stage partial diffs (with undo)
- Customisable (signs, highlights, mappings, etc)
- Status bar integration
Requirements
Neovim nightly
Installation
use {
'lewis6991/gitsigns.nvim',
requires = {
'nvim-lua/plenary.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 = {
-- Default keymap options
noremap = true,
buffer = true,
['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'"},
['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'"},
['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
},
watch_index = {
interval = 1000
},
sign_priority = 6,
status_formatter = nil, -- Use default
}
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
is formatted using config.status_formatter
. b:gitsigns_status_dict
is a
dictionary with the keys added
, removed
, changed
and head
.
Example:
set statusline+=%{get(b:,'gitsigns_status','')}
For the current branch use the variable b:gitsigns_head
.
TODO
- Add action for undoing a stage of a hunk
- Add action for
undoingreseting a hunk - Add action for showing diff (or original text) in a floating window
- Add ability to show staged hunks with different signs (maybe in a different sign column?)
- Add support for repeat.vim
- Apply buffer updates incrementally
- Add tests
- Respect algorithm in diffopt
- When detecting index changes, also check if the file of the buffer changed
- Add ability to show commit in floating window of current line
- Add help doc