refactor: Complete modular migration from kickstart.nvim
Major architectural overhaul to transform the flat kickstart.nvim structure
into a maintainable, modular configuration while preserving upstream sync capability.
## Structure Changes
- Migrated from flat `lua/custom/` to organized `lua/core/` and `lua/plugins/`
- Separated plugin specs from configs: `lua/plugins/spec/` and `lua/plugins/config/`
- Complex configs (LSP, Debug) now use directory structure with sub-modules:
- `lsp/init.lua`, `lsp/servers.lua`, `lsp/keymaps.lua`
- `debug/init.lua`, `debug/adapters.lua`, `debug/keymaps.lua`
## Core Improvements
- Created dedicated core modules: options, keymaps, autocmds, bootstrap, health
- Added comprehensive health check (`lua/core/health.lua`) for diagnostics
- Simplified init.lua to just orchestrate module loading
- Better separation of concerns throughout
## Plugin Updates
- Fixed Blink.cmp configuration (removed invalid fuzzy options)
- Integrated Copilot with Blink.cmp for unified completion experience
- Added autopairs and indent-line from kickstart examples
- Optimized for Nix development environments (removed venv assumptions)
## Documentation
- Updated README with modular structure and kickstart sync instructions
- Created comprehensive KEYBIND_ANALYSIS.md with all mappings
- Added modular.txt help documentation
- Created TODO_TEST.md checklist for testing
## Benefits
- Easier to maintain and extend
- Clean separation allows upstream kickstart merges without conflicts
- Scalable architecture for adding new languages/tools
- Better code organization and discoverability
All kickstart functionality preserved while gaining modularity and maintainability.
This commit is contained in:
parent
277be1e79b
commit
f81cab2da3
55 changed files with 2039 additions and 2299 deletions
0
lua/core/autocmds.lua
Normal file
0
lua/core/autocmds.lua
Normal file
13
lua/core/bootstrap.lua
Normal file
13
lua/core/bootstrap.lua
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
-- Lazy.nvim installation
|
||||
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',
|
||||
lazypath,
|
||||
}
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
98
lua/core/health.lua
Normal file
98
lua/core/health.lua
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
-- Health check for the modular Neovim configuration
|
||||
|
||||
local M = {}
|
||||
|
||||
local check_version = function()
|
||||
local verstr = tostring(vim.version())
|
||||
if not vim.version.ge then
|
||||
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
|
||||
return
|
||||
end
|
||||
|
||||
if vim.version.ge(vim.version(), '0.10-dev') then
|
||||
vim.health.ok(string.format("Neovim version is: '%s'", verstr))
|
||||
else
|
||||
vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr))
|
||||
end
|
||||
end
|
||||
|
||||
local check_external_reqs = function()
|
||||
-- Basic utils
|
||||
for _, exe in ipairs { 'git', 'make', 'unzip' } do
|
||||
local is_executable = vim.fn.executable(exe) == 1
|
||||
if is_executable then
|
||||
vim.health.ok(string.format("Found executable: '%s'", exe))
|
||||
else
|
||||
vim.health.warn(string.format("Could not find executable: '%s'", exe))
|
||||
end
|
||||
end
|
||||
|
||||
-- Search tools
|
||||
for _, exe in ipairs { 'rg', 'fd' } do
|
||||
local is_executable = vim.fn.executable(exe) == 1
|
||||
if is_executable then
|
||||
vim.health.ok(string.format("Found search tool: '%s'", exe))
|
||||
else
|
||||
vim.health.warn(string.format("Could not find search tool: '%s' (required for Telescope)", exe))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local check_lsp_servers = function()
|
||||
-- Check for LSP servers installed via Nix
|
||||
local servers = {
|
||||
{ name = 'clangd', desc = 'C/C++ language server' },
|
||||
{ name = 'pyright', desc = 'Python language server' },
|
||||
{ name = 'ruff', desc = 'Python linter/formatter' },
|
||||
{ name = 'nixd', desc = 'Nix language server' },
|
||||
{ name = 'texlab', desc = 'LaTeX language server' },
|
||||
{ name = 'cmake-language-server', desc = 'CMake language server' },
|
||||
}
|
||||
|
||||
vim.health.start('LSP Servers (via Nix/Home Manager)')
|
||||
for _, server in ipairs(servers) do
|
||||
local is_executable = vim.fn.executable(server.name) == 1
|
||||
if is_executable then
|
||||
vim.health.ok(string.format("Found %s: '%s'", server.desc, server.name))
|
||||
else
|
||||
vim.health.info(string.format("Not found: '%s' (%s) - install via Nix if needed", server.name, server.desc))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local check_formatters = function()
|
||||
-- Check for formatters installed via Nix
|
||||
local formatters = {
|
||||
{ name = 'stylua', filetype = 'lua' },
|
||||
{ name = 'clang-format', filetype = 'c/cpp' },
|
||||
{ name = 'alejandra', filetype = 'nix' },
|
||||
}
|
||||
|
||||
vim.health.start('Formatters (via Nix/Home Manager)')
|
||||
for _, formatter in ipairs(formatters) do
|
||||
local is_executable = vim.fn.executable(formatter.name) == 1
|
||||
if is_executable then
|
||||
vim.health.ok(string.format("Found formatter for %s: '%s'", formatter.filetype, formatter.name))
|
||||
else
|
||||
vim.health.info(string.format("Not found: '%s' (%s) - install via Nix if needed", formatter.name, formatter.filetype))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.check()
|
||||
vim.health.start('Modular Neovim Configuration')
|
||||
|
||||
vim.health.info [[NOTE: Not every warning needs to be fixed.
|
||||
Only install tools for languages you actually use.
|
||||
All language servers and formatters should be installed via Nix/Home Manager.]]
|
||||
|
||||
local uv = vim.uv or vim.loop
|
||||
vim.health.info('System Information: ' .. vim.inspect(uv.os_uname()))
|
||||
|
||||
check_version()
|
||||
check_external_reqs()
|
||||
check_lsp_servers()
|
||||
check_formatters()
|
||||
end
|
||||
|
||||
return M
|
||||
26
lua/core/keymaps.lua
Normal file
26
lua/core/keymaps.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- [[ Basic Keymaps ]]
|
||||
-- See `:help vim.keymap.set()`
|
||||
|
||||
-- LSP reload function
|
||||
local function reload_lsp()
|
||||
local clients = vim.lsp.get_clients()
|
||||
if #clients == 0 then
|
||||
print('No LSP clients running')
|
||||
return
|
||||
end
|
||||
|
||||
for _, client in ipairs(clients) do
|
||||
vim.lsp.stop_client(client.id)
|
||||
end
|
||||
|
||||
vim.defer_fn(function()
|
||||
vim.cmd('LspStart')
|
||||
print('LSP servers reloaded')
|
||||
end, 500)
|
||||
end
|
||||
|
||||
-- Reload LSP keybind
|
||||
vim.keymap.set('n', '<leader>lr', reload_lsp, { desc = '[L]SP [R]eload all servers' })
|
||||
|
||||
-- Standard practice for Lua modules that don't need to return complex data
|
||||
return {}
|
||||
69
lua/core/options.lua
Normal file
69
lua/core/options.lua
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
-- Place custom vim options here
|
||||
|
||||
-- Set based on your font installation
|
||||
vim.g.have_nerd_font = true
|
||||
|
||||
-- Indentation settings
|
||||
vim.o.smartindent = true
|
||||
vim.o.autoindent = true
|
||||
vim.o.expandtab = true
|
||||
vim.o.tabstop = 2
|
||||
vim.o.shiftwidth = 2
|
||||
vim.o.softtabstop = 2
|
||||
|
||||
-- Add any other custom vim.o or vim.g settings from your old config here
|
||||
-- For example, if you changed defaults for:
|
||||
-- vim.opt.number = true -- (Already default in kickstart)
|
||||
-- vim.opt.mouse = 'a' -- (Already default in kickstart)
|
||||
-- etc... Review the options section of your old init.lua and add any *changed* values here.
|
||||
-- The kickstart defaults are generally sensible, so you might not need many overrides.
|
||||
|
||||
-- Function to check if running in a shared tmux session
|
||||
local function is_shared_tmux_session()
|
||||
if not vim.env.TMUX then
|
||||
return false
|
||||
end
|
||||
|
||||
local handle = io.popen('tmux list-sessions -F "#{session_name}:#{session_attached}" 2>/dev/null')
|
||||
if not handle then
|
||||
return false
|
||||
end
|
||||
|
||||
local current_session = vim.fn.system('tmux display-message -p "#S"'):gsub('\n', '')
|
||||
local output = handle:read('*a')
|
||||
handle:close()
|
||||
|
||||
-- Check if session name contains "shared" (case insensitive)
|
||||
if current_session:lower():find('shared') then
|
||||
return true
|
||||
end
|
||||
|
||||
-- Also check if multiple users are attached
|
||||
for line in output:gmatch('[^\r\n]+') do
|
||||
local session_name, attached_count = line:match('([^:]+):(%d+)')
|
||||
if session_name == current_session and tonumber(attached_count) > 1 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
-- Warn before quitting if in a shared tmux session
|
||||
vim.api.nvim_create_autocmd('VimLeavePre', {
|
||||
callback = function()
|
||||
if is_shared_tmux_session() then
|
||||
local choice = vim.fn.confirm(
|
||||
'You are in a shared tmux session. Other users may be affected.\nDo you really want to quit?',
|
||||
'&Yes\n&No',
|
||||
2 -- Default to No
|
||||
)
|
||||
-- vim.fn.confirm returns 1 for Yes, 2 for No, 0 for Esc
|
||||
-- The & makes Y/y and N/n work as shortcuts (case-insensitive)
|
||||
if choice ~= 1 then
|
||||
return -- Prevent quit unless explicitly choosing Yes
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue