-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_append.lua
More file actions
286 lines (258 loc) · 10.7 KB
/
Copy pathinit_append.lua
File metadata and controls
286 lines (258 loc) · 10.7 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
-- [[ LazyLite Configuration ]]
-- Do not reorder these blocks. Dependencies matter.
local core = require "core"
local config = require "core.config"
local style = require "core.style"
local keymap = require "core.keymap"
local common = require "core.common"
-- ── 0. Global Process Spawn Protection ───────────────────────────────────────
local process = require "process"
local orig_process_start = process.start
function process.start(...)
local ok, a, b, c = pcall(orig_process_start, ...)
if ok then return a, b, c else return nil, a end
end
-- ── 1. Color scheme ───────────────────────────────────────────────────────────
core.reload_module("colors.everforest_lite_xl")
-- ── 2. Font — Auto-Native OS Fonts & Fallbacks ────────────────────────────────
local function try_load_font(path, size, opts)
local ok, f = pcall(renderer.font.load, path, size, opts or {})
return ok and f or nil
end
local os_fonts = {
USERDIR .. "/fonts/FiraCode-iScript.ttf",
USERDIR .. "/fonts/FiraCodeNerdFont-Regular.ttf",
}
if PLATFORM == "Windows" then
local windir = os.getenv("WINDIR") or "C:\\Windows"
table.insert(os_fonts, windir .. "\\Fonts\\consola.ttf")
table.insert(os_fonts, windir .. "\\Fonts\\lucon.ttf")
elseif PLATFORM == "Mac OS X" then
table.insert(os_fonts, "/System/Library/Fonts/Menlo.ttc")
table.insert(os_fonts, "/System/Library/Fonts/Monaco.ttf")
else
table.insert(os_fonts, "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf")
table.insert(os_fonts, "/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf")
table.insert(os_fonts, "/usr/share/fonts/dejavu/DejaVuSansMono.ttf")
end
local base_font = nil
local font_path_used = nil
for _, path in ipairs(os_fonts) do
base_font = try_load_font(path, 15 * SCALE)
if base_font then
font_path_used = path
break
end
end
if base_font then
style.font = base_font
style.big_font = try_load_font(font_path_used, 20 * SCALE) or base_font
style.code_font = base_font
local NERD_PATH = USERDIR .. "/fonts/FiraCodeNerdFont-Regular.ttf"
style.icon_font = try_load_font(NERD_PATH, 14 * SCALE) or base_font
style.icon_big_font = try_load_font(NERD_PATH, 28 * SCALE) or base_font
end
-- ── 3. Editor behaviour ───────────────────────────────────────────────────────
config.tab_type = "soft"
config.indent_size = 4
config.line_limit = 120
config.highlight_current_line = true
config.mouse_wheel_scroll = 50 * SCALE
config.blink_period = 0.5
config.draw_whitespace = false
config.max_undos = 10000
config.file_size_limit = 10
config.max_project_files = 50000
config.ignore_files = {
"^%.git$", "^node_modules$", "^__pycache__$", "^%.DS_Store$",
"^venv$", "^%.venv$", "^build$", "^dist$", "^%.next$", "^vendor$",
"^%.gemini$", "^AppData$", "^%.config$", "^%.cache$", "^%.vscode$",
"^%.npm$", "^%.rustup$", "^%.cargo$", "^%.antigravity$", "^tempfiles$",
"^NTUSER%.DAT", "^ntuser%.dat", "%.tmp$", "%.log$", "%.cache$"
}
-- ── 4. Built-in plugins ───────────────────────────────────────────────────────
config.plugins.treeview = true
config.plugins.autocomplete = true
config.plugins.bracketmatch = true
config.plugins.autosave = false
config.plugins.minimap = true
config.plugins.drawwhitespace = false
config.plugins.lineguide = false
config.plugins.wordcount = false
-- ── 5. Hybrid Theme Universal Patches ──────────────────────────────────────────
local Node = require "core.node"
local old_node_draw_tabs = Node.draw_tabs
function Node:draw_tabs(...)
local old_text = style.text
local old_dim = style.dim
local old_bg2 = style.background2
if style.mossy then
style.background2 = style.tab_bar_background or style.mossy.activity_bg or style.background2
style.text = style.syntax.normal or style.text
style.dim = style.mossy.sidebar_text or style.dim
end
old_node_draw_tabs(self, ...)
style.text = old_text
style.dim = old_dim
style.background2 = old_bg2
end
local TreeView_ok, TreeView = pcall(require, "plugins.treeview")
if TreeView_ok then
local old_tv_draw = TreeView.draw
function TreeView:draw(...)
local old_bg2 = style.background2
local old_bg3 = style.background3
local old_text = style.text
local old_dim = style.dim
if style.mossy then
style.background2 = style.mossy.sidebar_bg or style.background2
style.background3 = style.mossy.activity_bg or style.background3
style.text = style.mossy.sidebar_text or style.text
style.dim = style.mossy.sidebar_muted or style.dim
end
old_tv_draw(self, ...)
style.background2 = old_bg2
style.background3 = old_bg3
style.text = old_text
style.dim = old_dim
end
end
-- ── 6. Custom plugins ─────────────────────────────────────────────────────────
local function safe_require(mod)
local ok, err = pcall(require, mod)
if not ok then
core.warn("Failed to load %s: %s", mod, tostring(err))
local f = io.open(USERDIR .. "/error_log.txt", "a")
if f then
f:write("Failed to load " .. mod .. ": " .. tostring(err) .. "\n")
f:close()
end
end
end
safe_require "plugins.mossy_icons"
safe_require "plugins.mossy_treeview"
safe_require "plugins.toggle_terminal"
safe_require "plugins.git_timeline"
safe_require "plugins.github_actions"
safe_require "plugins.antigravity_sidebar"
safe_require "plugins.auto_healer"
safe_require "plugins.mossy_statusbar"
safe_require "plugins.loader_games"
safe_require "plugins.virtual_codespace_fs"
safe_require "plugins.github_codespaces"
safe_require "plugins.font_picker"
safe_require "plugins.resource_monitor"
-- ── 7. Keybindings ────────────────────────────────────────────────────────────
keymap.add {
["ctrl+`"] = "terminal:toggle",
["ctrl+shift+a"] = "antigravity:toggle",
["ctrl+b"] = "treeview:toggle",
["ctrl+p"] = "core:open-file",
["ctrl+shift+p"] = "core:find-command",
["ctrl+shift+e"] = "treeview:focus",
["ctrl+/"] = "doc:toggle-line-comments",
["ctrl+d"] = "find-replace:select-next",
["ctrl+z"] = "doc:undo",
["ctrl+y"] = "doc:redo",
["ctrl+s"] = "doc:save",
["ctrl+w"] = "root:close-active",
["ctrl+shift+k"] = "doc:delete-lines",
["alt+up"] = "doc:move-lines-up",
["alt+down"] = "doc:move-lines-down",
["ctrl+shift+r"] = "core:restart",
["ctrl+shift+g"] = "git-timeline:toggle",
["alt+p"] = "pdf:open-file",
["ctrl+alt+p"] = "pdf:open-file",
["shift+alt+f"] = "lsp:format-document",
["alt+shift+f"] = "lsp:format-document",
["ctrl+alt+l"] = "lsp:toggle-servers",
["alt+l"] = "lsp:toggle-servers",
}
config.borderless = true
-- ── 8. Open CWD when launched without arguments from a project folder ─────────
local function is_generic_dir(path)
local p = path:lower():gsub("\\", "/")
local userprofile = (os.getenv("USERPROFILE") or ""):lower():gsub("\\", "/")
local exedir = EXEDIR:lower():gsub("\\", "/")
if p == userprofile then return true end
if p == userprofile .. "/desktop" then return true end
if p == userprofile .. "/documents" then return true end
if p == userprofile .. "/downloads" then return true end
if p == userprofile .. "/onedrive" then return true end
if p == userprofile .. "/onedrive/desktop" then return true end
if p == userprofile .. "/onedrive/documents" then return true end
if p == exedir then return true end
if p == "c:/windows/system32" then return true end
if p == "c:/windows" then return true end
return false
end
local STARTUP_CWD = system.absolute_path(".")
local original_add_project_directory = core.add_project_directory
function core.add_project_directory(path)
if #ARGS <= 1 and not core._cwd_handled then
core._cwd_handled = true
if STARTUP_CWD and STARTUP_CWD ~= path and not is_generic_dir(STARTUP_CWD) then
path = STARTUP_CWD
core.set_project_dir(STARTUP_CWD)
local recents = core.recent_projects
local dirname = common.normalize_volume(STARTUP_CWD)
if recents and dirname then
for i, v in ipairs(recents) do
if v == dirname then
table.remove(recents, i)
break
end
end
table.insert(recents, 1, dirname)
end
end
end
return original_add_project_directory(path)
end
-- ── 9. Statusview & Theme Cleanup ─────────────────────────────────────────────
local old_reload = core.reload_module
function core.reload_module(name)
if type(name) == "string" and name:match("^colors%.") then
style.mossy = nil
end
return old_reload(name)
end
-- ── 10. Auto-Close Editor Splits on Startup ───────────────────────────────────
core.add_thread(function()
coroutine.yield()
local max_iters = 20
for iter = 1, max_iters do
local editor_nodes = {}
local function collect(node)
if node.type == "leaf" then
if not node.locked then table.insert(editor_nodes, node) end
elseif node.type ~= "leaf" then
collect(node.a)
collect(node.b)
end
end
collect(core.root_view.root_node)
if #editor_nodes <= 1 then break end
local source = editor_nodes[2]
local view = source.views[1]
if view then
source:remove_view(core.root_view.root_node, view)
local surviving_nodes = {}
local function collect_survivors(node)
if node.type == "leaf" then
if not node.locked then table.insert(surviving_nodes, node) end
elseif node.type ~= "leaf" then
collect_survivors(node.a)
collect_survivors(node.b)
end
end
collect_survivors(core.root_view.root_node)
if #surviving_nodes > 0 then
surviving_nodes[1]:add_view(view)
end
else
break
end
end
end)
-- [[ End LazyLite Configuration ]]