# hanimar/nvim-config architecture

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

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

## Overview

##### Project Type & Purpose
- The project is essentially a custom configuration for Neovim, where the core settings, keybindings, plugin configurations, and language-specific integrations are organized modularly.
- Its purpose is to provide a rich, extensible development environment in Neovim with multiple plugins and tailored options for a variety of tasks (e.g., LSP setup, UI customizations, syntax parsing, and utilities like Git, Markdown, etc.).

##### Analyzing the File Structure
- At the top level you have core files like .gitignore, README.md, and init.lua (which serves as the main entry point when Neovim starts).
- The “lua” directory contains all the configuration code, further split into:
- “lua/config”: Houses general configurations, including subdirectories for commands and LSP settings. Files like options.lua indicate core editor settings, while commands and LSP subfolders demonstrate custom command setups and language server integrations.
- “lua/plugins”: Organizes the plugin management and configuration. This folder is subdivided into multiple directories:
· “lazy.lua” is likely the configuration for the lazy-loading plugin manager.
· “syntax”: Contains files for setting up LSP, completion (nvim-cmp), Treesitter integrations, and other syntax-related utilities.
· “utilities”: Groups together miscellaneous integrations (git, jupyter, latex, python, markdown, etc.), telescope, quickfix, and which-key; each file tailoring plugin behavior or setting up integrations.
- There is also a “snippets” directory providing code snippets, indicating support for language-specific shortcuts (e.g., cpp.snippets).

##### Main Components
- Entry Point: Start with the central node “init.lua” which initializes the Neovim session and calls subsequent configurations.
- Configuration Modules (lua/config):
- Options Module: “options.lua” contains core editor settings.
- Commands Module: “commands” (with files like smart-splits.lua and toggle.lua) for key bindings and command customizations.
- LSP Module: “lsp” folder with files (mason-lspconfig.lua, nvim-cmp.lua) showing the setup of language servers and auto-completion.
- Plugins Management (lua/plugins):
- Plugin Manager: “lazy.lua” handles lazy loading and initialization of plugins.
- Syntax Plugins: “syntax” folder (e.g., nvim-treesitter.lua, mason-lspconfig.lua) for syntax parsing, language server configs and completion engines.
- Utility Plugins: “utilities” folder integrating additional tools such as git, jupyter, latex, markdown, telescope, etc.
- External Components:
- Snippets Directory: “snippets” for code snippet integration.
- Other dependencies potentially provided by external plugin repositories (implied by configuration files, for instance, for LSP and Treesitter).

##### Relationships and Interactions
- The “init.lua” serves as the system bootstrapping script that loads the Lua configuration.
- Within “lua/config”, illustrate interactions:
· “options.lua” sets basic Neovim options.
· “commands” and “lsp” are invoked to customize editing commands and enable language-specific functionalities.
- That each plugin group then configures specific features (eg. “ui/status.lua” for status bars, “syntax/nvim-treesitter.lua” for syntax highlighting).

##### Architectural Patterns & Design Principles
- Modularity: The configuration is split into small, self-contained Lua modules (each file handles a particular aspect).
- Separation of Concerns: Core settings (“lua/config”) are kept separate from plugin-related logic (“lua/plugins”), which in turn is clearly divided by functionality (syntax, ui, utilities).
- Extensibility: The structure allows for easy addition of new plugins or commands without interfering with other areas – a key principle for larger, maintainable Neovim configurations.
- Dependency Injection: While implicit, it’s clear that the base configuration injects settings that each plugin can then build upon.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top-level Nodes
    Init["Core Init (init.lua)"]:::core
    Config["Configuration"]:::config
    Plugins["Plugins"]:::plugins
    Snippets["Snippets Integration"]:::external

    %% Connections from init.lua
    Init -->|"loads"| Config
    Init -->|"loads"| Plugins
    Init -->|"integrates"| Snippets

    %% Configuration Modules Subgraph
    subgraph "Configuration Modules"
        Options["Editor Options (options.lua)"]:::config
        Commands["Commands Module (lua/config/commands)"]:::config
        LSP["LSP Module (lua/config/lsp)"]:::config
    end

    Config --> Options
    Config --> Commands
    Config --> LSP

    %% Plugins Management Subgraph
    subgraph "Plugins Management"
        Lazy["Lazy Plugin Manager (lazy.lua)"]:::plugins
        Syntax["Syntax Plugins (lua/plugins/syntax)"]:::plugins
        UI["UI Plugins (lua/plugins/ui)"]:::plugins
        Utilities["Utility Plugins (lua/plugins/utilities)"]:::plugins
    end

    Plugins --> Lazy
    Lazy --> Syntax
    Lazy --> UI
    Lazy --> Utilities

    %% Click Events
    click Init "https://github.com/hanimar/nvim-config/blob/main/init.lua"
    click Options "https://github.com/hanimar/nvim-config/blob/main/lua/config/options.lua"
    click Commands "https://github.com/hanimar/nvim-config/tree/main/lua/config/commands"
    click LSP "https://github.com/hanimar/nvim-config/tree/main/lua/config/lsp"
    click Lazy "https://github.com/hanimar/nvim-config/blob/main/lua/plugins/lazy.lua"
    click Syntax "https://github.com/hanimar/nvim-config/tree/main/lua/plugins/syntax"
    click UI "https://github.com/hanimar/nvim-config/tree/main/lua/plugins/ui"
    click Utilities "https://github.com/hanimar/nvim-config/tree/main/lua/plugins/utilities"
    click Snippets "https://github.com/hanimar/nvim-config/tree/main/snippets"

    %% Style Definitions
    classDef core fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef config fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef plugins fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
```
