"A sophisticated Neovim configuration that combines the logical precision of Vulcan engineering with the wisdom of Istari craftsmanship."
MARVIM is a high-performance Neovim configuration built on lazy.nvim with a modular, complexity-aware architecture. It emphasizes performance, maintainability, and developer experience through thoughtful abstraction layers and defensive programming patterns.
lua/
├── config/ # Core configuration layer
│ ├── autocmds.lua # Event-driven automation
│ ├── lazy.lua # Plugin manager setup
│ ├── options.lua # Editor settings
│ ├── keymaps/ # Centralized keymap system
│ │ ├── keymaps.lua # Main coordinator & exports
│ │ ├── core.lua # Editor/window/buffer keymaps
│ │ ├── lsp.lua # LSP & Git callback setups
│ │ ├── plugins.lua # Plugin key table definitions
│ │ ├── search.lua # Search-related operations
│ │ └── root.lua # Root directory operations
│ └── plugins/ # Plugin specifications
│ ├── [category].lua # Category aggregators
│ └── [category]/ # Complex configurations
├── utils/ # Utility libraries
│ ├── keymaps.lua # Keymap management & safety
│ ├── lsp.lua # LSP utilities & formatting
│ ├── root.lua # Project root detection
│ └── theme.lua # Color system & utilities
└── init.lua # Entry point & bootstrap
Plugin configurations are organized by complexity:
- LOW Complexity: Simple
optstables → Consolidated in category files - MEDIUM Complexity: Moderate configuration → Judgment call based on importance
- HIGH Complexity: Extensive setup, critical functionality → Dedicated files
Example Structure:
lua/config/plugins/
├── lsp.lua # Imports and simple LSP plugins
├── lsp/
│ ├── config.lua # Complex LSP server setup
│ ├── mason.lua # Tool management
│ └── completion.lua # Advanced completion config
├── editor.lua # Consolidates simple editor plugins
└── editor/
├── mini.lua # Complex mini.nvim configurations
└── oil.lua # File explorer configuration
Bootstrap Process:
-- init.lua flow
1. Bootstrap lazy.nvim (auto-install if missing)
2. Load core configurations
3. Setup lazy with category imports
4. Lazy loading with performance optimizationsCategory Import System:
-- lazy.lua setup
{
{ import = "config.plugins.core" },
{ import = "config.plugins.editor" },
{ import = "config.plugins.coding" },
{ import = "config.plugins.lsp" },
{ import = "config.plugins.git" },
{ import = "config.plugins.ui" },
{ import = "config.plugins.testing" },
{ import = "config.plugins.extras" },
}Performance Optimizations:
- Disabled built-in plugins:
netrw,gzip,zipPlugin, etc. - Module caching enabled
- Lazy-by-default loading strategy
- Strategic eager loading for critical plugins
- plenary.nvim: Lua utilities foundation
- which-key.nvim: Keymap discovery and documentation
- persistence.nvim: Session management
- dressing.nvim: UI enhancement for vim.ui
- oil.nvim: Buffer-based file explorer
- mini.nvim: Comprehensive editor enhancements
- mini.ai: Advanced text objects
- mini.surround: Surround operations
- mini.pairs: Auto-pairing
- mini.comment: Comment operations
- flash.nvim: Enhanced navigation and search
- toggleterm.nvim: Terminal management
- nvim-lspconfig: LSP client configurations
- mason.nvim: Tool installation manager
- blink.cmp: High-performance completion engine
- conform.nvim: Formatting with fallback chains
- lazygit.nvim: Git GUI integration
- gitsigns.nvim: Git status in gutter
- diffview.nvim: Advanced diff views
- neotest: Test runner with adapters for:
- Jest/Vitest (JS/TS)
- pytest (Python)
- go test (Go)
- PHPUnit (PHP)
MARVIM implements a fully centralized keymap system - the single source of truth for ALL keybindings.
Core Principle: Zero vim.keymap.set calls exist in plugin files.
-- Exports plugin key tables
M.neotest_keys = { ... }
M.oil_keys = { ... }
M.trouble_keys = { ... }
-- Provides setup functions
M.setup_deferred()
M.setup_lsp_keybindings(client, buffer)core.lua: Editor, window, buffer, tab, terminal operationslsp.lua: LSP and Git callback setup functionsplugins.lua: Plugin-specific key table definitionssearch.lua: Search and navigation keymapsroot.lua: Project root operations
-- Conflict detection and error handling
safe_keymap_set(mode, lhs, rhs, opts)
register_keymap_conflict(key, plugin1, plugin2)
get_keymap_diagnostics()-- In keymaps.lua
M.plugin_keys = {
{ "<leader>xx", function() require("plugin").action() end, desc = "Action" },
}
-- In plugin config
{
"plugin-name",
keys = function() return require("config.keymaps").plugin_keys end,
opts = { ... },
}- Conflict Detection: Tracks and warns about keymap collisions
- Error Handling: Graceful handling of failed registrations
- Diagnostic Command:
:KeymapDiagnosticsshows conflicts - Deferred Setup: Avoids timing issues with plugin loading
-- Core LSP utilities
M.get_clients(opts) -- Enhanced client retrieval
M.on_attach(client, buffer) -- Standard attachment callback
M.format(opts) -- Formatting with fallbacks
M.get_root() -- Project root detection-- Server setup and capabilities
local servers = {
vtsls = { ... }, -- TypeScript/JavaScript
lua_ls = { ... }, -- Lua
pyright = { ... }, -- Python
gopls = { ... }, -- Go
-- Additional servers...
}-- Automatic tool installation
ensure_installed = {
-- LSP servers
"vtsls", "lua-language-server", "pyright",
-- Formatters
"prettier", "stylua", "black",
-- Linters
"eslint_d", "ruff",
}- Capabilities Detection: Auto-detects blink.cmp vs nvim-cmp
- Graceful Fallbacks: Handles missing dependencies
- TypeScript Enhancement: Advanced vtsls configuration
- Format Chains: Multiple formatter fallbacks per filetype
Comprehensive Project Detection:
-- 32 different project markers
local root_patterns = {
".git", ".hg", ".svn",
"package.json", "Cargo.toml", "go.mod",
"pyproject.toml", "setup.py", "requirements.txt",
-- ... and many more
}Performance Features:
- Caching system for repeated lookups
- Auto-setup via autocmds
- Fallback to current directory
Rose Pine Integration:
-- Semantic color mapping
local colors = {
bg = "#191724", -- Base background
fg = "#e0def4", -- Main foreground
accent = "#ebbcba", -- Primary accent
muted = "#6e6a86", -- Secondary text
-- ... complete palette
}Color Utilities:
M.darken(color, amount) -- Darken color by percentage
M.lighten(color, amount) -- Lighten color by percentage
M.alpha(color, alpha) -- Apply alpha transparency
M.setup_highlights() -- Apply custom highlightsIndustrial-Grade Keymap Management:
-- Conflict detection registry
local keymap_registry = {}
local conflicts = {}
local errors = {}
-- Safe keymap registration
M.safe_keymap_set = function(mode, lhs, rhs, opts)
-- Validation and conflict detection
-- Error handling and logging
-- Registration tracking
endMARVIM achieves exceptional startup performance (sub-40ms) through aggressive optimization strategies:
- Cached Capabilities: LSP capabilities calculated once and cached in
lua/utils/lsp_cache.lua - Lazy Server Configs: Heavy server configurations extracted to
lua/utils/lsp_servers.luaand loaded on-demand - Deferred Features: Codelens and inlay hints activate only after cursor activity (
CursorHold/CursorHoldI) - Background Setup: Mason server installation happens asynchronously via
vim.defer_fn() - Optimized Events: LSP loads on
BufReadPreinstead ofBufReadPostfor faster file opening
- Snippet Deferral: friendly-snippets and LuaSnip load only when
:EnableSnippetsis called - Minimal Default Sources: Completion uses only
lsp,path, andbufferby default - Event Optimization: Removed
CmdlineEntertrigger to eliminate 40ms+ bottleneck - Lazy Dependencies: Heavy completion dependencies marked as
lazy = true
- Strategic Event Triggers: Plugins load on precise events rather than broad categories
- Dependency Management: Heavy dependencies (LuaSnip, friendly-snippets) deferred until needed
- Deferred Initialization: Non-critical features initialize after UI is ready via autocmds
- Original Performance: 201ms startup time
- After LSP Optimization: 41ms startup time (80% improvement)
- After Completion Optimization: 38ms startup time (81% total improvement)
- Performance Monitoring: Use
:Lazy profileto identify bottlenecks
lua/utils/lsp_cache.lua- LSP capability caching systemlua/utils/lsp_servers.lua- Deferred server configuration loading- Background mason setup with 50ms delay
- CursorHold/CursorHoldI triggered feature loading for non-essential components
- Root Caching: Project root detection cached
- Capability Detection: LSP capabilities cached and reused
- Keymap Registry: Efficient conflict detection
- Selective Loading: Only load what's needed when needed
# Health checks
:checkhealth # System health
:checkhealth lazy # Plugin health
:Mason # Tool management
:LspInfo # LSP status
# Performance & Diagnostics
:Lazy profile # Plugin performance analysis
:KeymapDiagnostics # Keymap conflicts
:EnableSnippets # Load snippet support on-demand
# Performance monitoring
:Lazy profile # Startup performance breakdown<leader>ff- Find files<leader>fg- Live grep<leader>fb- Browse buffers<leader>fr- Recent files
<leader>gg- LazyGit<leader>gd- Diff view<leader>gb- Git blame<leader>gh- Git hunks
<leader>tt- Run nearest test<leader>tf- Run file tests<leader>ts- Test summary<leader>tw- Watch tests
gd- Go to definitiongr- Find referencesK- Hover documentation<leader>ca- Code actions
- Plugin Loading: Check
:Lazyfor errors - LSP Problems: Use
:LspInfoand:checkhealth lsp - Keymap Conflicts: Run
:KeymapDiagnostics - Performance: Use
:Lazy profilefor bottlenecks
-- Enable debug logging
vim.g.marvim_debug = true:checkhealth # Full system check
:checkhealth lazy # Plugin manager
:checkhealth mason # Tool manager
:checkhealth lsp # LSP configuration- Determine Complexity: Simple config → category file, complex → separate file
- Add Keymaps: Update
lua/config/keymaps/plugins.lua - Follow Patterns: Use existing plugins as templates
- User Config: Create
lua/user/directory for personal customizations - Override Patterns: Use lazy.nvim's override system
- Maintain Modularity: Keep changes isolated and reversible
- Follow Architecture: Respect complexity-based organization
- Update Documentation: Keep DOCS.md current
- Test Thoroughly: Verify no regressions
- Performance: Profile changes with
:Lazy profile
MARVIM represents a sophisticated approach to Neovim configuration, combining performance optimization with maintainable architecture. The centralized keymap system, complexity-based organization, and defensive programming patterns create a robust foundation for modern development workflows.
"In the grand tradition of both Starfleet engineering and Istari wisdom, MARVIM demonstrates that true sophistication lies not in complexity, but in the elegant orchestration of simple, well-designed components."
Version: 1.0
Last Updated: 2025-06-27
Author: Brendan Mullins
Architecture: Modular, Performance-Optimized
Plugin Manager: lazy.nvim