aboutsummaryrefslogtreecommitdiff
path: root/lua/startup
diff options
context:
space:
mode:
authormax397574 <[email protected]>2021-12-09 11:28:08 +0100
committermax397574 <[email protected]>2021-12-09 11:28:08 +0100
commit9d1ddb0afbc2e2ea540ba21a3d009ba23abdf056 (patch)
tree020a4c96d6b40ff3b176f81a938f8823ee6bdec8 /lua/startup
parent16c4e5252fe25b7874a48c14c9c822a6fecd7d20 (diff)
chore: autoformat with stylua
Diffstat (limited to 'lua/startup')
-rw-r--r--lua/startup/themes/startify.lua46
-rw-r--r--lua/startup/utils.lua70
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]="<cmd>e "..file.."<CR>"
+ user_bookmark_mappings[key] = "<cmd>e " .. file .. "<CR>"
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), "<cmd>e "..all_oldfiles[i+1].."<CR>", {noremap = true,silent = true})
+ vim.api.nvim_buf_set_keymap(
+ 0,
+ "n",
+ tostring(i),
+ "<cmd>e " .. all_oldfiles[i + 1] .. "<CR>",
+ { 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,