From cd910db45c591b05902fe5bd82fe1f2a084dee6c Mon Sep 17 00:00:00 2001 From: jgmdev Date: Sun, 13 Mar 2022 14:34:40 -0400 Subject: force_syntax: use new StatusView api --- plugins/force_syntax.lua | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'plugins/force_syntax.lua') diff --git a/plugins/force_syntax.lua b/plugins/force_syntax.lua index 640e1d3..e5d17e2 100644 --- a/plugins/force_syntax.lua +++ b/plugins/force_syntax.lua @@ -39,30 +39,23 @@ local function get_syntax_name(s) return name or "Undefined" end -local statusview_get_items = StatusView.get_items -function StatusView:get_items() - local left, right = statusview_get_items(self) - - local is_dv = core.active_view and getmetatable(core.active_view) == DocView - if not is_dv then return left, right end - - local syntax_name = get_syntax_name(doc().syntax) - - local ins = { - style.dim, - self.separator2, - style.text, - syntax_name - } - - if syntax_name then - for _,item in pairs(ins) do - table.insert(right, item) - end - end - - return left, right -end +core.status_view:add_item( + function() + return core.active_view and getmetatable(core.active_view) == DocView + end, + "doc:syntax", + StatusView.Item.RIGHT, + 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 local function get_syntax_list() local pt_name = plain_text_syntax.name -- cgit v1.2.3