This repository was archived by the owner on Feb 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
173 lines (146 loc) · 4.64 KB
/
init.lua
File metadata and controls
173 lines (146 loc) · 4.64 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
vim.g.mapleader = " "
vim.g.maplocalleader = "'"
-- require("user.profiler")
vim.g.loaded_python_provider = 0
vim.g.loaded_ruby_provider = 0
vim.g.loaded_perl_provider = 0
vim.lsp.set_log_level('warn')
_G.map = vim.keymap.set
vim.opt.fillchars:append({ eob = ' ' })
-- =========================================================
-- 1. Safe require helper
-- =========================================================
local function safe_require(module)
local ok, result = pcall(require, module)
if not ok then
vim.notify(
'Failed to load: ' .. module .. '\n' .. tostring(result),
vim.log.levels.ERROR,
{ title = 'Module Load Error' }
)
return nil
end
return result
end
-- =========================================================
-- 2. Auto-discover and load stages in numerical order
-- =========================================================
local function load_stages()
local stages_path = vim.fn.stdpath('config') .. '/lua/user/stages'
local files = vim.fn.readdir(stages_path)
-- Filter for .lua files and sort them numerically
local lua_files = {}
for _, file in ipairs(files) do
if file:match('%.lua$') then
table.insert(lua_files, file)
end
end
-- Sort numerically by extracting leading numbers
table.sort(lua_files, function(a, b)
local num_a = tonumber(a:match('^(%d+)'))
local num_b = tonumber(b:match('^(%d+)'))
if num_a and num_b then
return num_a < num_b
end
return a < b -- Fallback to alphabetical
end)
-- Load each stage in order
for _, file in ipairs(lua_files) do
local module_name = file:gsub('%.lua$', '')
local stage_module = 'user.stages.' .. module_name
safe_require(stage_module)
end
end
load_stages()
-- =========================================================
-- 3. Post-init
-- =========================================================
vim.cmd.colorscheme('tokyonight-night')
local function safe_cursor_line_fix()
local cl = vim.api.nvim_get_hl(0, { name = 'CursorLine' })
local clr = vim.api.nvim_get_hl(0, { name = 'CursorLineNr' })
-- Only proceed if we have the data we need
if not cl or not clr then
return
end
-- Build highlight table safely
local hl = {}
if clr.fg then
hl.fg = clr.fg
end
if cl.bg then
hl.bg = cl.bg
end
if clr.bold then
hl.bold = true
end
-- Only set if we have something to set
if next(hl) then
vim.api.nvim_set_hl(0, 'CursorLineNr', hl)
end
-- CursorLineSign with fallback
if cl.bg then
vim.api.nvim_set_hl(0, 'CursorLineSign', { bg = cl.bg })
end
end
-- Run safely
local ok, err = pcall(safe_cursor_line_fix)
if not ok then
vim.notify('CursorLine fix failed: ' .. tostring(err), vim.log.levels.WARN)
end
local function apply_diag_hls()
vim.api.nvim_create_autocmd('ColorScheme', {
callback = function()
vim.schedule(function()
local ok = pcall(safe_cursor_line_fix)
if not ok then
-- Silently fail, don't spam user
end
end)
end,
})
-- Base group
vim.api.nvim_set_hl(0, 'DiagnosticUnnecessary', {
link = 'DiagnosticWarn',
bold = true,
-- standout = true,
})
-- Explicitly disable underline
vim.api.nvim_set_hl(0, 'DiagnosticUnderlineUnnecessary', {
underline = true,
nocombine = true,
undercurl = false,
bold = true,
-- standout = true,
sp = 'NONE',
})
local function bold_diag_underline(name, target)
local hl = vim.api.nvim_get_hl(0, { name = target, link = false })
vim.api.nvim_set_hl(0, name, {
fg = hl.fg,
sp = hl.fg,
bold = true,
underline = true,
-- standout = true,
})
end
-- Apply ONLY to severities that should underline
bold_diag_underline('DiagnosticUnderlineError', 'DiagnosticError')
bold_diag_underline('DiagnosticUnderlineWarn', 'DiagnosticWarn')
bold_diag_underline('DiagnosticUnderlineInfo', 'DiagnosticInfo')
bold_diag_underline('DiagnosticUnderlineHint', 'DiagnosticHint')
end
vim.api.nvim_create_autocmd('ColorScheme', {
callback = apply_diag_hls,
})
-- apply once at startup
apply_diag_hls()
-- Sementics off
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client then
client.server_capabilities.semanticTokensProvider = nil
end
end,
})