Skip to content

Commit

Permalink
feat(toggle): return current value
Browse files Browse the repository at this point in the history
Fixes #506
  • Loading branch information
lewis6991 committed Apr 10, 2022
1 parent acdd74b commit 4a68d2a
Show file tree
Hide file tree
Showing 3 changed files with 224 additions and 38 deletions.
56 changes: 49 additions & 7 deletions doc/gitsigns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -360,23 +360,65 @@ stage_hunk({range}) *gitsigns.stage_hunk()*
{range} table|nil List-like table of two integers making
up the line range from which you want to stage the hunks.

toggle_deleted() *gitsigns.toggle_deleted()*
toggle_deleted({value}) *gitsigns.toggle_deleted()*
Toggle |gitsigns-config-show_deleted|

toggle_current_line_blame() *gitsigns.toggle_current_line_blame()*
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.

Returns:~
Current value of |gitsigns-config-show_deleted|

toggle_current_line_blame({value}) *gitsigns.toggle_current_line_blame()*
Toggle |gitsigns-config-current_line_blame|

toggle_word_diff() *gitsigns.toggle_word_diff()*
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.

Returns:~
Current value of |gitsigns-config-current_line_blame|

toggle_word_diff({value}) *gitsigns.toggle_word_diff()*
Toggle |gitsigns-config-word_diff|

toggle_linehl() *gitsigns.toggle_linehl()*
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.

Returns:~
Current value of |gitsigns-config-word_diff|

toggle_linehl({value}) *gitsigns.toggle_linehl()*
Toggle |gitsigns-config-linehl|

toggle_numhl() *gitsigns.toggle_numhl()*
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.

Returns:~
Current value of |gitsigns-config-linehl|

toggle_numhl({value}) *gitsigns.toggle_numhl()*
Toggle |gitsigns-config-numhl|

toggle_signs() *gitsigns.toggle_signs()*
Toggle |gitsigns-config-signcolumn|
Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.

Returns:~
Current value of |gitsigns-config-numhl|

toggle_signs({value}) *gitsigns.toggle_signs()*
Toggle |gitsigns-config-signbooleancolumn|

Parameters:~
{value} boolean|nil Value to set toggle. If `nil`
the toggle value is inverted.

Returns:~
Current value of |gitsigns-config-signcolumn|


==============================================================================
Expand Down
96 changes: 84 additions & 12 deletions lua/gitsigns/actions.lua

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

110 changes: 91 additions & 19 deletions teal/gitsigns/actions.tl
Original file line number Diff line number Diff line change
Expand Up @@ -63,48 +63,120 @@ local record M
get_actions : function(bufnr: integer, lnum: integer)

refresh : function()
toggle_signs : function()
toggle_numhl : function()
toggle_linehl : function()
toggle_word_diff : function()
toggle_current_line_blame : function()
toggle_deleted : function()
toggle_signs : function(boolean): boolean
toggle_numhl : function(boolean): boolean
toggle_linehl : function(boolean): boolean
toggle_word_diff : function(boolean): boolean
toggle_current_line_blame : function(boolean): boolean
toggle_deleted : function(boolean): boolean
end

--- Toggle |gitsigns-config-signcolumn|
M.toggle_signs = function()
config.signcolumn = not config.signcolumn
--- Toggle |gitsigns-config-signbooleancolumn|
---
--- Parameters:~
--- {value} boolean|nil Value to set toggle. If `nil`
--- the toggle value is inverted.
---
--- Returns:~
--- Current value of |gitsigns-config-signcolumn|
M.toggle_signs = function(value: boolean): boolean
if value ~= nil then
config.signcolumn = value
else
config.signcolumn = not config.signcolumn
end
M.refresh()
return config.signcolumn
end

--- Toggle |gitsigns-config-numhl|
M.toggle_numhl = function()
config.numhl = not config.numhl
---
--- Parameters:~
--- {value} boolean|nil Value to set toggle. If `nil`
--- the toggle value is inverted.
---
--- Returns:~
--- Current value of |gitsigns-config-numhl|
M.toggle_numhl = function(value: boolean): boolean
if value ~= nil then
config.numhl = value
else
config.numhl = not config.numhl
end
M.refresh()
return config.numhl
end

--- Toggle |gitsigns-config-linehl|
M.toggle_linehl = function()
config.linehl = not config.linehl
---
--- Parameters:~
--- {value} boolean|nil Value to set toggle. If `nil`
--- the toggle value is inverted.
---
--- Returns:~
--- Current value of |gitsigns-config-linehl|
M.toggle_linehl = function(value: boolean): boolean
if value ~= nil then
config.linehl = value
else
config.linehl = not config.linehl
end
M.refresh()
return config.linehl
end

--- Toggle |gitsigns-config-word_diff|
M.toggle_word_diff = function()
config.word_diff = not config.word_diff
---
--- Parameters:~
--- {value} boolean|nil Value to set toggle. If `nil`
--- the toggle value is inverted.
---
--- Returns:~
--- Current value of |gitsigns-config-word_diff|
M.toggle_word_diff = function(value: boolean): boolean
if value ~= nil then
config.word_diff = value
else
config.word_diff = not config.word_diff
end
M.refresh()
return config.word_diff
end

--- Toggle |gitsigns-config-current_line_blame|
M.toggle_current_line_blame = function()
config.current_line_blame = not config.current_line_blame
---
--- Parameters:~
--- {value} boolean|nil Value to set toggle. If `nil`
--- the toggle value is inverted.
---
--- Returns:~
--- Current value of |gitsigns-config-current_line_blame|
M.toggle_current_line_blame = function(value: boolean): boolean
if value ~= nil then
config.current_line_blame = value
else
config.current_line_blame = not config.current_line_blame
end
M.refresh()
return config.current_line_blame
end

--- Toggle |gitsigns-config-show_deleted|
M.toggle_deleted = function()
config.show_deleted = not config.show_deleted
---
--- Parameters:~
--- {value} boolean|nil Value to set toggle. If `nil`
--- the toggle value is inverted.
---
--- Returns:~
--- Current value of |gitsigns-config-show_deleted|
M.toggle_deleted = function(value: boolean): boolean
if value ~= nil then
config.show_deleted = value
else
config.show_deleted = not config.show_deleted
end
M.refresh()
return config.show_deleted
end

local function get_cursor_hunk(bufnr: integer, hunks: {Hunk}): Hunk, integer
Expand Down

0 comments on commit 4a68d2a

Please sign in to comment.