From cd5d85a11b5eecaf12d9a9f420e8924ed6a214d7 Mon Sep 17 00:00:00 2001 From: siduck Date: Mon, 4 Jul 2022 07:09:38 +0530 Subject: [PATCH] modularize statusline config | Make overriding of it actually work (#1307) --- lua/core/default_config.lua | 2 +- lua/ui/statusline/init.lua | 19 +++++++++++++++++++ .../modules.lua} | 19 ------------------- 3 files changed, 20 insertions(+), 20 deletions(-) create mode 100644 lua/ui/statusline/init.lua rename lua/ui/{statusline.lua => statusline/modules.lua} (93%) diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index 98ecbb6..3659f9a 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -23,7 +23,7 @@ M.ui = { statusline = { separator_style = "default", -- default/round/block/arrow - config = "%!v:lua.require('ui.statusline').run()", + config = "%!v:lua.require('ui.statusline')", override = {}, }, diff --git a/lua/ui/statusline/init.lua b/lua/ui/statusline/init.lua new file mode 100644 index 0000000..9b73c09 --- /dev/null +++ b/lua/ui/statusline/init.lua @@ -0,0 +1,19 @@ +local modules = require "ui.statusline.modules" + +local user_override = require("core.utils").load_config().ui.statusline.override +modules = vim.tbl_deep_extend("force", modules, user_override) + +return table.concat { + modules.mode(), + modules.fileInfo(), + modules.git(), + + "%=", + modules.LSP_progress(), + "%=", + + modules.LSP_Diagnostics(), + modules.LSP_status() or "", + modules.cwd(), + modules.cursor_position(), +} diff --git a/lua/ui/statusline.lua b/lua/ui/statusline/modules.lua similarity index 93% rename from lua/ui/statusline.lua rename to lua/ui/statusline/modules.lua index df52cb9..3b1f517 100644 --- a/lua/ui/statusline.lua +++ b/lua/ui/statusline/modules.lua @@ -135,23 +135,4 @@ M.cursor_position = function() return left_sep .. "%#St_pos_text#" .. " " .. text .. " " end -M.run = function() - return table.concat { - M.mode(), - M.fileInfo(), - M.git(), - - "%=", - M.LSP_progress(), - "%=", - - M.LSP_Diagnostics(), - M.LSP_status() or "", - M.cwd(), - M.cursor_position(), - } -end - -M = vim.tbl_deep_extend("force", M, require("core.utils").load_config().ui.statusline.override) - return M