From f67f7bf4d9952abfcba3a26dd25c6f7afcd8614f Mon Sep 17 00:00:00 2001 From: max397574 Date: Wed, 6 Oct 2021 16:07:16 +0200 Subject: =?UTF-8?q?feat(config):=20=E2=9C=A8allow=20right=20align?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/startup.lua | 15 +++++++++++---- lua/startup/config.lua | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lua/startup.lua b/lua/startup.lua index cffe0b9..0696112 100644 --- a/lua/startup.lua +++ b/lua/startup.lua @@ -1,12 +1,13 @@ local M = {} local ns = vim.api.nvim_create_namespace "startup" +local limited_space = false + local opts = { noremap = true, silent = true } local settings = require "startup.config" local utils = require "startup.utils" local spaces = utils.spaces -local empty = utils.empty local function create_mappings() vim.api.nvim_buf_set_keymap( @@ -43,16 +44,23 @@ end local function align(dict) local aligned = {} + local max_len = utils.longest_line(dict) if settings.options.align == "center" then - local max_len = utils.longest_line(dict) local space_left = vim.o.columns - max_len for _, line in ipairs(dict) do table.insert(aligned, spaces(space_left / 2) .. line) end - elseif settings.options.align == "padding" then + elseif settings.options.align == "left" then for _, line in ipairs(dict) do table.insert(aligned, spaces(settings.options.padding) .. line) end + elseif settings.options.align == "right" then + for _, line in ipairs(dict) do + table.insert( + aligned, + spaces(vim.o.columns - max_len - settings.options.padding - 10) .. line + ) + end end return aligned end @@ -91,7 +99,6 @@ local function body() end function M.display() - local limited_space = false local rly_limited_space = false if vim.o.lines < (#settings.header + (#settings.tools * 2) + 20) then diff --git a/lua/startup/config.lua b/lua/startup/config.lua index 13a5df0..27206e7 100644 --- a/lua/startup/config.lua +++ b/lua/startup/config.lua @@ -25,9 +25,9 @@ local settings = { ["ﲉ Help Files"] = { "Telescope help_tags", "fh" }, }, options = { - align = "center", -- center or padding + align = "center", -- center, left or right mapping_names = true, - padding = 5, -- only used if align padding + padding = 5, -- only used if align left or right }, colors = { background = "#1f2227", -- cgit v1.2.3