# magidc/nvim-config architecture

> Architecture diagram of the GitHub repository magidc/nvim-config, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/magidc/nvim-config
- Repository: https://github.com/magidc/nvim-config

## Overview

##### Project type and purpose
- This repository is not a typical “app” but a **Neovim configuration framework** written in Lua.
- Purpose: Turn Neovim into a full-featured IDE for Java, Python, Rust, and Lua by orchestrating plugins (LSP, DAP, UI enhancements, file explorers, fuzzy finders, etc.), custom mappings, themes, and utility scripts.

##### File structure
- Top‐level files:
- init.lua – entry point, loads settings, plugins, mappings, autocmds
- install_nvim.sh – bootstrap script to install Neovim on Debian/Ubuntu
- README.md, .gitignore, screenshots/
- lua/ directory: the heart of the configuration, subdivided into:
- autocmds.lua – file‐system and editor event hooks
- settings.lua, theme.lua, utils.lua – global options, colorscheme, helper functions
- mappings.lua – global keybindings, WhichKey integration
- lsp/ – language-server configurations (java.lua, python.lua, rust.lua, handlers, dap adapters)
- plugins/ – plugin manager setup and per-plugin config modules
– configs/ – configuration files for each plugin (Telescope, Neotree, Aerial, Mason, etc.)
- External tool dependencies: ripgrep, Neovim >=0.8, Mason-managed LSP/DAP binaries

##### README for insights
- Describes features: autocompletion, diagnostics, debugging via DAP, fuzzy finder, Java launch
- Lists key plugins and their roles (Telescope, Aerial, WhichKey, nvim-jdtls, nvim-dap, etc.)
- Explains installation steps and pre-requisites (LSP servers, DAP adapters installed via mason.nvim)

##### Main components
A. Neovim Core (C/embedded Lua VM)
B. init.lua loader
C. Global modules
- Settings & Theme
- Utilities
- Autocmds
- Mappings (WhichKey)
D. Plugin Manager (packer.nvim / lazy.nvim entry point in lua/plugins/init.lua)
E. Plugin modules
1. UI Plugins (bufferline, lualine, neotree, telescope, scrollbar, etc.)
2. Dev-tools Plugins
– LSP client configuration (lua/lsp)
– DAP client configuration (lua/lsp/configs/dap.lua)
– Mason installer for LSP/DAP servers
3. Editor Enhancements (treesitter, autopairs, surround, comment, etc.)
F. External services
– LSP servers (e.g. eclipse.jdt.ls, pyright, rust_analyzer, lua_ls)
– DAP adapters (java-debug, debugpy, codelldb)
– OS tools (ripgrep)

##### Relationships & interactions
- init.lua → loads Settings, Theme, Utils, Autocmds, Mappings → initializes Plugin Manager
- Plugin Manager → installs/configures each plugin module
- Mappings/Autocmds → dispatch user key events to plugin commands or LSP/DAP functions
- LSP client module ↔ external LSP servers via IPC/STDIO
- DAP module ↔ external debug adapters via TCP/JSON
- UI plugins subscribe to events (diagnostics, completion, outline) and render in Neovim UI

##### Architectural patterns & design principles
- Modular separation: each feature/plugin lives in its own Lua module
- Declarative plugin specification + imperative config callbacks
- Lazy loading: plugins and LSP servers are loaded on demand (filetype hooks, commands)
- Dependency injection via `require(…)` and shared utils

##### Elements
- init.lua (entry point)
- lua/settings.lua/theme.lua/utils.lua/autocmds.lua/mappings.lua
- lua/plugins/init.lua + plugin config cluster
- lua/lsp/init.lua + per-language config + mason installer
- Data flows: keypress → mapping → plugin → LSP/DAP → external service → UI update
- OS tool (ripgrep) used by Telescope

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core
    NeovimCore["Neovim Core\n(C/embedded Lua VM)"]:::core
    NeovimCore -->|loads| Init

    %% Loader & Globals
    subgraph "Loader & Globals"
        Init["init.lua"]:::loader
        Settings["settings.lua"]:::loader
        Theme["theme.lua"]:::loader
        Utils["utils.lua"]:::loader
        Autocmds["autocmds.lua"]:::loader
        Mappings["mappings.lua"]:::loader
    end
    Init --> Settings
    Init --> Theme
    Init --> Utils
    Init --> Autocmds
    Init --> Mappings

    %% Plugin Manager
    subgraph "Plugin Manager & Modules"
        direction TB
        PluginMgr["lua/plugins/init.lua"]:::plugin
        subgraph "UI Plugins" 
            direction TB
            Bufferline["bufferline.lua"]:::ui
            Lualine["lualine.lua"]:::ui
            Neotree["neotree.lua"]:::ui
            Telescope["telescope.lua"]:::ui
            Scrollbar["scrollbar.lua"]:::ui
            Aerial["aerial.lua"]:::ui
            Colorizer["colorizer.lua"]:::ui
            Glance["glance.lua"]:::ui
            Zen["zen.lua"]:::ui
        end
        subgraph "Dev-Tools Plugins"
            direction TB
            Mason["mason.lua"]:::plugin
            LSPInit["lua/lsp/init.lua"]:::plugin
            JavaCfg["java.lua"]:::plugin
            PythonCfg["python.lua"]:::plugin
            RustCfg["rust.lua"]:::plugin
            Handlers["handlers.lua"]:::plugin
            DAPCfg["dap.lua"]:::plugin
        end
        subgraph "Editor Enhancements"
            direction TB
            Treesitter["treesitter.lua"]:::plugin
            Autopairs["autopairs.lua"]:::plugin
            Surround["surround.lua"]:::plugin
            Comment["comment.lua"]:::plugin
            Indent["indent.lua"]:::plugin
            SplitJoin["splitjoin.lua"]:::plugin
            ToggleTerm["toggleterm.lua"]:::plugin
        end
    end
    Mappings --> PluginMgr
    PluginMgr --> Bufferline
    PluginMgr --> Lualine
    PluginMgr --> Neotree
    PluginMgr --> Telescope
    PluginMgr --> Scrollbar
    PluginMgr --> Aerial
    PluginMgr --> Colorizer
    PluginMgr --> Glance
    PluginMgr --> Zen
    PluginMgr --> Mason
    PluginMgr --> LSPInit
    PluginMgr --> DAPCfg
    PluginMgr --> Treesitter
    PluginMgr --> Autopairs
    PluginMgr --> Surround
    PluginMgr --> Comment
    PluginMgr --> Indent
    PluginMgr --> SplitJoin
    PluginMgr --> ToggleTerm

    LSPInit --> JavaCfg
    LSPInit --> PythonCfg
    LSPInit --> RustCfg
    LSPInit --> Handlers

    %% External Services
    subgraph "External Services"
        direction TB
        LSPServers["LSP Servers\n(eclipse.jdt.ls,\npyright, rust_analyzer,\nlua_ls)"]:::ext
        DAPAdapters["DAP Adapters\n(java-debug, debugpy,\ncodelldb)"]:::ext
        Ripgrep["Ripgrep (OS Tool)"]:::ext
    end
    JavaCfg -->|JSON RPC| LSPServers
    PythonCfg -->|JSON RPC| LSPServers
    RustCfg -->|JSON RPC| LSPServers
    Handlers -->|JSON RPC| LSPServers
    DAPCfg -->|Debug Adapter Protocol| DAPAdapters
    Telescope -->|uses| Ripgrep

    %% Bootstrap Script
    InstallScript["install_nvim.sh"]:::loader
    NeovimCore --> InstallScript

    %% Click Events
    click Init "https://github.com/magidc/nvim-config/blob/master/init.lua"
    click Settings "https://github.com/magidc/nvim-config/blob/master/lua/settings.lua"
    click Theme "https://github.com/magidc/nvim-config/blob/master/lua/theme.lua"
    click Utils "https://github.com/magidc/nvim-config/blob/master/lua/utils.lua"
    click Autocmds "https://github.com/magidc/nvim-config/blob/master/lua/autocmds.lua"
    click Mappings "https://github.com/magidc/nvim-config/blob/master/lua/mappings.lua"
    click PluginMgr "https://github.com/magidc/nvim-config/blob/master/lua/plugins/init.lua"
    click Bufferline "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/bufferline.lua"
    click Lualine "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/lualine.lua"
    click Neotree "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/neotree.lua"
    click Telescope "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/telescope.lua"
    click Scrollbar "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/scrollbar.lua"
    click Aerial "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/aerial.lua"
    click Colorizer "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/colorizer.lua"
    click Glance "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/glance.lua"
    click Zen "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/zen.lua"
    click Mason "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/mason.lua"
    click LSPInit "https://github.com/magidc/nvim-config/blob/master/lua/lsp/init.lua"
    click JavaCfg "https://github.com/magidc/nvim-config/blob/master/lua/lsp/configs/java.lua"
    click PythonCfg "https://github.com/magidc/nvim-config/blob/master/lua/lsp/configs/python.lua"
    click RustCfg "https://github.com/magidc/nvim-config/blob/master/lua/lsp/configs/rust.lua"
    click Handlers "https://github.com/magidc/nvim-config/blob/master/lua/lsp/handlers.lua"
    click DAPCfg "https://github.com/magidc/nvim-config/blob/master/lua/lsp/configs/dap.lua"
    click Treesitter "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/treesitter.lua"
    click Autopairs "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/autopairs.lua"
    click Surround "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/surround.lua"
    click Comment "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/comment.lua"
    click Indent "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/indent.lua"
    click SplitJoin "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/splitjoin.lua"
    click ToggleTerm "https://github.com/magidc/nvim-config/blob/master/lua/plugins/configs/toggleterm.lua"
    click InstallScript "https://github.com/magidc/nvim-config/blob/master/install_nvim.sh"

    %% Styles
    classDef core fill:#F0F0F0,stroke:#333,stroke-width:1px
    classDef loader fill:#D6EFFF,stroke:#333,stroke-width:1px
    classDef plugin fill:#D4F4DD,stroke:#333,stroke-width:1px
    classDef ui fill:#EAD1DC,stroke:#333,stroke-width:1px
    classDef ext fill:#FFD8A8,stroke:#333,stroke-width:1px
```
