From 80f6c7825ad2d0c0ab3814c36a5fde990f7954f4 Mon Sep 17 00:00:00 2001 From: max397574 Date: Wed, 6 Oct 2021 07:49:59 +0200 Subject: =?UTF-8?q?feat(plugin):=20=E2=9C=A8added=20check=20for=20limited?= =?UTF-8?q?=20space?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/startuptools.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lua/startuptools.lua b/lua/startuptools.lua index b5344e4..f36f3f6 100644 --- a/lua/startuptools.lua +++ b/lua/startuptools.lua @@ -24,6 +24,7 @@ local settings = { [" Config Files"] = {'lua require("telescope.builtin").find_files({cwd="~/.config"})', "cf"}, [" Colorschemes"] = {"Telescope colorscheme", "cs"}, [" New File"] = {"lua require'startuptools'.new_file()", "nf"}, + ["ﲉ Help Files"] = {"Telescope help_tags", "fh"}, }, options = { align = "center", -- center or padding @@ -126,15 +127,24 @@ local function set_options() end function M.display() + local limited_space = false + local rly_limited_space = false + if vim.o.lines < (#settings.header + (#settings.tools*2) + 20) then + limited_space = true + end create_mappings() create_hls() vim.api.nvim_buf_set_keymap(0, "n", "j", "2j", opts) vim.api.nvim_buf_set_keymap(0, "n", "k", "2k", opts) - empty() + if not limited_space then + empty() + end set_lines(#settings.header, settings.header, "StartuptoolsHeading") local toolnames = {} for name, cmd in pairs(settings.tools) do - table.insert(toolnames, " ") + if not limited_space then + table.insert(toolnames, " ") + end if settings.options.mapping_names then table.insert(toolnames, name .. " " .. cmd[2]) else @@ -145,7 +155,9 @@ function M.display() set_lines(#toolnames, toolnames, "StartuptoolsTools") vim.cmd [[silent! %s/\s\+$//]] -- clear trailing whitespace set_options() - vim.api.nvim_win_set_cursor(0, { #settings.header + 5, vim.o.columns / 2 }) + if limited_space then + vim.api.nvim_win_set_cursor(0, {#settings.header + 3, math.floor(vim.o.columns/2)}) + end end function M.setup(update) -- cgit v1.2.3