diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 523de69..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,132 +0,0 @@ -# CLAUDE.md - -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. - -## Repository Overview - -This is a personal Neovim configuration built with nixvim, a Nix-based configuration system for Neovim. The configuration is structured as a Nix flake with modular plugin organization and supports multiple platforms (Linux and macOS, both x86_64 and aarch64). - -## Development Commands - -### Building and Running -- `nix run .` - Build and run nixvim with current configuration -- `nix run git+https://git.sajenim.dev/jasmine/nvim.nix.git` - Run from remote repository -- `nix flake check` - Verify configuration is valid and not broken -- `nix flake show` - Display available packages and checks for all systems -- `nix build` - Build the nixvim package without running it - -### Development Workflow -- `nix develop` - Enter development shell (if devShell is available) -- `nix flake update` - Update flake inputs (nixpkgs, nixvim, flake-parts) -- `git log --oneline -10` - View recent configuration changes - -## Architecture and Structure - -### Core Configuration Files -- `flake.nix` - Main flake definition with inputs, outputs, and build configuration -- `config/default.nix` - Central module imports file that orchestrates all configuration pieces -- `config/options.nix` - Global Neovim options (number, tabstop, clipboard, etc.) -- `config/autocmds.nix` - Autocommands for automatic behaviors (window balancing on resize) - -### Keymap Organization -The configuration separates keybindings into semantic namespaces under `config/keymaps/`: -- `general.nix` - Leader setup, page navigation, global keybindings -- `buffers.nix` - Buffer management operations (bq, bQ, bl) -- `windows.nix` - Window management operations (ws, wv, wq, wQ, wm) -- `find.nix` - Telescope find operations (ff, fg, fh, fc) -- `git.nix` - Unified git operations from gitsigns, fugitive, and telescope - -### Plugin Organization -The configuration uses a hierarchical plugin structure under `config/plugins/`: - -**Themes & Appearance** (`plugins/themes/`) -- Uses gruvbox-material theme with medium background and italic support - -**Language Server Protocol** (`plugins/lsp/`) -- `lsp.nix` - Comprehensive LSP setup with servers for: C/C++ (clangd), Clojure, Haskell (hls), Lua, Nix (nil_ls), YAML, Python (pyright), Rust (rust_analyzer) -- `conform.nix` - Code formatting configuration -- Extensive LSP keybindings: `gd` (definition), `gr` (references), `K` (hover), `r` (rename) - -**Plugin Collections** (`plugins/collections/`) -- `mini.nix` - Mini.nvim plugin suite -- `snacks.nix` - Snacks.nvim plugin collection (bufdelete functionality) - -**Editor Enhancements** (`plugins/editor/`) -- `treesitter.nix` - Syntax highlighting and parsing -- `harpoon.nix` - Quick file navigation -- `sessions.nix` - Session management -- `maximize.nix` - Window maximization/zoom functionality -- `surround.nix` - Text object surrounding -- `commentary.nix` - Code commenting - -**User Interface** (`plugins/ui/`) -- `lualine.nix` - Status line configuration -- `web-devicons.nix` - File type icons -- `whichkey.nix` - Keybinding hints and discovery - -**Git Integration** (`plugins/git/`) -- `fugitive.nix` - Git commands within Neovim (plugin config only, keymaps in keymaps/git.nix) -- `gitsigns.nix` - Git change indicators in gutter (plugin config only, keymaps in keymaps/git.nix) - -**Completion** (`plugins/cmp/`) -- `cmp.nix` - Autocompletion engine configuration - -**Utilities** (`plugins/utils/`) -- `telescope.nix` - Fuzzy finder and picker (plugin config only, keymaps in keymaps/find.nix and keymaps/git.nix) -- `oil.nix` - File manager replacement for netrw -- `vimtex.nix` - LaTeX support - -**Notes and Productivity** (`plugins/notes/`) -- `neorg.nix` - Org-mode like note taking (requires conceallevel=2, foldlevel=99) -- `markdown-preview.nix` - Live markdown preview -- `render-markdown.nix` - Enhanced markdown rendering -- `todo-comments.nix` - Highlight and manage TODO comments - -### Key Configuration Patterns - -**Leader Keys** -- Primary leader: `` -- Local leader: `` (using raw vim API call) -- Namespace prefixes: - - `b` - Buffer operations (bq, bQ, bl) - - `w` - Window operations (ws, wv, wq, wQ, wm) - - `f` - Find operations (ff, fg, fh, fc) - - `g` - Git operations (gs, gr, gb, gc, gd, gu, gp) - - `gl` - Git list operations (glc, glb, gld, gls) - - `l` - LSP operations - -**Navigation Keybindings** -- Uses dedicated modifiers for fast navigation (muscle memory): - - `Ctrl+Left/Right` - Cycle buffers - - `Ctrl+Up/Down` - Cycle windows - - `Ctrl+PageUp/PageDown` - Rotate windows - - `Ctrl+Del` - Equalize window sizes -- Mirrors WezTerm (ALT) and XMonad (Super) for cross-application consistency - -**Keybinding Philosophy** -- **Navigation**: Optimized for speed using dedicated modifiers -- **Management**: Optimized for clarity using leader + semantic namespaces -- **Separation of concerns**: Keymaps separated from plugin configurations -- **Container consistency**: Matches WezTerm's LEADER+p/t namespace pattern - -**Platform Support** -- Multi-platform flake supporting x86_64-linux, aarch64-linux, x86_64-darwin, aarch64-darwin -- Uses `pkgsWithUnfree` to allow unfree packages when needed -- Each system gets its own package and check derivation - -**Module Import Strategy** -- Central `default.nix` imports all configuration modules -- Keymaps organized by domain (buffers, windows, find, git) not by plugin -- Plugin files contain only configuration, keymaps are extracted to `keymaps/` -- Logical grouping by functionality (themes, LSP, editor, UI, etc.) -- Each plugin typically gets its own dedicated file for maintainability - -### Development Settings -- Uses 2-space indentation with tab expansion -- Clipboard integration with system (`unnamedplus`) -- Persistent undo files enabled -- Split windows open to the right -- Update time set to 100ms for responsive interactions -- Session options configured for proper session restoration - -When working on this configuration, always test changes with `nix flake check` before committing, and consider the modular structure when adding new plugins or features. \ No newline at end of file diff --git a/config/default.nix b/config/default.nix index 596de7d..e7d4b66 100644 --- a/config/default.nix +++ b/config/default.nix @@ -2,15 +2,9 @@ imports = [ # General Configuration ./autocmds.nix + ./keymaps.nix ./options.nix - # Keymaps - ./keymaps/general.nix - ./keymaps/buffers.nix - ./keymaps/windows.nix - ./keymaps/find.nix - ./keymaps/git.nix - # Themes & Appearance ./plugins/themes/default.nix @@ -28,8 +22,8 @@ # Editor Enhancements ./plugins/editor/commentary.nix ./plugins/editor/harpoon.nix - ./plugins/editor/maximize.nix ./plugins/editor/sessions.nix + ./plugins/editor/smart-splits.nix ./plugins/editor/surround.nix ./plugins/editor/treesitter.nix diff --git a/config/keymaps/general.nix b/config/keymaps.nix similarity index 83% rename from config/keymaps/general.nix rename to config/keymaps.nix index 6f80905..90d2d91 100644 --- a/config/keymaps/general.nix +++ b/config/keymaps.nix @@ -14,6 +14,15 @@ }; } + { + mode = ["n"]; + key = "f"; + action = ""; + options = { + desc = "+find"; + }; + } + { mode = ["n"]; key = ""; diff --git a/config/keymaps/buffers.nix b/config/keymaps/buffers.nix deleted file mode 100644 index a7cc025..0000000 --- a/config/keymaps/buffers.nix +++ /dev/null @@ -1,70 +0,0 @@ -{...}: { - keymaps = [ - # Buffer namespace indicator for whichkey - { - mode = ["n"]; - key = "b"; - action = ""; - options = { - desc = "+buffer"; - }; - } - - # Buffer deletion - { - mode = ["n"]; - key = "bq"; - action = { - __raw = "function() require('snacks').bufdelete() end"; - }; - options = { - desc = "Quit current buffer"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "bQ"; - action = { - __raw = "function() require('snacks').bufdelete.other() end"; - }; - options = { - desc = "Quit all other buffers"; - silent = true; - }; - } - - # Buffer navigation (moved from keymaps.nix) - { - mode = ["n"]; - key = ""; - action = ":bprevious"; - options = { - desc = "Previous buffer"; - silent = true; - }; - } - - { - mode = ["n"]; - key = ""; - action = ":bnext"; - options = { - desc = "Next buffer"; - silent = true; - }; - } - - # Buffer listing - { - mode = ["n"]; - key = "bl"; - action = "Telescope buffers"; - options = { - desc = "List buffers"; - silent = true; - }; - } - ]; -} diff --git a/config/keymaps/find.nix b/config/keymaps/find.nix deleted file mode 100644 index fc7faf2..0000000 --- a/config/keymaps/find.nix +++ /dev/null @@ -1,54 +0,0 @@ -{...}: { - keymaps = [ - # Find namespace indicator for whichkey - { - mode = ["n"]; - key = "f"; - action = ""; - options = { - desc = "+find"; - }; - } - - # Find files and content - { - mode = ["n"]; - key = "ff"; - action = "Telescope find_files"; - options = { - desc = "Find project files"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "fg"; - action = "Telescope live_grep"; - options = { - desc = "Find pattern"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "fh"; - action = "Telescope help_tags"; - options = { - desc = "Find help tags"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "fc"; - action = "Telescope commands"; - options = { - desc = "Find commands"; - silent = true; - }; - } - ]; -} diff --git a/config/keymaps/git.nix b/config/keymaps/git.nix deleted file mode 100644 index 7d303ac..0000000 --- a/config/keymaps/git.nix +++ /dev/null @@ -1,181 +0,0 @@ -{...}: { - keymaps = [ - # Git namespace indicator for whichkey - { - mode = ["n"]; - key = "g"; - action = ""; - options = { - desc = "+git"; - }; - } - - # Git list namespace indicator for whichkey - { - mode = ["n"]; - key = "gl"; - action = ""; - options = { - desc = "+list"; - }; - } - - # Git staging (from gitsigns) - { - mode = ["n" "v"]; - key = "gs"; - action = "Gitsigns stage_hunk"; - options = { - desc = "Stage hunk"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "gS"; - action = "Gitsigns stage_buffer"; - options = { - desc = "Stage buffer"; - silent = true; - }; - } - - # Git reset (from gitsigns) - { - mode = ["n" "v"]; - key = "gr"; - action = "Gitsigns reset_hunk"; - options = { - desc = "Reset hunk"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "gR"; - action = "Gitsigns reset_buffer"; - options = { - desc = "Reset buffer"; - silent = true; - }; - } - - # Git blame (from gitsigns) - { - mode = ["n"]; - key = "gb"; - action = "Gitsigns toggle_current_line_blame"; - options = { - desc = "Toggle blame"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "gB"; - action = "Gitsigns blame"; - options = { - desc = "View blame"; - silent = true; - }; - } - - # Git commit (from fugitive) - { - mode = ["n"]; - key = "gc"; - action = "Git commit"; - options = { - desc = "Commit changes"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "gC"; - action = "Git commit --amend"; - options = { - desc = "Amend changes"; - silent = true; - }; - } - - # Git diff (from fugitive) - { - mode = ["n"]; - key = "gd"; - action = "Git diff"; - options = { - desc = "View diff"; - silent = true; - }; - } - - # Git unstage (from fugitive) - { - mode = ["n"]; - key = "gu"; - action = "Git restore --staged ."; - options = { - desc = "Unstage all changes"; - silent = true; - }; - } - - # Git push (from fugitive) - { - mode = ["n"]; - key = "gp"; - action = "Git push"; - options = { - desc = "Push changes to remote"; - silent = true; - }; - } - - # Git list operations (from telescope) - { - mode = ["n"]; - key = "glc"; - action = "Telescope git_commits"; - options = { - desc = "List git commits"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "glb"; - action = "Telescope git_branches"; - options = { - desc = "List git branches"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "gld"; - action = "Telescope git_status"; - options = { - desc = "List git diff"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "gls"; - action = "Telescope git_stash"; - options = { - desc = "List git stash"; - silent = true; - }; - } - ]; -} diff --git a/config/keymaps/windows.nix b/config/keymaps/windows.nix deleted file mode 100644 index dfffcf9..0000000 --- a/config/keymaps/windows.nix +++ /dev/null @@ -1,110 +0,0 @@ -{...}: { - keymaps = [ - # Window namespace indicator for whichkey - { - mode = ["n"]; - key = "w"; - action = ""; - options = { - desc = "+window"; - }; - } - - # Window splits - { - mode = ["n"]; - key = "ws"; - action = "s"; - options = { - desc = "Split window horizontally"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "wv"; - action = "v"; - options = { - desc = "Split window vertically"; - silent = true; - }; - } - - # Window closing - { - mode = ["n"]; - key = "wq"; - action = "q"; - options = { - desc = "Quit window"; - silent = true; - }; - } - - { - mode = ["n"]; - key = "wQ"; - action = "o"; - options = { - desc = "Quit all other windows"; - silent = true; - }; - } - - # Window maximize - { - mode = ["n"]; - key = "wm"; - action = { - __raw = "require('maximize').toggle"; - }; - options = { - desc = "Toggle maximize window"; - silent = true; - }; - } - - # Cycle through splits - { - mode = ["n"]; - key = ""; - action = "W"; - options = { - desc = "Cycle to previous split"; - silent = true; - }; - } - - { - mode = ["n"]; - key = ""; - action = "w"; - options = { - desc = "Cycle to next split"; - silent = true; - }; - } - - # Rotate split layout - { - mode = ["n"]; - key = ""; - action = "R"; - options = { - desc = "Rotate splits counter-clockwise"; - silent = true; - }; - } - - { - mode = ["n"]; - key = ""; - action = "r"; - options = { - desc = "Rotate splits clockwise"; - silent = true; - }; - } - ]; -} diff --git a/config/plugins/collections/snacks.nix b/config/plugins/collections/snacks.nix index c0f6205..fa77338 100644 --- a/config/plugins/collections/snacks.nix +++ b/config/plugins/collections/snacks.nix @@ -1,4 +1,4 @@ -{...}: { +{...}:{ plugins.snacks = { enable = true; @@ -12,4 +12,30 @@ }; }; }; + + keymaps = [ + { + mode = ["n"]; + key = "q"; + action = { + __raw = "function() require('snacks').bufdelete() end"; + }; + options = { + desc = "Close current buffer"; + silent = true; + }; + } + + { + mode = ["n"]; + key = "Q"; + action = { + __raw = "function() require('snacks').bufdelete.other() end"; + }; + options = { + desc = "Close other buffers"; + silent = true; + }; + } + ]; } diff --git a/config/plugins/editor/maximize.nix b/config/plugins/editor/maximize.nix deleted file mode 100644 index 8d7be60..0000000 --- a/config/plugins/editor/maximize.nix +++ /dev/null @@ -1,13 +0,0 @@ -{pkgs, ...}: { - extraPlugins = [ - (pkgs.vimUtils.buildVimPlugin { - name = "maximize.nvim"; - src = pkgs.fetchFromGitHub { - owner = "declancm"; - repo = "maximize.nvim"; - rev = "d688b66344b03ee6e5a32a0a40af85d174490af8"; - hash = "sha256-rwnvX+Sul+bwESZtpqbvaDJuk49SV9tLUnvgiAH4VMs="; - }; - }) - ]; -} diff --git a/config/plugins/editor/smart-splits.nix b/config/plugins/editor/smart-splits.nix new file mode 100644 index 0000000..e85b9cc --- /dev/null +++ b/config/plugins/editor/smart-splits.nix @@ -0,0 +1,110 @@ +{...}: { + plugins.smart-splits = { + enable = true; + + settings = { + multiplexer_integration = "wezterm"; + }; + }; + + keymaps = [ + # moving between splits + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_left"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_down"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_up"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').move_cursor_right"; + }; + } + + # swapping buffers between windows + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_left"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_down"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_up"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').swap_buf_right"; + }; + } + + # resizing splits + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_left"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_down"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_up"; + }; + } + + { + mode = ["n"]; + key = ""; + action = { + __raw = "require('smart-splits').resize_right"; + }; + } + ]; +} diff --git a/config/plugins/git/fugitive.nix b/config/plugins/git/fugitive.nix index f440e26..337cdb7 100644 --- a/config/plugins/git/fugitive.nix +++ b/config/plugins/git/fugitive.nix @@ -2,4 +2,56 @@ plugins.fugitive = { enable = true; }; + + keymaps = [ + { + mode = ["n"]; + key = "gc"; + action = "Git commit"; + options = { + silent = true; + desc = "Commit Changes"; + }; + } + + { + mode = ["n"]; + key = "gC"; + action = "Git commit --amend"; + options = { + silent = true; + desc = "Ammend Changes"; + }; + } + + { + mode = ["n"]; + key = "gd"; + action = "Git diff"; + options = { + silent = true; + desc = "View diff"; + }; + } + + { + mode = ["n"]; + key = "gu"; + action = "Git restore --staged ."; + options = { + silent = true; + desc = "Unstage all changes"; + }; + } + + { + mode = ["n"]; + key = "gp"; + action = "Git push"; + options = { + silent = true; + desc = "Push changes to remote"; + }; + } + ]; } diff --git a/config/plugins/git/gitsigns.nix b/config/plugins/git/gitsigns.nix index f800e5f..0f363af 100644 --- a/config/plugins/git/gitsigns.nix +++ b/config/plugins/git/gitsigns.nix @@ -2,4 +2,66 @@ plugins.gitsigns = { enable = true; }; + + keymaps = [ + { + mode = ["n" "v"]; + key = "gs"; + action = "Gitsigns stage_hunk"; + options = { + silent = true; + desc = "Stage Hunk"; + }; + } + + { + mode = ["n"]; + key = "gS"; + action = "Gitsigns stage_buffer"; + options = { + silent = true; + desc = "Stage Buffer"; + }; + } + + { + mode = ["n" "v"]; + key = "gr"; + action = "Gitsigns reset_hunk"; + options = { + silent = true; + desc = "Reset Hunk"; + }; + } + + { + mode = ["n"]; + key = "gR"; + action = "Gitsigns reset_buffer"; + options = { + silent = true; + desc = "Reset Buffer"; + }; + } + + { + mode = ["n"]; + key = "gb"; + action = "Gitsigns toggle_current_line_blame"; + options = { + silent = true; + desc = "Toggle Blame"; + }; + } + + { + mode = ["n"]; + key = "gB"; + action = "Gitsigns blame"; + options = { + silent = true; + desc = "View Blame"; + }; + } + ]; } diff --git a/config/plugins/utils/telescope.nix b/config/plugins/utils/telescope.nix index 1a9f46c..af41389 100644 --- a/config/plugins/utils/telescope.nix +++ b/config/plugins/utils/telescope.nix @@ -18,12 +18,73 @@ settings = { defaults = { layout_strategy = "horizontal"; - # Reduce height / width of picker + # Reduce height / width of picker layout_config = { height = 0.8; width = 0.8; }; }; }; + + # Configure our telescope keymaps. + keymaps = { + # Find + "ff" = { + action = "find_files"; + options = { + desc = "Find project files"; + }; + }; + "fg" = { + action = "live_grep"; + options = { + desc = "Find pattern"; + }; + }; + "fb" = { + action = "buffers"; + options = { + desc = "Find open buffers"; + }; + }; + "fh" = { + action = "help_tags"; + options = { + desc = "Find help tags"; + }; + }; + "fc" = { + action = "commands"; + options = { + desc = "Find commands"; + }; + }; + + # Git List + "glc" = { + action = "git_commits"; + options = { + desc = "List git commits"; + }; + }; + "glb" = { + action = "git_branches"; + options = { + desc = "List git branches"; + }; + }; + "gld" = { + action = "git_status"; + options = { + desc = "List git diff"; + }; + }; + "gls" = { + action = "git_stash"; + options = { + desc = "List git stash"; + }; + }; + }; }; }