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:
dlond 2025-09-02 13:21:18 +12:00 committed by Daniel Lond
parent 277be1e79b
commit f81cab2da3
55 changed files with 2039 additions and 2299 deletions

View file

@ -0,0 +1,26 @@
-- LSP Configuration Module
local M = {}
function M.setup()
local lspconfig = require 'lspconfig'
-- Get capabilities from blink.cmp if available
local capabilities = {}
pcall(function()
capabilities = require('blink.cmp').get_lsp_capabilities()
end)
-- Load server configurations
local servers = require('plugins.config.lsp.servers').get_servers()
-- Setup each server with capabilities
for name, config in pairs(servers) do
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
lspconfig[name].setup(config)
end
-- Setup LSP keymaps
require('plugins.config.lsp.keymaps').setup()
end
return M

View file

@ -0,0 +1,57 @@
-- LSP Keymaps Configuration
local M = {}
function M.setup()
-- Setup keymaps when LSP attaches to a buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('lsp-attach-keymaps', { clear = true }),
callback = function(event)
-- Helper function to define keymaps
local map = function(keys, func, desc, mode)
mode = mode or 'n'
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
end
-- Navigation keymaps (using kickstart.nvim patterns)
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype definition')
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
-- Symbol operations
map('grn', vim.lsp.buf.rename, '[G]oto [R]e[n]ame')
map('gra', vim.lsp.buf.code_action, '[G]oto code [A]ction', { 'n', 'x' })
map('gO', require('telescope.builtin').lsp_document_symbols, '[G]oto [O]pen document symbols')
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[G]oto [W]orkspace symbols')
-- Documentation
map('K', vim.lsp.buf.hover, 'Hover Documentation')
-- Formatting
map('<leader>f', function()
vim.lsp.buf.format { async = true }
end, '[F]ormat buffer')
-- The following keymaps are available but not mapped by default:
-- vim.lsp.buf.signature_help - Show function signature help
-- vim.lsp.buf.add_workspace_folder - Add workspace folder
-- vim.lsp.buf.remove_workspace_folder - Remove workspace folder
-- vim.lsp.buf.list_workspace_folders - List workspace folders
-- Optional: Add a message when LSP attaches
local client = vim.lsp.get_client_by_id(event.data.client_id)
if client then
vim.notify('LSP attached: ' .. client.name, vim.log.levels.INFO)
end
end,
})
-- Diagnostic keymaps (available globally, not just when LSP attaches)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
end
return M

View file

@ -0,0 +1,88 @@
-- LSP Server Configurations
local M = {}
local util = require 'lspconfig.util'
-- Query driver for clangd to find compilers in various locations
local function get_clangd_query_driver()
return table.concat({
'/nix/store/*/bin/clang*',
'/opt/homebrew/opt/llvm/bin/clang*',
'/usr/bin/clang*',
}, ';')
end
-- Get clang resource directory
local function get_clang_resource_dir()
local ok, result = pcall(vim.fn.systemlist, { 'clang++', '--print-resource-dir' })
if ok and result and result[1] then
return result[1]
else
return '/usr/lib/clang/19/include' -- fallback
end
end
function M.get_servers()
return {
-- C/C++ Language Server
clangd = {
cmd = {
'clangd',
'--background-index',
'--clang-tidy',
'--header-insertion=never',
'--query-driver=' .. get_clangd_query_driver(),
'--compile-commands-dir=build',
'--resource-dir=' .. get_clang_resource_dir(),
},
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
root_dir = util.root_pattern('CMakeLists.txt', '.git'),
single_file_support = true,
},
-- Python Language Server
pyright = {
settings = {
python = {
analysis = {
autoSearchPaths = true,
diagnosticMode = 'openFilesOnly',
useLibraryCodeForTypes = true,
typeCheckingMode = 'basic',
},
},
},
positionEncoding = 'utf-8',
},
-- Python Linter/Formatter
ruff = {},
-- Nix Language Server
nixd = {},
-- LaTeX Language Server
texlab = {},
-- CMake Language Server
cmake = {
cmd = { 'cmake-language-server' },
filetypes = { 'cmake' },
root_dir = util.root_pattern('CMakeLists.txt', '.git'),
},
-- Add more servers here as needed
-- Example:
-- rust_analyzer = {
-- settings = {
-- ['rust-analyzer'] = {
-- checkOnSave = {
-- command = 'clippy',
-- },
-- },
-- },
-- },
}
end
return M