diff options
author | Guldoman <giulio.lettieri@gmail.com> | 2022-07-15 06:34:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-15 00:34:52 -0400 |
commit | dfd0a5020fbf5904ca674256ff42510be5e11a48 (patch) | |
tree | b02f25411f3e40a819577ebf2d607fe77a214f65 | |
parent | a1c7102578f166df804bf5dbdbe6aac6810dff2d (diff) | |
download | lite-xl-plugins-dfd0a5020fbf5904ca674256ff42510be5e11a48.tar.gz lite-xl-plugins-dfd0a5020fbf5904ca674256ff42510be5e11a48.zip |
Use new `StatusView:add_item` syntax (#117)
-rw-r--r-- | plugins/force_syntax.lua | 19 | ||||
-rw-r--r-- | plugins/gitstatus.lua | 17 | ||||
-rw-r--r-- | plugins/memoryusage.lua | 17 | ||||
-rw-r--r-- | plugins/scalestatus.lua | 17 | ||||
-rw-r--r-- | plugins/smallclock.lua | 15 | ||||
-rw-r--r-- | plugins/statusclock.lua | 15 | ||||
-rw-r--r-- | plugins/typingspeed.lua | 18 | ||||
-rw-r--r-- | plugins/wordcount.lua | 12 |
8 files changed, 63 insertions, 67 deletions
diff --git a/plugins/force_syntax.lua b/plugins/force_syntax.lua index 5c1d2eb..ae5a138 100644 --- a/plugins/force_syntax.lua +++ b/plugins/force_syntax.lua @@ -39,23 +39,24 @@ local function get_syntax_name(s) return name or "Undefined" end -core.status_view:add_item( - function() +core.status_view:add_item({ + predicate = function() return core.active_view and getmetatable(core.active_view) == DocView end, - "doc:syntax", - StatusView.Item.RIGHT, - function() + name = "doc:syntax", + alignment = StatusView.Item.RIGHT, + get_item = function() local syntax_name = get_syntax_name(doc().syntax) return { style.text, syntax_name } end, - "force-syntax:select-file-syntax", - -1, - "file syntax" -).separator = core.status_view.separator2 + command = "force-syntax:select-file-syntax", + position = -1, + tooltip = "file syntax", + separator = core.status_view.separator2 +}) local function get_syntax_list() local pt_name = plain_text_syntax.name diff --git a/plugins/gitstatus.lua b/plugins/gitstatus.lua index fc7a2ea..9a36142 100644 --- a/plugins/gitstatus.lua +++ b/plugins/gitstatus.lua @@ -116,11 +116,10 @@ core.add_thread(function() end) -core.status_view:add_item( - nil, - "status:git", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:git", + alignment = StatusView.Item.RIGHT, + get_item = function() if not git.branch then return {} end @@ -133,7 +132,7 @@ core.status_view:add_item( git.deletes ~= 0 and style.accent or style.text, "-", git.deletes, } end, - nil, - -1, - "branch and changes" -).separator = core.status_view.separator2 + position = -1, + tooltip = "branch and changes", + separator = core.status_view.separator2 +}) diff --git a/plugins/memoryusage.lua b/plugins/memoryusage.lua index d84a8c2..16220fc 100644 --- a/plugins/memoryusage.lua +++ b/plugins/memoryusage.lua @@ -30,11 +30,10 @@ config.plugins.memoryusage = common.merge({ } }, config.plugins.memoryusage) -core.status_view:add_item( - nil, - "status:memory-usage", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:memory-usage", + alignment = StatusView.Item.RIGHT, + get_item = function() return { style.text, string.format( @@ -43,8 +42,8 @@ core.status_view:add_item( ) } end, - nil, - 1, - "lua memory usage" -).separator = core.status_view.separator2 + potition = 1, + tooltip = "lua memory usage", + separator = core.status_view.separator2 +}) diff --git a/plugins/scalestatus.lua b/plugins/scalestatus.lua index aa08cdc..b07177f 100644 --- a/plugins/scalestatus.lua +++ b/plugins/scalestatus.lua @@ -36,20 +36,19 @@ config.plugins.scalestatus = common.merge({ } }, config.plugins.scalestatus) -core.status_view:add_item( - nil, - "status:scale", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:scale", + alignment = StatusView.Item.RIGHT, + get_item = function() return {string.format( config.plugins.scalestatus.format, scale.get() * 100 )} end, - nil, - 1, - "scale" -).separator = core.status_view.separator2 + position = 1, + "scale", + separator = core.status_view.separator2 +}) return true diff --git a/plugins/smallclock.lua b/plugins/smallclock.lua index 7c845d7..e975152 100644 --- a/plugins/smallclock.lua +++ b/plugins/smallclock.lua @@ -54,14 +54,13 @@ local function update_time() end end -core.status_view:add_item( - nil, - "status:small-clock", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + name = "status:small-clock", + alignment = StatusView.Item.RIGHT, + get_item = function() update_time() return {style.accent, time} end, - nil, - -1 -).separator = core.status_view.separator2 + position = -1, + separator = core.status_view.separator2 +}) diff --git a/plugins/statusclock.lua b/plugins/statusclock.lua index 0fe95dd..aec58e3 100644 --- a/plugins/statusclock.lua +++ b/plugins/statusclock.lua @@ -68,11 +68,10 @@ local function update_time() end end -core.status_view:add_item( - nil, - "status:clock", - StatusView.Item.RIGHT, - function(self) +core.status_view:add_item({ + name = "status:clock", + alignment = StatusView.Item.RIGHT, + get_item = function(self) update_time() return { style.text, @@ -83,7 +82,7 @@ core.status_view:add_item( time_data.time_text, } end, - nil, - -1 -).separator = core.status_view.separator2 + position = -1, + separator = core.status_view.separator2 +}) diff --git a/plugins/typingspeed.lua b/plugins/typingspeed.lua index 14bd91c..0e28ec9 100644 --- a/plugins/typingspeed.lua +++ b/plugins/typingspeed.lua @@ -82,19 +82,19 @@ function DocView:on_text_input(text, idx) on_text_input(self, text, idx) end -core.status_view:add_item( - function() +core.status_view:add_item({ + predicate = function() return core.active_view and getmetatable(core.active_view) == DocView end, - "typing-speed:stats", - core.status_view.Item.RIGHT, - function() + name = "typing-speed:stats", + alignment = core.status_view.Item.RIGHT, + get_item = function() return { style.text, string.format("%.0f CPM / %.0f WPM", cpm, wpm) } end, - nil, - 1, - "characters / words per minute" -).separator = core.status_view.separator2 + position = 1, + tooltip = "characters / words per minute", + separator = core.status_view.separator2 +}) diff --git a/plugins/wordcount.lua b/plugins/wordcount.lua index 224ad5e..42224ac 100644 --- a/plugins/wordcount.lua +++ b/plugins/wordcount.lua @@ -71,11 +71,11 @@ end local cached_word_length, cached_word_count -core.status_view:add_item( - function() return core.active_view:is(DocView) and not core.active_view:is(CommandView) and words[core.active_view.doc] end, - "status:word-count", - StatusView.Item.RIGHT, - function() +core.status_view:add_item({ + predicate = function() return core.active_view:is(DocView) and not core.active_view:is(CommandView) and words[core.active_view.doc] end, + name = "status:word-count", + alignment = StatusView.Item.RIGHT, + get_item = function() local selection_text = core.active_view.doc:get_selection_text() if #selection_text ~= cached_word_length then cached_word_count = compute_line_words(selection_text) @@ -87,4 +87,4 @@ core.status_view:add_item( return { style.text, words[core.active_view.doc] .. " words" } end end -) +}) |