From 9d1ddb0afbc2e2ea540ba21a3d009ba23abdf056 Mon Sep 17 00:00:00 2001 From: max397574 Date: Thu, 9 Dec 2021 11:28:08 +0100 Subject: chore: autoformat with stylua --- lua/startup/themes/startify.lua | 46 ++++++++++++++------------- lua/startup/utils.lua | 70 ++++++++++++++++++++++++++++------------- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/lua/startup/themes/startify.lua b/lua/startup/themes/startify.lua index 311b30a..91362fb 100644 --- a/lua/startup/themes/startify.lua +++ b/lua/startup/themes/startify.lua @@ -1,49 +1,51 @@ local user_bookmarks = vim.g.startup_bookmarks -local bookmark_texts = {"Bookmarks",""} +local bookmark_texts = { "Bookmarks", "" } for key, file in pairs(user_bookmarks) do - bookmark_texts[#bookmark_texts+1] = key.." "..file + bookmark_texts[#bookmark_texts + 1] = key .. " " .. file end local user_bookmark_mappings = {} for key, file in pairs(user_bookmarks) do - user_bookmark_mappings[key]="e "..file.."" + user_bookmark_mappings[key] = "e " .. file .. "" end local cow = { -" \\ ^__^", -" \\ (oo)\\_______", -" (__)\\ )\\/\\", -" ||----w |", -" || ||", + " \\ ^__^", + " \\ (oo)\\_______", + " (__)\\ )\\/\\", + " ||----w |", + " || ||", } -local quote = require"startup.functions".quote() +local quote = require("startup.functions").quote() while true do - if require"startup.utils".longest_line(quote) <= vim.o.columns-15 then + if require("startup.utils").longest_line(quote) <= vim.o.columns - 15 then break end - quote = require"startup.functions".quote() + quote = require("startup.functions").quote() end -local length = require"startup.utils".longest_line(quote)+4 +local length = require("startup.utils").longest_line(quote) + 4 local complete = {} -table.insert(quote,1,"") -quote[#quote+1]="" +table.insert(quote, 1, "") +quote[#quote + 1] = "" - -table.insert(complete,"▛"..string.rep("▀",length-2).."▜") +table.insert(complete, "▛" .. string.rep("▀", length - 2) .. "▜") local function spaces(amount) - return string.rep(" ",amount) - end + return string.rep(" ", amount) +end for _, line in ipairs(quote) do - table.insert(complete, "▌".." "..line..spaces(length-3-#line).."▐") + table.insert( + complete, + "▌" .. " " .. line .. spaces(length - 3 - #line) .. "▐" + ) end -table.insert(complete,"▙"..string.rep("▄",length-2).."▟") +table.insert(complete, "▙" .. string.rep("▄", length - 2) .. "▟") for _, line in ipairs(cow) do - complete[#complete+1] = line + complete[#complete + 1] = line end -- NOTE: lua dump(vim.fn.expand("#<1")) to get newest oldfile @@ -113,7 +115,7 @@ local settings = { background = "#1f2227", folded_section = "#56b6c2", }, - parts = { "header", "body", "body_2", "bookmarks"}, + parts = { "header", "body", "body_2", "bookmarks" }, } return settings diff --git a/lua/startup/utils.lua b/lua/startup/utils.lua index bfe74fc..bf25141 100644 --- a/lua/startup/utils.lua +++ b/lua/startup/utils.lua @@ -191,15 +191,18 @@ function U.get_oldfiles(amount) local oldfiles_shortened = {} for _, file in ipairs(oldfiles) do if oldfiles_total < 10 then - oldfiles_shortened[#oldfiles_shortened+1]="["..oldfiles_total.."] "..string.gsub(file, home, "~") + oldfiles_shortened[#oldfiles_shortened + 1] = "[" + .. oldfiles_total + .. "] " + .. string.gsub(file, home, "~") else - oldfiles_shortened[#oldfiles_shortened+1]=string.gsub(file, home, "~") + oldfiles_shortened[#oldfiles_shortened + 1] = string.gsub(file, home, "~") end - oldfiles_total = oldfiles_total+1 + oldfiles_total = oldfiles_total + 1 end oldfiles = oldfiles_shortened - table.insert(oldfiles,1,"Last Files:") - table.insert(oldfiles,2,"") + table.insert(oldfiles, 1, "Last Files:") + table.insert(oldfiles, 2, "") local length = U.longest_line(oldfiles) + 2 local oldfiles_aligned = {} @@ -229,15 +232,18 @@ function U.get_oldfiles_directory(amount) local oldfiles_shortened = {} for _, file in ipairs(oldfiles) do if oldfiles_total < 10 then - oldfiles_shortened[#oldfiles_shortened+1]="["..oldfiles_total.."] "..string.gsub(file, home, "~") + oldfiles_shortened[#oldfiles_shortened + 1] = "[" + .. oldfiles_total + .. "] " + .. string.gsub(file, home, "~") else - oldfiles_shortened[#oldfiles_shortened+1]=string.gsub(file, home, "~") + oldfiles_shortened[#oldfiles_shortened + 1] = string.gsub(file, home, "~") end - oldfiles_total = oldfiles_total+1 + oldfiles_total = oldfiles_total + 1 end oldfiles = oldfiles_shortened - table.insert(oldfiles,1,"Last Files in "..directory..":") - table.insert(oldfiles,2,"") + table.insert(oldfiles, 1, "Last Files in " .. directory .. ":") + table.insert(oldfiles, 2, "") local length = U.longest_line(oldfiles) + 2 local oldfiles_aligned = {} @@ -252,7 +258,13 @@ function U.oldfiles_mappings() return end for i = 0, 9, 1 do - vim.api.nvim_buf_set_keymap(0, "n", tostring(i), "e "..all_oldfiles[i+1].."", {noremap = true,silent = true}) + vim.api.nvim_buf_set_keymap( + 0, + "n", + tostring(i), + "e " .. all_oldfiles[i + 1] .. "", + { noremap = true, silent = true } + ) end end @@ -414,23 +426,37 @@ function U.set_buf_options() ) vim.cmd( [[autocmd BufEnter * lua if vim.opt.filetype~="startup" then vim.opt.laststatus=]] - .. last_status - .. [[;vim.opt.showtabline=]] - .. tab_line - .. [[ end]] + .. last_status + .. [[;vim.opt.showtabline=]] + .. tab_line + .. [[ end]] ) end ---validate the settings ---@param options table the settings for a section function U.validate_settings(options) - if not options.oldfiles_directory then options.oldfiles_directory = false end - if not options.fold_section then options.fold_section = false end - if not options.margin then options.margin = 5 end - if not options.title then options.title = "" end - if not options.default_color then options.default_color = "" end - if not options.highlights then options.highlights = "" end - if not options.oldfiles_amount then options.oldfiles_amount = 5 end + if not options.oldfiles_directory then + options.oldfiles_directory = false + end + if not options.fold_section then + options.fold_section = false + end + if not options.margin then + options.margin = 5 + end + if not options.title then + options.title = "" + end + if not options.default_color then + options.default_color = "" + end + if not options.highlights then + options.highlights = "" + end + if not options.oldfiles_amount then + options.oldfiles_amount = 5 + end vim.validate({ type = { options.type, -- cgit v1.2.3