Comprehensive guide to the modular Neovim configuration
This configuration uses a modular Lua architecture designed for maintainability, performance, and extensibility.
~/.dotfiles/src/neovim/
βββ init.lua # Entry point with path detection
βββ plugins.lua # Plugin specifications (80+ plugins)
βββ lsp.lua # Language server configurations
βββ ui.lua # UI and theme configuration
βββ autocmds.lua # Autocommands
βββ commands.lua # Custom commands
βββ keymaps.lua # Keymap loader
βββ telescope.lua # Telescope configuration
βββ utils.lua # Utility functions
βββ dap.lua # Debug Adapter Protocol
βββ gitsigns.lua # Git integration
βββ menu.lua # Menu system
βββ health.lua # Health checks
βββ logging.lua # Logging utilities
βββ error-handler.lua # Error handling
βββ fixy.lua # Formatter integration
βββ work.lua # Work-specific overrides
βββ work-init.lua # Work initialization
βββ core/ # Core settings
β βββ options.lua # Vim options
β βββ globals.lua # Global variables
β βββ performance.lua # Performance optimizations
βββ keymaps/ # Key bindings (modular)
β βββ core.lua # Essential mappings
β βββ navigation.lua # Movement mappings
β βββ editing.lua # Text manipulation
β βββ lsp.lua # Language server mappings
β βββ plugins.lua # Plugin-specific mappings
β βββ debug.lua # DAP debugging mappings
βββ plugins/ # Plugin specifications (by category)
βββ colors/ # Color scheme utilities
βββ snippets/ # Language-specific snippets
βββ spell/ # Spell files
init.lua)The main entry point that:
-- Key initialization order:
-- 1. Path detection
-- 2. Options (core settings)
-- 3. Lazy.nvim bootstrap
-- 4. Plugin loading
-- 5. Keymaps
-- 6. Autocommands
-- 7. Work overrides (if exists)
core/options.luaEssential Neovim settings:
-- Example settings
vim.opt.number = true -- Line numbers
vim.opt.relativenumber = true -- Relative line numbers
vim.opt.expandtab = true -- Spaces instead of tabs
vim.opt.shiftwidth = 2 -- Indent width
vim.opt.tabstop = 2 -- Tab width
vim.opt.smartindent = true -- Smart indentation
vim.opt.termguicolors = true -- True color support
vim.opt.undofile = true -- Persistent undo
vim.opt.updatetime = 250 -- Faster updates
vim.opt.timeoutlen = 300 -- Key sequence timeout
core/globals.luaGlobal variables and leader keys:
vim.g.mapleader = " " -- Space as leader
vim.g.maplocalleader = " " -- Local leader
core/performance.luaPerformance optimizations:
-- Disable built-in plugins not needed
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
-- Large file handling
vim.g.large_file_threshold = 512 * 1024 -- 512KB
Organized by functionality (see Keybindings Reference):
| File | Purpose |
|---|---|
core.lua |
Essential mappings (save, quit, clipboard) |
navigation.lua |
Window, buffer, and code navigation |
editing.lua |
Text manipulation and indentation |
lsp.lua |
Go to definition, references, etc. |
plugins.lua |
Telescope, file explorer, git |
debug.lua |
DAP breakpoints and stepping |
lsp.luaLanguage server configurations:
-- Servers are configured with Mason
local servers = {
lua_ls = {
settings = {
Lua = {
diagnostics = { globals = { "vim" } },
},
},
},
pyright = {},
ts_ls = {},
rust_analyzer = {},
-- ... 20+ more languages
}
| Language | Server | Formatter |
|---|---|---|
| Lua | lua_ls | stylua |
| Python | pyright | ruff |
| TypeScript | ts_ls | prettier |
| Rust | rust_analyzer | rustfmt |
| Go | gopls | gofmt |
| C/C++ | clangd | clang-format |
Uses lazy.nvim for plugin management:
plugins.lua and plugins/Main plugin specifications (80+ plugins):
return {
-- Essential
{ "folke/lazy.nvim" },
-- UI
{ "folke/tokyonight.nvim", priority = 1000 },
{ "nvim-lualine/lualine.nvim" },
-- Editor
{ "nvim-telescope/telescope.nvim" },
{ "folke/snacks.nvim" },
-- Coding
{ "saghen/blink.cmp" },
{ "nvim-treesitter/nvim-treesitter" },
-- AI
{ "olimorris/codecompanion.nvim" },
}
| Category | Key Plugins |
|---|---|
| Completion | blink.cmp, LuaSnip |
| Fuzzy Finding | Telescope, fzf-lua |
| File Management | oil.nvim, snacks.explorer |
| Git | gitsigns, lazygit |
| AI | CodeCompanion, Avante |
| LSP | nvim-lspconfig, Mason |
| Treesitter | nvim-treesitter |
| UI | tokyonight, lualine |
| Debugging | nvim-dap, nvim-dap-ui |
autocmds.lua)Automated behaviors:
-- Highlight on yank
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
vim.highlight.on_yank()
end,
})
-- Auto-format on save
vim.api.nvim_create_autocmd("BufWritePre", {
callback = function()
vim.lsp.buf.format({ async = false })
end,
})
-- Skeleton templates for new files
vim.api.nvim_create_autocmd("BufNewFile", {
pattern = "*.py",
callback = function()
-- Insert Python template
end,
})
commands.lua)Productivity commands:
| Command | Description |
|---|---|
:Format |
Format current buffer |
:LspRestart |
Restart LSP servers |
:Telescope |
Open fuzzy finder |
:Mason |
Manage LSP servers |
plugins.lua or a file in plugins/:{
"author/plugin-name",
event = "VeryLazy", -- Lazy load
config = function()
require("plugin-name").setup({
-- options
})
end,
}
:Lazy sync to installkeymaps/vim.keymap.set("n", "<leader>xx", function()
-- action
end, { desc = "Description for which-key" })
lsp.lua:servers.new_server = {
settings = {
-- server-specific settings
},
}
:MasonInstall new_serversnippets/:-- snippets/python.lua
return {
s("def", {
t("def "), i(1, "name"), t("("), i(2), t("):"),
t({ "", " " }), i(0),
}),
}
-- Bad: Loads immediately
{ "heavy-plugin" }
-- Good: Loads on command
{ "heavy-plugin", cmd = "HeavyCommand" }
-- Good: Loads on filetype
{ "python-plugin", ft = "python" }
-- Good: Loads on keymap
{ "plugin", keys = { { "<leader>x", "<cmd>PluginCmd<cr>" } } }
All configurations use pcall for graceful degradation:
local ok, module = pcall(require, "module")
if not ok then
vim.notify("Failed to load module", vim.log.levels.WARN)
return
end
:checkhealth
nvim --startuptime /tmp/startup.log
:Lazy profile
:LspInfo
:Mason
nvim -V9 /tmp/nvim.log
| Metric | Target |
|---|---|
| Startup time | < 150ms |
| Plugin loading | < 500ms |
| LSP attach | < 1s |
| Memory usage | < 200MB |
The configuration supports work-specific overrides via .dotfiles.private/:
-- Loaded if present
~/.dotfiles/.dotfiles.private/companies/*/neovim/
This allows company-specific LSP configs, keymaps, and plugins without affecting the main configuration.