Add gitsigns

This commit is contained in:
Daniel Lynn 2021-10-19 15:04:57 -05:00
parent 7d61b928a8
commit 1cc7ffbad1
Signed by: daniel
GPG Key ID: 28496A140E180A9D
4 changed files with 80 additions and 5 deletions

View File

@ -27,11 +27,11 @@ function! s:sonokai_custom() abort
call sonokai#highlight('SignColumn', l:palette.fg, l:palette.bg1)
call sonokai#highlight('Terminal', l:palette.fg, l:palette.bg1)
call sonokai#highlight('VertSplit', l:palette.bg1, l:palette.none)
call sonokai#highlight('CocGitAddedSign', l:palette.green, l:palette.bg1)
call sonokai#highlight('CocGitChangeRemovedSign', l:palette.purple, l:palette.bg1)
call sonokai#highlight('CocGitChangedSign', l:palette.blue, l:palette.bg1)
call sonokai#highlight('CocGitRemovedSign', l:palette.red, l:palette.bg1)
call sonokai#highlight('CocGitTopRemovedSign', l:palette.red, l:palette.bg1)
call sonokai#highlight('GitSignsAdd', l:palette.green, l:palette.bg1)
call sonokai#highlight('GitSignsChange', l:palette.blue, l:palette.bg1)
call sonokai#highlight('GitSignsChangeDelete', l:palette.purple, l:palette.bg1)
call sonokai#highlight('GitSignsDelete', l:palette.red, l:palette.bg1)
call sonokai#highlight('GitSignsTopDelete', l:palette.orange, l:palette.bg1)
call sonokai#highlight('BlueSign', l:palette.blue, l:palette.bg1)
call sonokai#highlight('GreenSign', l:palette.green, l:palette.bg1)
call sonokai#highlight('RedSign', l:palette.red, l:palette.bg1)

66
nvim/gitsigns.vimrc Normal file
View File

@ -0,0 +1,66 @@
lua << EOF
require('gitsigns').setup {
signs = {
add = {hl = 'GitSignsAdd' , text = '█', numhl='GitSignsAddNr' , linehl='GitSignsAddLn'},
change = {hl = 'GitSignsChange', text = '█', numhl='GitSignsChangeNr', linehl='GitSignsChangeLn'},
delete = {hl = 'GitSignsDelete', text = '█', numhl='GitSignsDeleteNr', linehl='GitSignsDeleteLn'},
topdelete = {hl = 'GitSignsTopDelete', text = '█', numhl='GitSignsTopDeleteNr', linehl='GitSignsTopDeleteLn'},
changedelete = {hl = 'GitSignsChangeDelete', text = '█', numhl='GitSignsChangeDeleteNr', linehl='GitSignsChangeDeleteLn'},
},
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
keymaps = {
-- Default keymap options
noremap = true,
['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns.actions\".next_hunk()<CR>'"},
['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns.actions\".prev_hunk()<CR>'"},
['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
['v <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
['v <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk({vim.fn.line("."), vim.fn.line("v")})<CR>',
['n <leader>hR'] = '<cmd>lua require"gitsigns".reset_buffer()<CR>',
['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line(true)<CR>',
['n <leader>hS'] = '<cmd>lua require"gitsigns".stage_buffer()<CR>',
['n <leader>hU'] = '<cmd>lua require"gitsigns".reset_buffer_index()<CR>',
-- Text objects
['o ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>',
['x ih'] = ':<C-U>lua require"gitsigns.actions".select_hunk()<CR>'
},
watch_gitdir = {
interval = 1000,
follow_files = true
},
attach_to_untracked = true,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
},
current_line_blame_formatter_opts = {
relative_time = false
},
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000,
preview_config = {
-- Options passed to nvim_open_win
border = 'single',
style = 'minimal',
relative = 'cursor',
row = 0,
col = 1
},
yadm = {
enable = false
},
}
EOF

View File

@ -25,6 +25,10 @@ Plug 'neovim/nvim-lspconfig' |
\ Plug 'hrsh7th/vim-vsnip' |
\ Plug 'rafamadriz/friendly-snippets'
" Gitsigns
Plug 'nvim-lua/plenary.nvim' |
\ Plug 'lewis6991/gitsigns.nvim'
" Lightline
Plug 'itchyny/lightline.vim' |
\ Plug 'albertomontesg/lightline-asyncrun' |

5
vimrc
View File

@ -83,6 +83,11 @@ if filereadable(expand("~/.config/nvim/keybindings.vimrc"))
source ~/.config/nvim/keybindings.vimrc
endif
" Gitsigns setup
if filereadable(expand("~/.config/nvim/gitsigns.vimrc"))
source ~/.config/nvim/gitsigns.vimrc
endif
" Lightline setup
if filereadable(expand("~/.config/nvim/lightline.vimrc"))
source ~/.config/nvim/lightline.vimrc