aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormax397574 <[email protected]>2022-01-15 20:39:29 +0100
committermax397574 <[email protected]>2022-01-15 20:39:29 +0100
commitfefba0a70d8de780e5366e53baea9b4ca63b2698 (patch)
tree31dd6369f78847e2482e3a1e97b430efc6737383
parentbe883e02b3ca7b49f0fd338c35ecdb65ff44a2a6 (diff)
chore: autoformat with stylua
-rw-r--r--doc/tags6
-rw-r--r--lua/startup/functions.lua32
-rw-r--r--lua/startup/headers.lua114
-rw-r--r--lua/startup/quotes.lua208
-rw-r--r--lua/startup/themes/dashboard.lua138
-rw-r--r--lua/startup/themes/empty.lua38
-rw-r--r--lua/startup/themes/evil.lua234
-rw-r--r--lua/startup/themes/startify.lua168
-rw-r--r--lua/startup/utils.lua941
-rw-r--r--scripts/gendocs.lua26
-rw-r--r--stylua.toml2
11 files changed, 967 insertions, 940 deletions
diff --git a/doc/tags b/doc/tags
index 7b7a70a..2d96fa9 100644
--- a/doc/tags
+++ b/doc/tags
@@ -1,4 +1,8 @@
functions.date_time() startup.txt /*functions.date_time()*
functions.packer_plugins() startup.txt /*functions.packer_plugins()*
functions.quote() startup.txt /*functions.quote()*
-startup.nvim_functions startup.txt /*startup.nvim_functions*
+headers.default_header() startup.txt /*headers.default_header()*
+headers.hydra() startup.txt /*headers.hydra()*
+headers.neovim_logo() startup.txt /*headers.neovim_logo()*
+startup_nvim.functions startup.txt /*startup_nvim.functions*
+startup_nvim.headers startup.txt /*startup_nvim.headers*
diff --git a/lua/startup/functions.lua b/lua/startup/functions.lua
index 63c26df..bcc4248 100644
--- a/lua/startup/functions.lua
+++ b/lua/startup/functions.lua
@@ -9,32 +9,32 @@ local quotes = require("startup.quotes")
---Returns a random programming quote
---@return table: Lines of text for the quote
function functions.quote()
- math.randomseed(os.clock())
- local index = math.random() * #quotes
- return quotes[math.floor(index) + 1]
+ math.randomseed(os.clock())
+ local index = math.random() * #quotes
+ return quotes[math.floor(index) + 1]
end
---Returns a string with the number of loaded Packer Plugins
---@return string: String with info about the number of loaded plugins
function functions.packer_plugins()
- if packer_plugins then
- return {
- string.format(
- "Total plugins (packer.nvim): %d",
- vim.tbl_count(packer_plugins)
- ),
- }
- else
- return ""
- end
+ if packer_plugins then
+ return {
+ string.format(
+ "Total plugins (packer.nvim): %d",
+ vim.tbl_count(packer_plugins)
+ ),
+ }
+ else
+ return ""
+ end
end
---Returns the current date and time
---@return table: Table with a string for the date and one for the time
function functions.date_time()
- local clock = " " .. os.date("%H:%M")
- local date = " " .. os.date("%d-%m-%y")
- return { clock, date }
+ local clock = " " .. os.date("%H:%M")
+ local date = " " .. os.date("%d-%m-%y")
+ return { clock, date }
end
return functions
diff --git a/lua/startup/headers.lua b/lua/startup/headers.lua
index 8e0bc6b..8e99762 100644
--- a/lua/startup/headers.lua
+++ b/lua/startup/headers.lua
@@ -4,12 +4,25 @@
---@brief ]]
local startup_headers = {}
-local log = require"startup.log"
+local log = require("startup.log")
---a neovim banner
function startup_headers.neovim_banner()
- log.warn("`headers.neovim_banner()` is deprecated. Use `headers.neovim_banner_header`")
- return {
+ log.warn(
+ "`headers.neovim_banner()` is deprecated. Use `headers.neovim_banner_header`"
+ )
+ return {
+ [[ /$$ ]],
+ [[ |__/ ]],
+ [[ /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$$$$$/$$$$ ]],
+ [[| $$__ $$ /$$__ $$ /$$__ $$| $$ /$$/| $$| $$_ $$_ $$]],
+ [[| $$ \ $$| $$$$$$$$| $$ \ $$ \ $$/$$/ | $$| $$ \ $$ \ $$]],
+ [[| $$ | $$| $$_____/| $$ | $$ \ $$$/ | $$| $$ | $$ | $$]],
+ [[| $$ | $$| $$$$$$$| $$$$$$/ \ $/ | $$| $$ | $$ | $$]],
+ [[|__/ |__/ \_______/ \______/ \_/ |__/|__/ |__/ |__/]],
+ }
+end
+startup_headers.neovim_banner_header = {
[[ /$$ ]],
[[ |__/ ]],
[[ /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$$$$$/$$$$ ]],
@@ -18,23 +31,27 @@ function startup_headers.neovim_banner()
[[| $$ | $$| $$_____/| $$ | $$ \ $$$/ | $$| $$ | $$ | $$]],
[[| $$ | $$| $$$$$$$| $$$$$$/ \ $/ | $$| $$ | $$ | $$]],
[[|__/ |__/ \_______/ \______/ \_/ |__/|__/ |__/ |__/]],
- }
-end
-startup_headers.neovim_banner_header = {
- [[ /$$ ]],
- [[ |__/ ]],
- [[ /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$$$$$/$$$$ ]],
- [[| $$__ $$ /$$__ $$ /$$__ $$| $$ /$$/| $$| $$_ $$_ $$]],
- [[| $$ \ $$| $$$$$$$$| $$ \ $$ \ $$/$$/ | $$| $$ \ $$ \ $$]],
- [[| $$ | $$| $$_____/| $$ | $$ \ $$$/ | $$| $$ | $$ | $$]],
- [[| $$ | $$| $$$$$$$| $$$$$$/ \ $/ | $$| $$ | $$ | $$]],
- [[|__/ |__/ \_______/ \______/ \_/ |__/|__/ |__/ |__/]],
}
---a hydra
function startup_headers.hydra()
- log.warn("`headers.hydra()` is deprecated. Use `headers.hydra_header`")
- return {
+ log.warn("`headers.hydra()` is deprecated. Use `headers.hydra_header`")
+ return {
+ [[ ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ]],
+ [[ ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ]],
+ [[ ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ]],
+ [[ ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ]],
+ [[ ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ]],
+ [[ ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ]],
+ [[ ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ]],
+ [[ ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ]],
+ [[ ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ]],
+ [[ ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ]],
+ [[ ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ]],
+ }
+end
+
+startup_headers.hydra_header = {
[[ ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ]],
[[ ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ]],
[[ ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ]],
@@ -46,27 +63,36 @@ function startup_headers.hydra()
[[ ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ]],
[[ ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ]],
[[ ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ]],
- }
-end
-
-startup_headers.hydra_header = {
- [[ ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣿⣶⣿⣦⣼⣆ ]],
- [[ ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ]],
- [[ ⠈⢿⣿⣟⠦ ⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ]],
- [[ ⣸⣿⣿⢧ ⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ]],
- [[ ⢠⣿⣿⣿⠈ ⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ]],
- [[ ⢠⣧⣶⣥⡤⢄ ⣸⣿⣿⠘ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ]],
- [[ ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾⠄ ]],
- [[ ⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ]],
- [[ ⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿ ⣿⣿⡇ ⠛⠻⢷⣄ ]],
- [[ ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ]],
- [[ ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ]],
}
---a neovim `n`
function startup_headers.neovim_logo()
- log.warn("`headers.neovim_logo()` is deprecated. Use `headers.neovim_logo_header`")
- return {
+ log.warn(
+ "`headers.neovim_logo()` is deprecated. Use `headers.neovim_logo_header`"
+ )
+ return {
+ [[⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠀⠀⠀⠀⠀⠀⠀]],
+ [[⠀⠀⠀⠀⠀⠀⣀⣶⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⣄⠀⠀⠀⠀⠀]],
+ [[⠀⠀⠀⠀⣀⣶⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣷⣄⠀⠀⠀]],
+ [[⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⣿⣷⡀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣷⣄⠀]],
+ [[⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠄⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣷]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡂⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]],
+ [[⠀⢿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿]],
+ [[⠀⠀⠙⢿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀]],
+ [[⠀⠀⠀⠀⠙⢿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀]],
+ [[⠀⠀⠀⠀⠀⠀⠙⢿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡿⠋⠀⠀⠀⠀⠀]],
+ [[⠀⠀⠀⠀⠀⠀⠀⠀⠙⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠋ ]],
+ }
+end
+startup_headers.neovim_logo_header = {
[[⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠀⠀⠀⠀⠀⠀⠀]],
[[⠀⠀⠀⠀⠀⠀⣀⣶⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⣄⠀⠀⠀⠀⠀]],
[[⠀⠀⠀⠀⣀⣶⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣷⣄⠀⠀⠀]],
@@ -86,28 +112,6 @@ function startup_headers.neovim_logo()
[[⠀⠀⠀⠀⠙⢿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀]],
[[⠀⠀⠀⠀⠀⠀⠙⢿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡿⠋⠀⠀⠀⠀⠀]],
[[⠀⠀⠀⠀⠀⠀⠀⠀⠙⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠋ ]],
- }
-end
-startup_headers.neovim_logo_header = {
- [[⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⠀⠀⠀⠀⠀⠀⠀]],
- [[⠀⠀⠀⠀⠀⠀⣀⣶⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣷⣄⠀⠀⠀⠀⠀]],
- [[⠀⠀⠀⠀⣀⣶⣿⣿⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣷⣄⠀⠀⠀]],
- [[⠀⠀⣠⣶⣿⣿⣿⣿⣿⣿⣿⣷⡀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣷⣄⠀]],
- [[⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠄⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣷]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡂⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣦⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣧⡀⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]],
- [[⠀⢿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿]],
- [[⠀⠀⠙⢿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠋⠀]],
- [[⠀⠀⠀⠀⠙⢿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣿⣿⣿⣿⣿⡿⠋⠀⠀⠀]],
- [[⠀⠀⠀⠀⠀⠀⠙⢿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢿⣿⡿⠋⠀⠀⠀⠀⠀]],
- [[⠀⠀⠀⠀⠀⠀⠀⠀⠙⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠋ ]],
}
return startup_headers
diff --git a/lua/startup/quotes.lua b/lua/startup/quotes.lua
index 807d6fa..67246e9 100644
--- a/lua/startup/quotes.lua
+++ b/lua/startup/quotes.lua
@@ -1,108 +1,108 @@
local quotes = {
- {
- "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.",
- "",
- "- Brian Kernighan",
- },
- {
- "If you don't fail at least 90% of the time, you're not aiming high enough.",
- "",
- "- Alan Kay",
- },
- {
- "Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.",
- "",
- "- John Woods",
- },
- {
- "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.",
- },
- {
- "If you don't make mistakes, you're not working on hard enough problems.",
- "",
- "- Frank Wilczek",
- },
- {
- "Use tracer bullets to find the target.",
- "",
- "Tracer bullets let you home in on your target by trying things and seeing how close they land.",
- },
- {
- "Always design for concurrency.",
- "",
- "Allow for concurrency, and you'll design cleaner interfaces with fewer assumptions.",
- },
- {
- "Test your software, or your users will.",
- "",
- "Test ruthlessly. Don't make your users find bugs for you.",
- },
- {
- "Don't live with broken windows.",
- "",
- "Fix bad designs, wrong decisions, and poor code when you see them.",
- },
- {
- "Keep knowledge in plain text.",
- "",
- "Plain text won't become obsolete. It helps leverage your work and simplifies debugging and testing.",
- },
- {
- "Use a single editor well.",
- "",
- "The editor should be an extension of your hand; make sure your editor is configurable, extensible, and programmable.",
- },
- {
- "Crash early.",
- "",
- "A dead program normally does a lot less damage than a crippled one.",
- },
- {
- "Design to test.",
- "",
- "Start thinking about testing before you write a line of code.",
- },
- {
- "Work with a user to think like a user.",
- "",
- "It's the best way to gain insight into how the system will really be used.",
- },
- {
- "Test early. Test often. Test automatically.",
- "",
- "Tests that run with every build are much more effective than test plans that sit on a shelf.",
- },
- {
- "Use saboteurs to test your testing.",
- "",
- "Introduce bugs on purpose in a separate copy of the source to verify that testing will catch them.",
- },
- {
- "There's an old story about the person who wished his computer were as easy to use as his telephone. That wish has come true, since I no longer know how to use my telephone.",
- "",
- "- Bjarne Stroustrup",
- },
- {
- 'There are only two industries that refer to their customers as "users".',
- "",
- "- Edward Tufte",
- },
- {
- "Easy things should be easy and hard things should be possible.",
- "",
- "- Larry Wall",
- },
- { "They did not know it was impossible, so they did it!", "", "- Mark Twain" },
- {
- "If debugging is the process of removing bugs, then programming must be the process of putting them in.",
- "",
- "- Edsger W. Dijkstra",
- },
- {
- "The average user doesn't give a damn what happens, as long as (1) it works and (2) it's fast.",
- "",
- "- Daniel J. Bernstein",
- },
+ {
+ "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.",
+ "",
+ "- Brian Kernighan",
+ },
+ {
+ "If you don't fail at least 90% of the time, you're not aiming high enough.",
+ "",
+ "- Alan Kay",
+ },
+ {
+ "Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.",
+ "",
+ "- John Woods",
+ },
+ {
+ "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.",
+ },
+ {
+ "If you don't make mistakes, you're not working on hard enough problems.",
+ "",
+ "- Frank Wilczek",
+ },
+ {
+ "Use tracer bullets to find the target.",
+ "",
+ "Tracer bullets let you home in on your target by trying things and seeing how close they land.",
+ },
+ {
+ "Always design for concurrency.",
+ "",
+ "Allow for concurrency, and you'll design cleaner interfaces with fewer assumptions.",
+ },
+ {
+ "Test your software, or your users will.",
+ "",
+ "Test ruthlessly. Don't make your users find bugs for you.",
+ },
+ {
+ "Don't live with broken windows.",
+ "",
+ "Fix bad designs, wrong decisions, and poor code when you see them.",
+ },
+ {
+ "Keep knowledge in plain text.",
+ "",
+ "Plain text won't become obsolete. It helps leverage your work and simplifies debugging and testing.",
+ },
+ {
+ "Use a single editor well.",
+ "",
+ "The editor should be an extension of your hand; make sure your editor is configurable, extensible, and programmable.",
+ },
+ {
+ "Crash early.",
+ "",
+ "A dead program normally does a lot less damage than a crippled one.",
+ },
+ {
+ "Design to test.",
+ "",
+ "Start thinking about testing before you write a line of code.",
+ },
+ {
+ "Work with a user to think like a user.",
+ "",
+ "It's the best way to gain insight into how the system will really be used.",
+ },
+ {
+ "Test early. Test often. Test automatically.",
+ "",
+ "Tests that run with every build are much more effective than test plans that sit on a shelf.",
+ },
+ {
+ "Use saboteurs to test your testing.",
+ "",
+ "Introduce bugs on purpose in a separate copy of the source to verify that testing will catch them.",
+ },
+ {
+ "There's an old story about the person who wished his computer were as easy to use as his telephone. That wish has come true, since I no longer know how to use my telephone.",
+ "",
+ "- Bjarne Stroustrup",
+ },
+ {
+ 'There are only two industries that refer to their customers as "users".',
+ "",
+ "- Edward Tufte",
+ },
+ {
+ "Easy things should be easy and hard things should be possible.",
+ "",
+ "- Larry Wall",
+ },
+ { "They did not know it was impossible, so they did it!", "", "- Mark Twain" },
+ {
+ "If debugging is the process of removing bugs, then programming must be the process of putting them in.",
+ "",
+ "- Edsger W. Dijkstra",
+ },
+ {
+ "The average user doesn't give a damn what happens, as long as (1) it works and (2) it's fast.",
+ "",
+ "- Daniel J. Bernstein",
+ },
}
return quotes
diff --git a/lua/startup/themes/dashboard.lua b/lua/startup/themes/dashboard.lua
index 817ab17..8f0ef30 100644
--- a/lua/startup/themes/dashboard.lua
+++ b/lua/startup/themes/dashboard.lua
@@ -1,75 +1,75 @@
local settings = {
- -- every line should be same width without escaped \
- header = {
- type = "text",
- oldfiles_directory = false,
- align = "center",
- fold_section = false,
- title = "Header",
- margin = 5,
- content = {
- " ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗",
- " ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║",
- " ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║",
- " ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║",
- " ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║",
- " ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝",
+ -- every line should be same width without escaped \
+ header = {
+ type = "text",
+ oldfiles_directory = false,
+ align = "center",
+ fold_section = false,
+ title = "Header",
+ margin = 5,
+ content = {
+ " ███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗",
+ " ████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║",
+ " ██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║",
+ " ██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║",
+ " ██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║",
+ " ╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝",
+ },
+ highlight = "Statement",
+ default_color = "",
+ oldfiles_amount = 0,
},
- highlight = "Statement",
- default_color = "",
- oldfiles_amount = 0,
- },
- -- name which will be displayed and command
- body = {
- type = "mapping",
- oldfiles_directory = false,
- align = "center",
- fold_section = false,
- title = "Basic Commands",
- margin = 5,
- content = {
- { " Find File", "Telescope find_files", "<leader>ff" },
- { " Find Word", "Telescope live_grep", "<leader>lg" },
- { " Recent Files", "Telescope oldfiles", "<leader>of" },
- { " File Browser", "Telescope file_browser", "<leader>fb" },
- { " Colorschemes", "Telescope colorscheme", "<leader>cs" },
- { " New File", "lua require'startup'.new_file()", "<leader>nf" },
+ -- name which will be displayed and command
+ body = {
+ type = "mapping",
+ oldfiles_directory = false,
+ align = "center",
+ fold_section = false,
+ title = "Basic Commands",
+ margin = 5,
+ content = {
+ { " Find File", "Telescope find_files", "<leader>ff" },
+ { " Find Word", "Telescope live_grep", "<leader>lg" },
+ { " Recent Files", "Telescope oldfiles", "<leader>of" },
+ { " File Browser", "Telescope file_browser", "<leader>fb" },
+ { " Colorschemes", "Telescope colorscheme", "<leader>cs" },
+ { " New File", "lua require'startup'.new_file()", "<leader>nf" },
+ },
+ highlight = "String",
+ default_color = "",
+ oldfiles_amount = 0,
+ },
+ footer = {
+ type = "text",
+ oldfiles_directory = false,
+ align = "center",
+ fold_section = false,
+ title = "Footer",
+ margin = 5,
+ content = { "startup.nvim" },
+ highlight = "Number",
+ default_color = "",
+ oldfiles_amount = 0,
},
- highlight = "String",
- default_color = "",
- oldfiles_amount = 0,
- },
- footer = {
- type = "text",
- oldfiles_directory = false,
- align = "center",
- fold_section = false,
- title = "Footer",
- margin = 5,
- content = { "startup.nvim" },
- highlight = "Number",
- default_color = "",
- oldfiles_amount = 0,
- },
- options = {
- mapping_keys = true,
- cursor_column = 0.5,
- empty_lines_between_mappings = true,
- disable_statuslines = true,
- paddings = { 1, 3, 3, 0 },
- },
- mappings = {
- execute_command = "<CR>",
- open_file = "o",
- open_file_split = "<c-o>",
- open_section = "<TAB>",
- open_help = "?",
- },
- colors = {
- background = "#1f2227",
- folded_section = "#56b6c2",
- },
- parts = { "header", "body", "footer" },
+ options = {
+ mapping_keys = true,
+ cursor_column = 0.5,
+ empty_lines_between_mappings = true,
+ disable_statuslines = true,
+ paddings = { 1, 3, 3, 0 },
+ },
+ mappings = {
+ execute_command = "<CR>",
+ open_file = "o",
+ open_file_split = "<c-o>",
+ open_section = "<TAB>",
+ open_help = "?",
+ },
+ colors = {
+ background = "#1f2227",
+ folded_section = "#56b6c2",
+ },
+ parts = { "header", "body", "footer" },
}
return settings
diff --git a/lua/startup/themes/empty.lua b/lua/startup/themes/empty.lua
index 9ed8065..bcf82a9 100644
--- a/lua/startup/themes/empty.lua
+++ b/lua/startup/themes/empty.lua
@@ -1,22 +1,22 @@
local settings = {
- options = {
- mapping_keys = true,
- cursor_column = 0.5,
- empty_lines_between_mappings = true,
- disable_statuslines = false,
- paddings = { 1, 3, 3, 0 },
- },
- mappings = {
- execute_command = "<CR>",
- open_file = "o",
- open_file_split = "<c-o>",
- open_section = "<TAB>",
- open_help = "?",
- },
- colors = {
- background = "#1f2227",
- folded_section = "#56b6c2",
- },
- parts = {},
+ options = {
+ mapping_keys = true,
+ cursor_column = 0.5,
+ empty_lines_between_mappings = true,
+ disable_statuslines = false,
+ paddings = { 1, 3, 3, 0 },
+ },
+ mappings = {
+ execute_command = "<CR>",
+ open_file = "o",
+ open_file_split = "<c-o>",
+ open_section = "<TAB>",
+ open_help = "?",
+ },
+ colors = {
+ background = "#1f2227",
+ folded_section = "#56b6c2",
+ },
+ parts = {},
}
return settings
diff --git a/lua/startup/themes/evil.lua b/lua/startup/themes/evil.lua
index d401773..1ca5625 100644
--- a/lua/startup/themes/evil.lua
+++ b/lua/startup/themes/evil.lua
@@ -1,124 +1,124 @@
local settings = {
- -- every line should be same width without escaped \
- header = {
- type = "text",
- align = "center",
- fold_section = false,
- title = "Header",
- margin = 5,
- content = require("startup.headers").hydra_header,
- highlight = "Statement",
- default_color = "",
- oldfiles_amount = 0,
- },
- header_2 = {
- type = "text",
- oldfiles_directory = false,
- align = "center",
- fold_section = false,
- title = "Quote",
- margin = 5,
- content = require("startup.functions").quote(),
- highlight = "Constant",
- default_color = "",
- oldfiles_amount = 0,
- },
- -- name which will be displayed and command
- body = {
- type = "mapping",
- align = "center",
- fold_section = true,
- title = "Basic Commands",
- margin = 5,
- content = {
- { " Find File", "Telescope find_files", "<leader>ff" },
- { " Find Word", "Telescope live_grep", "<leader>lg" },
- { " Recent Files", "Telescope oldfiles", "<leader>of" },
- { " File Browser", "Telescope file_browser", "<leader>fb" },
- { " Colorschemes", "Telescope colorscheme", "<leader>cs" },
- { " New File", "lua require'startup'.new_file()", "<leader>nf" },
+ -- every line should be same width without escaped \
+ header = {
+ type = "text",
+ align = "center",
+ fold_section = false,
+ title = "Header",
+ margin = 5,
+ content = require("startup.headers").hydra_header,
+ highlight = "Statement",
+ default_color = "",
+ oldfiles_amount = 0,
+ },
+ header_2 = {
+ type = "text",
+ oldfiles_directory = false,
+ align = "center",
+ fold_section = false,
+ title = "Quote",
+ margin = 5,
+ content = require("startup.functions").quote(),
+ highlight = "Constant",
+ default_color = "",
+ oldfiles_amount = 0,
+ },
+ -- name which will be displayed and command
+ body = {
+ type = "mapping",
+ align = "center",
+ fold_section = true,
+ title = "Basic Commands",
+ margin = 5,
+ content = {
+ { " Find File", "Telescope find_files", "<leader>ff" },
+ { " Find Word", "Telescope live_grep", "<leader>lg" },
+ { " Recent Files", "Telescope oldfiles", "<leader>of" },
+ { " File Browser", "Telescope file_browser", "<leader>fb" },
+ { " Colorschemes", "Telescope colorscheme", "<leader>cs" },
+ { " New File", "lua require'startup'.new_file()", "<leader>nf" },
+ },
+ highlight = "String",
+ default_color = "",
+ oldfiles_amount = 0,
+ },
+ body_2 = {
+ type = "oldfiles",
+ oldfiles_directory = true,
+ align = "center",
+ fold_section = true,
+ title = "Oldfiles of Directory",
+ margin = 5,
+ content = {},
+ highlight = "String",
+ default_color = "#FFFFFF",
+ oldfiles_amount = 5,
+ },
+ footer = {
+ type = "oldfiles",
+ oldfiles_directory = false,
+ align = "center",
+ fold_section = true,
+ title = "Oldfiles",
+ margin = 5,
+ content = { "startup.nvim" },
+ highlight = "TSString",
+ default_color = "#FFFFFF",
+ oldfiles_amount = 5,
},
- highlight = "String",
- default_color = "",
- oldfiles_amount = 0,
- },
- body_2 = {
- type = "oldfiles",
- oldfiles_directory = true,
- align = "center",
- fold_section = true,
- title = "Oldfiles of Directory",
- margin = 5,
- content = {},
- highlight = "String",
- default_color = "#FFFFFF",
- oldfiles_amount = 5,
- },
- footer = {
- type = "oldfiles",
- oldfiles_directory = false,
- align = "center",
- fold_section = true,
- title = "Oldfiles",
- margin = 5,
- content = { "startup.nvim" },
- highlight = "TSString",
- default_color = "#FFFFFF",
- oldfiles_amount = 5,
- },
- clock = {
- type = "text",
- content = function()
- local clock = " " .. os.date("%H:%M")
- local date = " " .. os.date("%d-%m-%y")
- return { clock, date }
- end,
- oldfiles_directory = false,
- align = "center",
- fold_section = false,
- title = "",
- margin = 5,
- highlight = "TSString",
- default_color = "#FFFFFF",
- oldfiles_amount = 10,
- },
+ clock = {
+ type = "text",
+ content = function()
+ local clock = " " .. os.date("%H:%M")
+ local date = " " .. os.date("%d-%m-%y")
+ return { clock, date }
+ end,
+ oldfiles_directory = false,
+ align = "center",
+ fold_section = false,
+ title = "",
+ margin = 5,
+ highlight = "TSString",
+ default_color = "#FFFFFF",
+ oldfiles_amount = 10,
+ },
- footer_2 = {
- type = "text",
- content = require("startup.functions").packer_plugins(),
- oldfiles_directory = false,
- align = "center",
- fold_section = false,
- title = "",
- margin = 5,
- highlight = "TSString",
- default_color = "#FFFFFF",
- oldfiles_amount = 10,
- },
+ footer_2 = {
+ type = "text",
+ content = require("startup.functions").packer_plugins(),
+ oldfiles_directory = false,
+ align = "center",
+ fold_section = false,
+ title = "",
+ margin = 5,
+ highlight = "TSString",
+ default_color = "#FFFFFF",
+ oldfiles_amount = 10,
+ },
- options = {
- after = function()
- require("startup.utils").oldfiles_mappings()
- end,
- mapping_keys = true,
- cursor_column = 0.5,
- empty_lines_between_mappings = true,
- disable_statuslines = true,
- paddings = { 2, 2, 2, 2, 2, 2, 2 },
- },
- colors = {
- background = "#1f2227",
- folded_section = "#56b6c2",
- },
- parts = {
- "header",
- "header_2",
- "body",
- "body_2",
- "footer",
- "clock",
- "footer_2",
- },
+ options = {
+ after = function()
+ require("startup.utils").oldfiles_mappings()
+ end,
+ mapping_keys = true,
+ cursor_column = 0.5,
+ empty_lines_between_mappings = true,
+ disable_statuslines = true,
+ paddings = { 2, 2, 2, 2, 2, 2, 2 },
+ },
+ colors = {
+ background = "#1f2227",
+ folded_section = "#56b6c2",
+ },
+ parts = {
+ "header",
+ "header_2",
+ "body",
+ "body_2",
+ "footer",
+ "clock",
+ "footer_2",
+ },
}
return settings
diff --git a/lua/startup/themes/startify.lua b/lua/startup/themes/startify.lua
index 7e743e9..b9d1827 100644
--- a/lua/startup/themes/startify.lua
+++ b/lua/startup/themes/startify.lua
@@ -4,31 +4,31 @@ local bookmark_texts = { "Bookmarks", "" }
local user_bookmark_mappings = {}
if not user_bookmarks then
- user_bookmarks = {}
- bookmark_texts = {}
+ user_bookmarks = {}
+ bookmark_texts = {}
end
for key, file in pairs(user_bookmarks) do
- bookmark_texts[#bookmark_texts + 1] = key .. " " .. file
+ bookmark_texts[#bookmark_texts + 1] = key .. " " .. file
end
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()
while true do
- if require("startup.utils").longest_line(quote) <= vim.o.columns - 15 then
- break
- end
- quote = require("startup.functions").quote()
+ if require("startup.utils").longest_line(quote) <= vim.o.columns - 15 then
+ break
+ end
+ quote = require("startup.functions").quote()
end
local length = require("startup.utils").longest_line(quote) + 4
@@ -39,88 +39,88 @@ quote[#quote + 1] = ""
table.insert(complete, "▛" .. string.rep("▀", length - 2) .. "▜")
local function spaces(amount)
- return string.rep(" ", amount)
+ 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) .. "▟")
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
local settings = {
- header = {
- type = "text",
- oldfiles_directory = false,
- align = "left",
- fold_section = false,
- title = "Header",
- margin = 5,
- content = complete,
- highlight = "Statement",
- default_color = "",
- oldfiles_amount = 0,
- },
- body = {
- type = "oldfiles",
- oldfiles_directory = false,
- align = "left",
- fold_section = false,
- title = "Oldfiles",
- margin = 5,
- content = "",
- highlight = "String",
- default_color = "",
- oldfiles_amount = 5,
- },
- body_2 = {
- type = "oldfiles",
- oldfiles_directory = true,
- align = "left",
- fold_section = false,
- title = "",
- margin = 5,
- content = "",
- highlight = "String",
- oldfiles_amount = 5,
- },
- bookmarks = {
- type = "text",
- align = "left",
- margin = 5,
- content = bookmark_texts,
- highlight = "String",
- },
- options = {
- after = function()
- require("startup").create_mappings(user_bookmark_mappings)
- require("startup.utils").oldfiles_mappings()
- end,
- mapping_keys = false,
- cursor_column = 0.25,
- empty_line_between_mappings = false,
- disable_statuslines = true,
- paddings = { 1, 1, 1, 1 },
- },
- mappings = {
- execute_command = "<CR>",
- open_file = "o",
- open_file_split = "<c-o>",
- open_section = "<TAB>",
- open_help = "?",
- },
- colors = {
- background = "#1f2227",
- folded_section = "#56b6c2",
- },
- parts = { "header", "body", "body_2", "bookmarks" },
+ header = {
+ type = "text",
+ oldfiles_directory = false,
+ align = "left",
+ fold_section = false,
+ title = "Header",
+ margin = 5,
+ content = complete,
+ highlight = "Statement",
+ default_color = "",
+ oldfiles_amount = 0,
+ },
+ body = {
+ type = "oldfiles",
+ oldfiles_directory = false,
+ align = "left",
+ fold_section = false,
+ title = "Oldfiles",
+ margin = 5,
+ content = "",
+ highlight = "String",
+ default_color = "",
+ oldfiles_amount = 5,
+ },
+ body_2 = {
+ type = "oldfiles",
+ oldfiles_directory = true,
+ align = "left",
+ fold_section = false,
+ title = "",
+ margin = 5,
+ content = "",
+ highlight = "String",
+ oldfiles_amount = 5,
+ },
+ bookmarks = {
+ type = "text",
+ align = "left",
+ margin = 5,
+ content = bookmark_texts,
+ highlight = "String",
+ },
+ options = {
+ after = function()
+ require("startup").create_mappings(user_bookmark_mappings)
+ require("startup.utils").oldfiles_mappings()
+ end,
+ mapping_keys = false,
+ cursor_column = 0.25,
+ empty_line_between_mappings = false,
+ disable_statuslines = true,
+ paddings = { 1, 1, 1, 1 },
+ },
+ mappings = {
+ execute_command = "<CR>",
+ open_file = "o",
+ open_file_split = "<c-o>",
+ open_section = "<TAB>",
+ open_help = "?",
+ },
+ colors = {
+ background = "#1f2227",
+ folded_section = "#56b6c2",
+ },
+ parts = { "header", "body", "body_2", "bookmarks" },
}
return settings
diff --git a/lua/startup/utils.lua b/lua/startup/utils.lua
index 7bb4c68..1a233d1 100644
--- a/lua/startup/utils.lua
+++ b/lua/startup/utils.lua
@@ -12,120 +12,120 @@ local all_oldfiles = {}
local set_buf_opt = vim.api.nvim_buf_set_option
local line_count = function()
- return vim.api.nvim_buf_line_count(0)
+ return vim.api.nvim_buf_line_count(0)
end
-- local startup = require"startup"
---sets cursor to position in current window
---@param cursor table table in form {row,column}
local function set_cursor(cursor)
- vim.api.nvim_win_set_cursor(0, cursor)
+ vim.api.nvim_win_set_cursor(0, cursor)
end
function U.breaking_changes()
- local buf = vim.api.nvim_create_buf(false, true)
- local ns = vim.api.nvim_create_namespace("Startup_breaking_changes")
- vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
- vim.api.nvim_buf_set_keymap(
- buf,
- "n",
- "q",
- "<cmd>q<CR>",
- { noremap = true, silent = true, nowait = true }
- )
- local lines = {
- "",
- " # Breaking Changes in startup.nvim",
- "",
- " ## 18-12-2021:",
- " The syntax for mappings has changed. This is because",
- " before it wasn't possible to keep the mappings in the",
- " order in which they were defined.",
- "",
- " ### Old syntax:",
- " ```lua",
- " content = {",
- ' [" Find File"] = { "Telescope find_files", "<leader>ff" }',
- ' [" Find Word"] = { "Telescope live_grep", "<leader>lg" }',
- ' [" Recent Files"] = { "Telescope oldfiles", "<leader>of" }',
- ' [" File Browser"] = { "Telescope file_browser", "<leader>fb" }',
- ' [" Colorschemes"] = { "Telescope colorscheme", "<leader>cs" }',
- [[ [" New File"] = { "lua require'startup'.new_file()", "<leader>nf" }]],
- " }",
- " ```",
- "",
- " ### New syntax:",
- " ```lua",
- " content = {",
- ' {" Find File", "Telescope find_files", "<leader>ff" }',
- ' {" Find Word", "Telescope live_grep", "<leader>lg" }',
- ' {" Recent Files", "Telescope oldfiles", "<leader>of" }',
- ' {" File Browser", "Telescope file_browser", "<leader>fb" }',
- ' {" Colorschemes", "Telescope colorscheme", "<leader>cs" }',
- [[ {" New File", "lua require'startup'.new_file()", "<leader>nf" }]],
- " }",
- " ```",
- }
- vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
- local width = vim.api.nvim_win_get_width(0)
- local height = vim.api.nvim_win_get_height(0)
- local win = vim.api.nvim_open_win(buf, true, {
- relative = "win",
- win = 0,
- -- width = math.floor(width * 0.8),
- width = 85,
- height = math.floor(height * 0.9),
- col = math.floor((width - 80) * 0.4),
- row = math.floor(height * 0.1),
- border = "shadow",
- style = "minimal",
- })
- -- vim.api.nvim_buf_add_highlight(buf, ns, "Special", 1, 0, -1)
- vim.api.nvim_win_set_option(win, "winblend", 0)
- vim.api.nvim_buf_set_option(buf, "modifiable", false)
- vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
+ local buf = vim.api.nvim_create_buf(false, true)
+ local ns = vim.api.nvim_create_namespace("Startup_breaking_changes")
+ vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
+ vim.api.nvim_buf_set_keymap(
+ buf,
+ "n",
+ "q",
+ "<cmd>q<CR>",
+ { noremap = true, silent = true, nowait = true }
+ )
+ local lines = {
+ "",
+ " # Breaking Changes in startup.nvim",
+ "",
+ " ## 18-12-2021:",
+ " The syntax for mappings has changed. This is because",
+ " before it wasn't possible to keep the mappings in the",
+ " order in which they were defined.",
+ "",
+ " ### Old syntax:",
+ " ```lua",
+ " content = {",
+ ' [" Find File"] = { "Telescope find_files", "<leader>ff" }',
+ ' [" Find Word"] = { "Telescope live_grep", "<leader>lg" }',
+ ' [" Recent Files"] = { "Telescope oldfiles", "<leader>of" }',
+ ' [" File Browser"] = { "Telescope file_browser", "<leader>fb" }',
+ ' [" Colorschemes"] = { "Telescope colorscheme", "<leader>cs" }',
+ [[ [" New File"] = { "lua require'startup'.new_file()", "<leader>nf" }]],
+ " }",
+ " ```",
+ "",
+ " ### New syntax:",
+ " ```lua",
+ " content = {",
+ ' {" Find File", "Telescope find_files", "<leader>ff" }',
+ ' {" Find Word", "Telescope live_grep", "<leader>lg" }',
+ ' {" Recent Files", "Telescope oldfiles", "<leader>of" }',
+ ' {" File Browser", "Telescope file_browser", "<leader>fb" }',
+ ' {" Colorschemes", "Telescope colorscheme", "<leader>cs" }',
+ [[ {" New File", "lua require'startup'.new_file()", "<leader>nf" }]],
+ " }",
+ " ```",
+ }
+ vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
+ local width = vim.api.nvim_win_get_width(0)
+ local height = vim.api.nvim_win_get_height(0)
+ local win = vim.api.nvim_open_win(buf, true, {
+ relative = "win",
+ win = 0,
+ -- width = math.floor(width * 0.8),
+ width = 85,
+ height = math.floor(height * 0.9),
+ col = math.floor((width - 80) * 0.4),
+ row = math.floor(height * 0.1),
+ border = "shadow",
+ style = "minimal",
+ })
+ -- vim.api.nvim_buf_add_highlight(buf, ns, "Special", 1, 0, -1)
+ vim.api.nvim_win_set_option(win, "winblend", 0)
+ vim.api.nvim_buf_set_option(buf, "modifiable", false)
+ vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
end
---load the theme specified
---@param theme_name string theme to load
---@return table settings
function U.load_theme(theme_name)
- local path = "lua/startup/themes/" .. theme_name .. ".lua"
- local files = vim.api.nvim_get_runtime_file(path, true)
- local settings
- if #files == 0 then
- path = "lua/startup/themes" .. theme_name .. "/init.lua"
- files = vim.api.nvim_get_runtime_file(path, true)
- end
- if #files == 0 then
- error("lua/startup/themes/" .. theme_name .. ".lua" .. " not found")
- elseif #files == 1 then
- settings = dofile(files[1])
- else
- local startup_pattern = "startup.nvim/lua/startup"
- local valid_file = false
- for _, file in ipairs(files) do
- if not file:find(startup_pattern) then
- settings = dofile(file)
- valid_file = true
- end
- end
- if not valid_file then
- -- multiple files but in startup repo shouldn't happen so just use first one
- settings = dofile(files[1])
- end
- end
- return settings
+ local path = "lua/startup/themes/" .. theme_name .. ".lua"
+ local files = vim.api.nvim_get_runtime_file(path, true)
+ local settings
+ if #files == 0 then
+ path = "lua/startup/themes" .. theme_name .. "/init.lua"
+ files = vim.api.nvim_get_runtime_file(path, true)
+ end
+ if #files == 0 then
+ error("lua/startup/themes/" .. theme_name .. ".lua" .. " not found")
+ elseif #files == 1 then
+ settings = dofile(files[1])
+ else
+ local startup_pattern = "startup.nvim/lua/startup"
+ local valid_file = false
+ for _, file in ipairs(files) do
+ if not file:find(startup_pattern) then
+ settings = dofile(file)
+ valid_file = true
+ end
+ end
+ if not valid_file then
+ -- multiple files but in startup repo shouldn't happen so just use first one
+ settings = dofile(files[1])
+ end
+ end
+ return settings
end
---checks if cursor should be able to move on current line
local function bad_line()
- for _, line in ipairs(require("startup").good_lines) do
- if line == vim.trim(vim.api.nvim_get_current_line()) and line ~= "" then
- return false
+ for _, line in ipairs(require("startup").good_lines) do
+ if line == vim.trim(vim.api.nvim_get_current_line()) and line ~= "" then
+ return false
+ end
end
- end
- return true
+ return true
end
U.cursor_pos = vim.api.nvim_win_get_cursor(0)
@@ -134,453 +134,472 @@ U.cursor_pos = vim.api.nvim_win_get_cursor(0)
---@param amount number the amount of space to return
---@return string
function U.spaces(amount)
- return string.rep(" ", amount)
+ return string.rep(" ", amount)
end
---returns table with empty strings
---@param amount number amount of empty strings
function U.empty(amount)
- for _ = 1, amount, 1 do
- table.insert(require("startup").lines, { " ", "center", false, "normal" })
- end
+ for _ = 1, amount, 1 do
+ table.insert(
+ require("startup").lines,
+ { " ", "center", false, "normal" }
+ )
+ end
end
local function parse_mapping(mapping)
- mapping = string.gsub(mapping, "C%-", "ctrl+")
- mapping = string.gsub(mapping, "c%-", "ctrl+")
- mapping = string.gsub(mapping, "%<leader%>", "leader+")
- mapping = string.gsub(mapping, "%<(.+)%>", "%1")
- return mapping
+ mapping = string.gsub(mapping, "C%-", "ctrl+")
+ mapping = string.gsub(mapping, "c%-", "ctrl+")
+ mapping = string.gsub(mapping, "%<leader%>", "leader+")
+ mapping = string.gsub(mapping, "%<(.+)%>", "%1")
+ return mapping
end
---open float with all the keybindings
function U.key_help()
- local ns = vim.api.nvim_create_namespace("Float help")
- local settings = require("startup").settings
- local buf = vim.api.nvim_create_buf(false, true)
- local user_mappings = require("startup").user_mappings
- set_buf_opt(buf, "bufhidden", "wipe")
- local lines = {
- " Startup.nvim Mappings ",
- "",
- " Execute command: " .. parse_mapping(
- settings.mappings.execute_command
- ),
- " Open file: " .. parse_mapping(settings.mappings.open_file),
- " Open file in split: " .. parse_mapping(
- settings.mappings.open_file_split
- ),
- " Open section: " .. parse_mapping(settings.mappings.open_section),
- }
- local length
- if not vim.tbl_isempty(user_mappings) then
- local user_map_commands = {}
- table.insert(lines, "")
- table.insert(lines, " User Mappings:")
- table.insert(lines, "")
- for _, lhs in pairs(user_mappings) do
- table.insert(user_map_commands, lhs)
- end
- length = U.longest_line(user_map_commands)
- for rhs, lhs in pairs(user_mappings) do
- table.insert(
- lines,
- " "
- .. lhs
- .. ":"
- .. U.spaces(length + 3 - #lhs)
- .. parse_mapping(rhs)
- )
- end
- end
- vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
- local height = 6
- if not vim.tbl_isempty(user_mappings) then
- height = 9 + vim.tbl_count(user_mappings)
- end
- help_window = vim.api.nvim_open_win(buf, false, {
- relative = "cursor",
- width = 55,
- height = height,
- col = 0,
- row = 1,
- border = "shadow",
- style = "minimal",
- })
- if not vim.tbl_isempty(user_mappings) then
- vim.api.nvim_buf_add_highlight(buf, ns, "Special", 7, 1, -1)
- for i = 9, 9 + vim.tbl_count(user_mappings), 1 do
- vim.api.nvim_buf_add_highlight(buf, ns, "String", i, length + 5, -1)
- vim.api.nvim_buf_add_highlight(buf, ns, "Number", i, 1, length + 5)
- end
- end
- vim.api.nvim_win_set_option(help_window, "winblend", 20)
- vim.api.nvim_buf_add_highlight(buf, ns, "Special", 0, 1, -1)
- for i = 2, 5, 1 do
- vim.api.nvim_buf_add_highlight(buf, ns, "String", i, 24, -1)
- vim.api.nvim_buf_add_highlight(buf, ns, "Number", i, 1, 23)
- end
- set_buf_opt(buf, "modifiable", false)
- vim.cmd(
- [[autocmd CursorMoved * ++once lua require"startup.utils".close_help()]]
- )
+ local ns = vim.api.nvim_create_namespace("Float help")
+ local settings = require("startup").settings
+ local buf = vim.api.nvim_create_buf(false, true)
+ local user_mappings = require("startup").user_mappings
+ set_buf_opt(buf, "bufhidden", "wipe")
+ local lines = {
+ " Startup.nvim Mappings ",
+ "",
+ " Execute command: " .. parse_mapping(
+ settings.mappings.execute_command
+ ),
+ " Open file: " .. parse_mapping(settings.mappings.open_file),
+ " Open file in split: " .. parse_mapping(
+ settings.mappings.open_file_split
+ ),
+ " Open section: " .. parse_mapping(
+ settings.mappings.open_section
+ ),
+ }
+ local length
+ if not vim.tbl_isempty(user_mappings) then
+ local user_map_commands = {}
+ table.insert(lines, "")
+ table.insert(lines, " User Mappings:")
+ table.insert(lines, "")
+ for _, lhs in pairs(user_mappings) do
+ table.insert(user_map_commands, lhs)
+ end
+ length = U.longest_line(user_map_commands)
+ for rhs, lhs in pairs(user_mappings) do
+ table.insert(
+ lines,
+ " "
+ .. lhs
+ .. ":"
+ .. U.spaces(length + 3 - #lhs)
+ .. parse_mapping(rhs)
+ )
+ end
+ end
+ vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
+ local height = 6
+ if not vim.tbl_isempty(user_mappings) then
+ height = 9 + vim.tbl_count(user_mappings)
+ end
+ help_window = vim.api.nvim_open_win(buf, false, {
+ relative = "cursor",
+ width = 55,
+ height = height,
+ col = 0,
+ row = 1,
+ border = "shadow",
+ style = "minimal",
+ })
+ if not vim.tbl_isempty(user_mappings) then
+ vim.api.nvim_buf_add_highlight(buf, ns, "Special", 7, 1, -1)
+ for i = 9, 9 + vim.tbl_count(user_mappings), 1 do
+ vim.api.nvim_buf_add_highlight(buf, ns, "String", i, length + 5, -1)
+ vim.api.nvim_buf_add_highlight(buf, ns, "Number", i, 1, length + 5)
+ end
+ end
+ vim.api.nvim_win_set_option(help_window, "winblend", 20)
+ vim.api.nvim_buf_add_highlight(buf, ns, "Special", 0, 1, -1)
+ for i = 2, 5, 1 do
+ vim.api.nvim_buf_add_highlight(buf, ns, "String", i, 24, -1)
+ vim.api.nvim_buf_add_highlight(buf, ns, "Number", i, 1, 23)
+ end
+ set_buf_opt(buf, "modifiable", false)
+ vim.cmd(
+ [[autocmd CursorMoved * ++once lua require"startup.utils".close_help()]]
+ )
end
---close the help window
function U.close_help()
- vim.api.nvim_win_close(help_window, false)
- -- vim.cmd([[autocmd! CursorMoved * lua require"startup.utils".close_help() ++once]])
+ vim.api.nvim_win_close(help_window, false)
+ -- vim.cmd([[autocmd! CursorMoved * lua require"startup.utils".close_help() ++once]])
end
---the default header
---@return table header strings with the default header
function U.default_header()
- local header = {
- " /$$ ",
- " |__/ ",
- " /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$$$$$/$$$$ ",
- "| $$__ $$ /$$__ $$ /$$__ $$| $$ /$$/| $$| $$_ $$_ $$",
- "| $$ \\ $$| $$$$$$$$| $$ \\ $$ \\ $$/$$/ | $$| $$ \\ $$ \\ $$",
- "| $$ | $$| $$_____/| $$ | $$ \\ $$$/ | $$| $$ | $$ | $$",
- "| $$ | $$| $$$$$$$| $$$$$$/ \\ $/ | $$| $$ | $$ | $$",
- "|__/ |__/ \\_______/ \\______/ \\_/ |__/|__/ |__/ |__/",
- }
- return header
+ local header = {
+ " /$$ ",
+ " |__/ ",
+ " /$$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$$$$$/$$$$ ",
+ "| $$__ $$ /$$__ $$ /$$__ $$| $$ /$$/| $$| $$_ $$_ $$",
+ "| $$ \\ $$| $$$$$$$$| $$ \\ $$ \\ $$/$$/ | $$| $$ \\ $$ \\ $$",
+ "| $$ | $$| $$_____/| $$ | $$ \\ $$$/ | $$| $$ | $$ | $$",
+ "| $$ | $$| $$$$$$$| $$$$$$/ \\ $/ | $$| $$ | $$ | $$",
+ "|__/ |__/ \\_______/ \\______/ \\_/ |__/|__/ |__/ |__/",
+ }
+ return header
end
---get oldfiles
---@param amount number amount of oldfiles to return
---@return table oldfiles table with all the oldfiles in it
function U.get_oldfiles(amount)
- local home = vim.fn.expand("~")
- local oldfiles = {}
- local oldfiles_raw = vim.fn.execute("oldfiles")
- local oldfiles_amount = 0
- for file in oldfiles_raw:gmatch("[^\n]+") do
- if oldfiles_amount >= amount then
- break
- end
- table.insert(oldfiles, (string.sub(file, 4, -1)))
- table.insert(all_oldfiles, (string.sub(file, 4, -1)))
- oldfiles_amount = oldfiles_amount + 1
- end
- 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, "~")
- else
- oldfiles_shortened[#oldfiles_shortened + 1] = string.gsub(file, home, "~")
+ local home = vim.fn.expand("~")
+ local oldfiles = {}
+ local oldfiles_raw = vim.fn.execute("oldfiles")
+ local oldfiles_amount = 0
+ for file in oldfiles_raw:gmatch("[^\n]+") do
+ if oldfiles_amount >= amount then
+ break
+ end
+ table.insert(oldfiles, (string.sub(file, 4, -1)))
+ table.insert(all_oldfiles, (string.sub(file, 4, -1)))
+ oldfiles_amount = oldfiles_amount + 1
+ end
+ 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, "~")
+ else
+ oldfiles_shortened[#oldfiles_shortened + 1] = string.gsub(
+ file,
+ home,
+ "~"
+ )
+ end
+ oldfiles_total = oldfiles_total + 1
end
- oldfiles_total = oldfiles_total + 1
- end
- oldfiles = oldfiles_shortened
- table.insert(oldfiles, 1, "Last Files:")
- table.insert(oldfiles, 2, "")
+ oldfiles = oldfiles_shortened
+ table.insert(oldfiles, 1, "Last Files:")
+ table.insert(oldfiles, 2, "")
- local length = U.longest_line(oldfiles) + 2
- local oldfiles_aligned = {}
- for _, file in ipairs(oldfiles) do
- table.insert(oldfiles_aligned, file .. U.spaces(length - #file))
- end
- return oldfiles_aligned
+ local length = U.longest_line(oldfiles) + 2
+ local oldfiles_aligned = {}
+ for _, file in ipairs(oldfiles) do
+ table.insert(oldfiles_aligned, file .. U.spaces(length - #file))
+ end
+ return oldfiles_aligned
end
---get oldfiles of current directory
---@param amount number amount of oldfiles to return
---@return table oldfiles table with all the oldfiles in it
function U.get_oldfiles_directory(amount)
- local home = vim.fn.expand("~")
- local oldfiles_raw = vim.fn.execute("oldfiles")
- local oldfiles_amount = 0
- local directory = vim.api.nvim_exec([[pwd]], true)
- local oldfiles = {}
- for file in oldfiles_raw:gmatch(directory .. "[^\n]+") do
- if oldfiles_amount >= amount then
- break
- end
- table.insert(oldfiles, (string.sub(file, #directory + 1, -1)))
- table.insert(all_oldfiles, file)
- oldfiles_amount = oldfiles_amount + 1
- end
- 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, "~")
- else
- oldfiles_shortened[#oldfiles_shortened + 1] = string.gsub(file, home, "~")
- end
- oldfiles_total = oldfiles_total + 1
- end
- oldfiles = oldfiles_shortened
- table.insert(
- oldfiles,
- 1,
- "Last Files in " .. string.gsub(directory, home, "~") .. ":"
- )
- table.insert(oldfiles, 2, "")
+ local home = vim.fn.expand("~")
+ local oldfiles_raw = vim.fn.execute("oldfiles")
+ local oldfiles_amount = 0
+ local directory = vim.api.nvim_exec([[pwd]], true)
+ local oldfiles = {}
+ for file in oldfiles_raw:gmatch(directory .. "[^\n]+") do
+ if oldfiles_amount >= amount then
+ break
+ end
+ table.insert(oldfiles, (string.sub(file, #directory + 1, -1)))
+ table.insert(all_oldfiles, file)
+ oldfiles_amount = oldfiles_amount + 1
+ end
+ 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, "~")
+ else
+ oldfiles_shortened[#oldfiles_shortened + 1] = string.gsub(
+ file,
+ home,
+ "~"
+ )
+ end
+ oldfiles_total = oldfiles_total + 1
+ end
+ oldfiles = oldfiles_shortened
+ table.insert(
+ oldfiles,
+ 1,
+ "Last Files in " .. string.gsub(directory, home, "~") .. ":"
+ )
+ table.insert(oldfiles, 2, "")
- local length = U.longest_line(oldfiles) + 2
- local oldfiles_aligned = {}
- for _, file in ipairs(oldfiles) do
- table.insert(oldfiles_aligned, file .. U.spaces(length - #file))
- end
- return oldfiles_aligned
+ local length = U.longest_line(oldfiles) + 2
+ local oldfiles_aligned = {}
+ for _, file in ipairs(oldfiles) do
+ table.insert(oldfiles_aligned, file .. U.spaces(length - #file))
+ end
+ return oldfiles_aligned
end
function U.oldfiles_mappings()
- if not all_oldfiles then
- return
- end
- for i = 0, #all_oldfiles >= 10 and 9 or #all_oldfiles - 1, 1 do
- vim.api.nvim_buf_set_keymap(
- 0,
- "n",
- tostring(i),
- "<cmd>e " .. all_oldfiles[i + 1] .. "<CR>",
- { noremap = true, silent = true }
- )
- end
+ if not all_oldfiles then
+ return
+ end
+ for i = 0, #all_oldfiles >= 10 and 9 or #all_oldfiles - 1, 1 do
+ vim.api.nvim_buf_set_keymap(
+ 0,
+ "n",
+ tostring(i),
+ "<cmd>e " .. all_oldfiles[i + 1] .. "<CR>",
+ { noremap = true, silent = true }
+ )
+ end
end
---return column on which cursor should be positioned
local column = function()
- local settings = require("startup").settings
- local column_calc
- local cursor_column = settings.options.cursor_column or 0.5
- if cursor_column < 1 then
- column_calc = math.floor(
- vim.fn.winwidth(require("startup").window_id) * cursor_column
- )
- else
- column_calc = cursor_column
- end
- return column_calc
+ local settings = require("startup").settings
+ local column_calc
+ local cursor_column = settings.options.cursor_column or 0.5
+ if cursor_column < 1 then
+ column_calc = math.floor(
+ vim.fn.winwidth(require("startup").window_id) * cursor_column
+ )
+ else
+ column_calc = cursor_column
+ end
+ return column_calc
end
---reposition cursor if cursor moved up
local function move_up()
- flag = true
- local i
- if new_cursor_pos[1] < U.cursor_pos[1] then
- if new_cursor_pos[1] == 1 then
- set_cursor(new_cursor_pos)
- i = 1
- while true do
- if not bad_line() then
- flag = false
- return
+ flag = true
+ local i
+ if new_cursor_pos[1] < U.cursor_pos[1] then
+ if new_cursor_pos[1] == 1 then
+ set_cursor(new_cursor_pos)
+ i = 1
+ while true do
+ if not bad_line() then
+ flag = false
+ return
+ end
+ set_cursor({ new_cursor_pos[1] + i, column() })
+ i = i + 1
+ end
+ else
+ set_cursor(new_cursor_pos)
+ i = 0
end
- set_cursor({ new_cursor_pos[1] + i, column() })
- i = i + 1
- end
else
- set_cursor(new_cursor_pos)
- i = 0
- end
- else
- set_cursor(U.cursor_pos)
- i = 1
- end
- while true do
- set_cursor({ new_cursor_pos[1] - i, column() })
- if not bad_line() then
- flag = false
- return
- end
- i = i + 1
- if new_cursor_pos[1] - i <= 1 then
- i = 1
- set_cursor({ 1, column() })
- while true do
+ set_cursor(U.cursor_pos)
+ i = 1
+ end
+ while true do
+ set_cursor({ new_cursor_pos[1] - i, column() })
if not bad_line() then
- flag = false
- return
+ flag = false
+ return
end
- set_cursor({ new_cursor_pos[1] - 1 + i, column() })
i = i + 1
- end
+ if new_cursor_pos[1] - i <= 1 then
+ i = 1
+ set_cursor({ 1, column() })
+ while true do
+ if not bad_line() then
+ flag = false
+ return
+ end
+ set_cursor({ new_cursor_pos[1] - 1 + i, column() })
+ i = i + 1
+ end
+ end
end
- end
- flag = false
+ flag = false
end
---reposition cursor if cursor moved down
local function move_down()
- flag = true
- local i
- if new_cursor_pos[1] > U.cursor_pos[1] then
- if new_cursor_pos[1] == line_count() then
- set_cursor(new_cursor_pos)
- i = 1
- while true do
+ flag = true
+ local i
+ if new_cursor_pos[1] > U.cursor_pos[1] then
+ if new_cursor_pos[1] == line_count() then
+ set_cursor(new_cursor_pos)
+ i = 1
+ while true do
+ if not bad_line() then
+ flag = false
+ return
+ end
+ set_cursor({ new_cursor_pos[1] - i, column() })
+ i = i + 1
+ end
+ i = 0
+ else
+ set_cursor(new_cursor_pos)
+ i = 0
+ end
+ else
+ set_cursor(U.cursor_pos)
+ i = 1
+ end
+ while true do
+ set_cursor({ new_cursor_pos[1] + i, column() })
if not bad_line() then
- flag = false
- return
+ flag = false
+ return
end
- set_cursor({ new_cursor_pos[1] - i, column() })
i = i + 1
- end
- i = 0
- else
- set_cursor(new_cursor_pos)
- i = 0
- end
- else
- set_cursor(U.cursor_pos)
- i = 1
- end
- while true do
- set_cursor({ new_cursor_pos[1] + i, column() })
- if not bad_line() then
- flag = false
- return
- end
- i = i + 1
- if new_cursor_pos[1] + i >= line_count() then
- set_cursor(U.cursor_pos)
- flag = false
- return
- end
- end
- flag = false
+ if new_cursor_pos[1] + i >= line_count() then
+ set_cursor(U.cursor_pos)
+ flag = false
+ return
+ end
+ end
+ flag = false
end
---reposition cursor after it moved
function U.reposition_cursor()
- if vim.o.filetype ~= "startup" or flag then
- return
- end
- new_cursor_pos = vim.api.nvim_win_get_cursor(0)
- if new_cursor_pos[1] > U.cursor_pos[1] then
- move_down()
- elseif
- (new_cursor_pos[1] < U.cursor_pos[1])
- or new_cursor_pos[2] < U.cursor_pos[2]
- then
- move_up()
- elseif
- (new_cursor_pos[1] > U.cursor_pos[1])
- or new_cursor_pos[2] > U.cursor_pos[2]
- then
- move_down()
- end
- U.cursor_pos = vim.api.nvim_win_get_cursor(0)
+ if vim.o.filetype ~= "startup" or flag then
+ return
+ end
+ new_cursor_pos = vim.api.nvim_win_get_cursor(0)
+ if new_cursor_pos[1] > U.cursor_pos[1] then
+ move_down()
+ elseif
+ (new_cursor_pos[1] < U.cursor_pos[1])
+ or new_cursor_pos[2] < U.cursor_pos[2]
+ then
+ move_up()
+ elseif
+ (new_cursor_pos[1] > U.cursor_pos[1])
+ or new_cursor_pos[2] > U.cursor_pos[2]
+ then
+ move_down()
+ end
+ U.cursor_pos = vim.api.nvim_win_get_cursor(0)
end
---return longest line length
---@param lines table
---@return number longest
function U.longest_line(lines)
- local longest = 0
- for _, line in ipairs(lines) do
- if vim.fn.strdisplaywidth(line) > longest then
- longest = vim.fn.strdisplaywidth(line)
+ local longest = 0
+ for _, line in ipairs(lines) do
+ if vim.fn.strdisplaywidth(line) > longest then
+ longest = vim.fn.strdisplaywidth(line)
+ end
end
- end
- return longest
+ return longest
end
---set all the options that should be set for the startup buffer
function U.set_buf_options()
- local settings = require("startup").settings
- local last_status = vim.api.nvim_get_option("laststatus")
- local tab_line = vim.api.nvim_get_option("showtabline")
- set_buf_opt(0, "bufhidden", "wipe")
- set_buf_opt(0, "buftype", "nofile")
- vim.cmd([[set wrap]])
- if settings.options.disable_statuslines then
- vim.opt.laststatus = 0
- vim.opt.showtabline = 0
- end
- set_buf_opt(0, "filetype", "startup")
- set_buf_opt(0, "swapfile", false)
- vim.cmd([[setlocal nonu nornu]])
- vim.api.nvim_set_current_dir(
- vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":h")
- )
- vim.cmd(
- [[autocmd BufEnter * lua if vim.opt.filetype~="startup" then vim.opt.laststatus=]]
- .. last_status
- .. [[;vim.opt.showtabline=]]
- .. tab_line
- .. [[ end]]
- )
+ local settings = require("startup").settings
+ local last_status = vim.api.nvim_get_option("laststatus")
+ local tab_line = vim.api.nvim_get_option("showtabline")
+ set_buf_opt(0, "bufhidden", "wipe")
+ set_buf_opt(0, "buftype", "nofile")
+ vim.cmd([[set wrap]])
+ if settings.options.disable_statuslines then
+ vim.opt.laststatus = 0
+ vim.opt.showtabline = 0
+ end
+ set_buf_opt(0, "filetype", "startup")
+ set_buf_opt(0, "swapfile", false)
+ vim.cmd([[setlocal nonu nornu]])
+ vim.api.nvim_set_current_dir(
+ vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ":h")
+ )
+ vim.cmd(
+ [[autocmd BufEnter * lua if vim.opt.filetype~="startup" then vim.opt.laststatus=]]
+ .. 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
- vim.validate({
- type = {
- options.type,
- function(arg)
- for _, v in ipairs({ "mapping", "oldfiles", "text" }) do
- if v == arg then
- return true
- end
- end
- return false
- end,
- '"mapping" "text" or "oldfiles"',
- },
- align = {
- options.align,
- function(arg)
- for _, v in ipairs({ "right", "left", "center" }) do
- if v == arg then
- return true
- end
- end
- return false
- end,
- '"center" "left" or "right"',
- },
- content = {
- options.content,
- function(content)
- if
- options.type == "text"
- and (type(content) == "table" or type(content) == "function")
- then
- return true
- elseif options.type == "mapping" and type(content) == "table" then
- return true
- elseif options.type == "oldfiles" then
- return true
- end
- return false
- end,
- "table for type=mapping and table or function for type=text",
- },
- })
- return 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
+ vim.validate({
+ type = {
+ options.type,
+ function(arg)
+ for _, v in ipairs({ "mapping", "oldfiles", "text" }) do
+ if v == arg then
+ return true
+ end
+ end
+ return false
+ end,
+ '"mapping" "text" or "oldfiles"',
+ },
+ align = {
+ options.align,
+ function(arg)
+ for _, v in ipairs({ "right", "left", "center" }) do
+ if v == arg then
+ return true
+ end
+ end
+ return false
+ end,
+ '"center" "left" or "right"',
+ },
+ content = {
+ options.content,
+ function(content)
+ if
+ options.type == "text"
+ and (
+ type(content) == "table"
+ or type(content)
+ == "function"
+ )
+ then
+ return true
+ elseif
+ options.type == "mapping" and type(content) == "table"
+ then
+ return true
+ elseif options.type == "oldfiles" then
+ return true
+ end
+ return false
+ end,
+ "table for type=mapping and table or function for type=text",
+ },
+ })
+ return options
end
return U
diff --git a/scripts/gendocs.lua b/scripts/gendocs.lua
index bb0976d..496e56e 100644
--- a/scripts/gendocs.lua
+++ b/scripts/gendocs.lua
@@ -3,22 +3,22 @@ local docgen = require("docgen")
local docs = {}
docs.test = function()
- -- TODO: Fix the other files so that we can add them here.
- local input_files = {
- "./lua/startup/functions.lua",
- "./lua/startup/headers.lua",
- }
+ -- TODO: Fix the other files so that we can add them here.
+ local input_files = {
+ "./lua/startup/functions.lua",
+ "./lua/startup/headers.lua",
+ }
- local output_file = "./doc/startup.txt"
- local output_file_handle = io.open(output_file, "w")
+ local output_file = "./doc/startup.txt"
+ local output_file_handle = io.open(output_file, "w")
- for _, input_file in ipairs(input_files) do
- docgen.write(input_file, output_file_handle)
- end
+ for _, input_file in ipairs(input_files) do
+ docgen.write(input_file, output_file_handle)
+ end
- output_file_handle:write(" vim:tw=78:ts=8:ft=help:norl:\n")
- output_file_handle:close()
- vim.cmd([[checktime]])
+ output_file_handle:write(" vim:tw=78:ts=8:ft=help:norl:\n")
+ output_file_handle:close()
+ vim.cmd([[checktime]])
end
docs.test()
diff --git a/stylua.toml b/stylua.toml
index 5a4c161..ddca055 100644
--- a/stylua.toml
+++ b/stylua.toml
@@ -1,5 +1,5 @@
column_width = 80
indent_type = "Spaces"
-indent_width = 2
+indent_width = 4
quote_style = "AutoPreferDouble"
no_call_parentheses = false