aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-03-13 14:34:40 -0400
committerjgmdev <jgmdev@gmail.com>2022-05-22 13:16:10 -0400
commitcd910db45c591b05902fe5bd82fe1f2a084dee6c (patch)
treeb2618b33edec9da9d24220bbce381a0f2bedfd83
parent33d43f46caca1a8b4948c0582a3562f6ed05626d (diff)
downloadlite-xl-plugins-cd910db45c591b05902fe5bd82fe1f2a084dee6c.tar.gz
lite-xl-plugins-cd910db45c591b05902fe5bd82fe1f2a084dee6c.zip
force_syntax: use new StatusView api
-rw-r--r--plugins/force_syntax.lua41
1 files changed, 17 insertions, 24 deletions
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