diff options
author | jgmdev <jgmdev@gmail.com> | 2022-03-11 05:19:28 -0400 |
---|---|---|
committer | jgmdev <jgmdev@gmail.com> | 2022-05-22 13:16:10 -0400 |
commit | 94bfa9a0e44b29836d933652db539d93d822704e (patch) | |
tree | 26951f53c9229cb662e11fc3c46386bf11a08a07 /plugins/gitstatus.lua | |
parent | 115b8073f7e453039e9633847b266723931017dc (diff) | |
download | lite-xl-plugins-94bfa9a0e44b29836d933652db539d93d822704e.tar.gz lite-xl-plugins-94bfa9a0e44b29836d933652db539d93d822704e.zip |
gitstatus: use new StatusView api
Diffstat (limited to 'plugins/gitstatus.lua')
-rw-r--r-- | plugins/gitstatus.lua | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua index 1846823..33dc5e5 100644 --- a/plugins/gitstatus.lua +++ b/plugins/gitstatus.lua @@ -99,27 +99,24 @@ core.add_thread(function() end) -local get_items = StatusView.get_items - -function StatusView:get_items() - if not git.branch then - return get_items(self) - end - local left, right = get_items(self) - - local t = { - style.dim, self.separator, - (git.inserts ~= 0 or git.deletes ~= 0) and style.accent or style.text, - git.branch, - style.dim, " ", - git.inserts ~= 0 and style.accent or style.text, "+", git.inserts, - style.dim, " / ", - git.deletes ~= 0 and style.accent or style.text, "-", git.deletes, - } - for _, item in ipairs(t) do - table.insert(right, item) - end - - return left, right -end - +core.status_view:add_item( + nil, + "status:git", + StatusView.Item.RIGHT, + function() + if not git.branch then + return {} + end + return { + (git.inserts ~= 0 or git.deletes ~= 0) and style.accent or style.text, + git.branch, + style.dim, " ", + git.inserts ~= 0 and style.accent or style.text, "+", git.inserts, + style.dim, " / ", + git.deletes ~= 0 and style.accent or style.text, "-", git.deletes, + } + end, + nil, + -1, + "branch and changes" +).separator = core.status_view.separator2 |