diff options
author | max397574 <[email protected]> | 2021-10-06 07:49:59 +0200 |
---|---|---|
committer | max397574 <[email protected]> | 2021-10-06 07:49:59 +0200 |
commit | 80f6c7825ad2d0c0ab3814c36a5fde990f7954f4 (patch) | |
tree | 1fb4a2af535b7e75c9d99a2aabf5856152f28365 | |
parent | d9e06d1a9ebd0c7383f1bdcfad7abddfadacc621 (diff) |
feat(plugin): ✨added check for limited space
-rw-r--r-- | lua/startuptools.lua | 18 |
1 files 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"})', "<leader>cf"}, [" Colorschemes"] = {"Telescope colorscheme", "<leader>cs"}, [" New File"] = {"lua require'startuptools'.new_file()", "<leader>nf"}, + ["ﲉ Help Files"] = {"Telescope help_tags", "<leader>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) |