-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
113 lines (106 loc) · 3.77 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
HOMEDIR = os.getenv("HOME")
vim.g.mapleader = " "
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
local function command_exists(cmd)
return vim.fn.executable(cmd) == 1
end
local boot_ascii = {
"╭─────────────────────────────────────────────────────────────────────────────────---- -- -",
}
if command_exists("neofetch") then
local function remove_ansi_codes(str)
local patterns = {
"\27%[[%d;]*m",
"\27%[%?25l",
"\27%[%?7l",
"\27%[%?25h",
"\27%[%?7h",
"\27%[19A",
"\27%[9999999D",
"\27%[41C",
"\27%[17A",
}
for _, pattern in ipairs(patterns) do
str = str:gsub(pattern, "")
end
return str
end
local output1 = vim.fn.system("neofetch -L --color_blocks off")
local output2 = vim.fn.system("neofetch --stdout --disable gpu --disable memory --gtk2 off --gtk3 off")
output1 = remove_ansi_codes(output1)
local lines1 = vim.split(output1, "\n")
local lines2 = vim.split(output2, "\n")
local handle = io.popen("ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}'")
local result = handle:read("*a")
handle:close()
local ip = result:match("%S+")
table.insert(lines2, "IP internal: " .. ip)
table.insert(lines2, "IP external: " .. vim.fn.system("curl -s ifconfig.me"))
local nvim_lua_version = vim.fn.execute("version"):match("NVIM v(%d+.%d+.%d+)")
nvim_lua_version = nvim_lua_version .. " - Lua: " .. _VERSION
table.insert(lines2, "Neovim: " .. nvim_lua_version)
local longest_line_length = 0
for _, line in ipairs(lines1) do
if #line > longest_line_length then
longest_line_length = #line
end
end
for i = 1, #lines2 do
local line1 = lines1[i] or ""
local line2 = lines2[i] or ""
local padding = longest_line_length - #line1
if padding > 0 then
line1 = line1 .. string.rep(" ", padding)
end
if #line2 > 0 then
local combined_line = line1 .. " " .. line2
table.insert(boot_ascii, "│ " .. combined_line:gsub("'", "`"))
end
end
else
table.insert(boot_ascii, "│")
local output1
if vim.fn.system("hostname"):match("c[0-9]*r[0-9]*p[0-9]*") then
output1 = vim.fn.system("cat " .. HOMEDIR .. "/.config/nvim/assets/boot_ascii_42.txt")
else
output1 = vim.fn.system("cat " .. HOMEDIR .. "/.config/nvim/assets/boot_ascii_nvim_logo.txt")
end
local lines1 = vim.split(output1, "\n")
for i = 1, #lines1 do
table.insert(boot_ascii, "│ " .. lines1[i])
end
end
table.insert(
boot_ascii,
"╰─────────────────────────────────────────────────────────────────────────────────---- -- -"
)
local boot_ascii_str = table.concat(boot_ascii, "',\n\\ '")
vim.cmd("let g:boot_ascii = ['" .. boot_ascii_str .. "']")
vim.cmd([[ let g:startify_custom_header = g:boot_ascii ]])
vim.cmd([[ let g:startify_session_autoload = 1 ]])
vim.cmd([[ let g:startify_session_persistence = 1 ]])
vim.cmd([[ let g:startify_lists = [
\ { 'type': 'sessions', 'header': [' Sessions'] },
\ { 'type': 'files', 'header': [' MRU'] },
\ { 'type': 'dir', 'header': [' MRU '. getcwd()] },
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
\ { 'type': 'commands', 'header': [' Commands'] },
\ ]
]])
require("lazy").setup("plugins")
require("base")
require("highlights")
require("maps")
require("bootstrap")
require("personalmenu")