Skip to content

Commit

Permalink
Fix gisigns key mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan committed Oct 23, 2022
1 parent 0961d5a commit 7622fee
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Plug g:NvideConf_PluginDownloadAddr . 'sainnhe/edge'
Plug g:NvideConf_PluginDownloadAddr . 'nvim-treesitter/nvim-treesitter'
Plug g:NvideConf_PluginDownloadAddr . 'nvim-treesitter/nvim-treesitter-refactor'
Plug g:NvideConf_PluginDownloadAddr . 'nvim-treesitter/nvim-treesitter-textobjects'
Plug g:NvideConf_PluginDownloadAddr . 'lewis6991/nvim-treesitter-context'
Plug g:NvideConf_PluginDownloadAddr . 'nvim-treesitter/nvim-treesitter-context'
Plug g:NvideConf_PluginDownloadAddr . 'p00f/nvim-ts-rainbow'

" ========= edit enhancement ==========
Expand Down Expand Up @@ -485,8 +485,17 @@ require('gitsigns').setup{
end

-- Navigation
map('n', ']c', "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'", {expr=true})
map('n', '[c', "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'", {expr=true})
map('n', ']c', function()
if vim.wo.diff then return ']c' end
vim.schedule(function() gs.next_hunk() end)
return '<Ignore>'
end, {expr=true})

map('n', '[c', function()
if vim.wo.diff then return '[c' end
vim.schedule(function() gs.prev_hunk() end)
return '<Ignore>'
end, {expr=true})

-- Actions
map({'n', 'v'}, 'gs', ':Gitsigns stage_hunk<CR>')
Expand Down

0 comments on commit 7622fee

Please sign in to comment.