Reorganize configuration into modular directory structure

- Create modules/ directory for Nix configuration modules
- Create config/ directory for configuration files
- Move nvim.nix, tmux.nix, zsh.nix to modules/
- Move p10k.zsh to config/
- Update flake.nix import paths to reference new structure
- Update zsh.nix p10k.zsh path reference
- Update README.md architecture documentation
- Keep tmux.sh at root for easy accessibility

This provides better separation between Nix modules and config files
while maintaining a clean, scalable structure.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yan Lin 2025-07-26 22:07:28 +02:00
parent 2295aa9131
commit 539ba9fef7
6 changed files with 11 additions and 9 deletions

200
modules/nvim.nix Normal file
View file

@ -0,0 +1,200 @@
{ pkgs, ... }:
{
programs.nixvim = {
enable = true;
defaultEditor = true;
# Global settings
globals.mapleader = " ";
# Vim options
opts = {
number = true;
relativenumber = false;
expandtab = true;
shiftwidth = 2;
tabstop = 2;
smartindent = true;
wrap = false;
linebreak = true; # Don't break words when wrapping
breakindent = true; # Preserve indentation when wrapping
termguicolors = true;
};
# Enable filetype detection
viAlias = true;
vimAlias = true;
# Gruvbox colorscheme with hard contrast
colorschemes.gruvbox = {
enable = true;
settings = {
contrast = "hard"; # Makes background much darker (#1d2021 instead of #282828)
background = "dark";
};
};
# Plugins
plugins = {
# File explorer
nvim-tree = {
enable = true;
# NixVim nvim-tree uses extraConfig for detailed settings
};
# Syntax highlighting
treesitter = {
enable = true;
settings = {
highlight = {
enable = true;
additional_vim_regex_highlighting = true;
};
indent = {
enable = true;
};
ensure_installed = []; # Managed by Nix
auto_install = false;
};
grammarPackages = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [
bash c cpp css dockerfile go html javascript json lua markdown nix python rust typescript yaml
];
};
# Status line with gruvbox theme and relative paths
lualine = {
enable = true;
settings = {
options = {
theme = "gruvbox_dark";
component_separators = { left = "|"; right = "|"; };
section_separators = { left = " "; right = " "; };
};
sections = {
lualine_c = [{ __unkeyed-1 = "filename"; path = 1; }];
};
};
};
# Web dev icons
web-devicons = {
enable = true;
};
# Markdown rendering
render-markdown = {
enable = true;
};
};
# Extra plugins that don't have dedicated modules
extraPlugins = with pkgs.vimPlugins; [
vim-fugitive
];
# Keymaps
keymaps = [
# File explorer
{
mode = "n";
key = "<leader>e";
action = ":NvimTreeToggle<CR>";
options = { desc = "Toggle file explorer"; };
}
# Basic keymaps
{
mode = "n";
key = "<leader>w";
action = ":w<CR>";
options = { desc = "Save file"; };
}
{
mode = "n";
key = "<leader>q";
action = ":q<CR>";
options = { desc = "Quit"; };
}
# System clipboard keymaps
{
mode = ["n" "v"];
key = "<leader>y";
action = "\"+y";
options = { desc = "Copy to system clipboard"; };
}
{
mode = "n";
key = "<leader>p";
action = "\"+p";
options = { desc = "Paste from system clipboard"; };
}
{
mode = "v";
key = "<leader>p";
action = "\"+p";
options = { desc = "Replace selection with system clipboard"; };
}
# System integration
{
mode = "n";
key = "<leader>o";
action = ":silent !open %<CR>";
options = { desc = "Open file with system default app"; };
}
{
mode = "n";
key = "<leader>f";
action = ":silent !open -R %<CR>";
options = { desc = "Show current file in Finder"; };
}
# Git keymaps (vim-fugitive)
{
mode = "n";
key = "<leader>gs";
action = ":Git<CR>";
options = { desc = "Git status"; };
}
{
mode = "n";
key = "<leader>gd";
action = ":Git diff<CR>";
options = { desc = "Git diff"; };
}
{
mode = "n";
key = "<leader>gc";
action = ":Git commit<CR>";
options = { desc = "Git commit"; };
}
{
mode = "n";
key = "<leader>gp";
action = ":Git push<CR>";
options = { desc = "Git push"; };
}
# Markdown rendering
{
mode = "n";
key = "<leader>md";
action = ":RenderMarkdown toggle<CR>";
options = { desc = "Toggle markdown rendering"; };
}
];
# Additional Lua configuration for plugins that need custom setup
extraConfigLua = ''
-- Nvim-tree setup with filters
require("nvim-tree").setup({
filters = {
dotfiles = true, -- Hide dotfiles by default (H to toggle)
git_ignored = false, -- Show gitignored files by default (I to toggle)
},
})
'';
};
}

99
modules/tmux.nix Normal file
View file

@ -0,0 +1,99 @@
{ pkgs, ... }:
{
programs.tmux = {
enable = true;
shortcut = "a";
baseIndex = 1; # Start windows and panes at 1, not 0
mouse = true; # Enable mouse support
keyMode = "vi"; # Use vi key bindings in copy mode
terminal = "screen-256color"; # Force 256 color support
extraConfig = ''
# Terminal settings
set -g default-terminal "screen-256color"
set -ga terminal-overrides ",xterm-256color:Tc"
# Gruvbox Dark Theme (Truecolor)
# Status bar colors
set -g status-style 'bg=#282828,fg=#ebdbb2'
set -g status-left-style 'bg=#a89984,fg=#282828'
set -g status-right-style 'bg=#a89984,fg=#282828'
# Window status colors
set -g window-status-style 'bg=#3c3836,fg=#a89984'
set -g window-status-current-style 'bg=#fabd2f,fg=#282828'
set -g window-status-activity-style 'bg=#fb4934,fg=#282828'
# Pane border colors
set -g pane-border-style 'fg=#3c3836'
set -g pane-active-border-style 'fg=#fabd2f'
# Message colors
set -g message-style 'bg=#fabd2f,fg=#282828'
set -g message-command-style 'bg=#fabd2f,fg=#282828'
# Status bar content
set -g status-left-length 40
set -g status-right-length 20
set -g status-left ' #S '
set -g status-right '#{?client_prefix,#[reverse]<Prefix>#[noreverse] ,}'
# Window status format
set -g window-status-format ' #I:#W '
set -g window-status-current-format ' #I:#W '
# Better key bindings for splitting panes
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# Vim-like pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Vim-like pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# Quick pane cycling
unbind o
bind ^A select-pane -t :.+
# Reload config file
bind r source-file ~/.config/tmux/tmux.conf \; display-message "Config reloaded!"
# Better copy mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "pbcopy"
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
# New window with current path
bind c new-window -c "#{pane_current_path}"
# Don't rename windows automatically
set-option -g allow-rename off
# Increase scrollback buffer size
set -g history-limit 10000
# Display messages for longer
set -g display-time 2000
# Faster command sequences
set -s escape-time 0
# Activity monitoring
setw -g monitor-activity on
set -g visual-activity off
# Automatically renumber windows
set -g renumber-windows on
'';
};
}

98
modules/zsh.nix Normal file
View file

@ -0,0 +1,98 @@
{ pkgs, ... }:
{
programs.zsh = {
enable = true;
defaultKeymap = "viins";
enableVteIntegration = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting.enable = true;
sessionVariables = {
COLORTERM = "truecolor";
EDITOR = "nvim";
};
shellAliases = {
ll = "ls -alF";
la = "ls -A";
l = "ls -CF";
".." = "cd ..";
"..." = "cd ../..";
# Git aliases
gs = "git status";
ga = "git add";
gc = "git commit";
gp = "git push";
gl = "git pull";
gd = "git diff";
# Nix helpers
hm = "home-manager";
hms = "home-manager switch --flake ~/.config/nix#yanlin";
};
initContent = ''
# Load Powerlevel10k theme
if [[ -f ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme ]]; then
source ${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k/powerlevel10k.zsh-theme
fi
# Load Powerlevel10k configuration (managed by Nix)
source ~/.p10k.zsh
# Vim mode configuration
# Reduce delay when switching modes (10ms instead of 400ms)
export KEYTIMEOUT=1
# Cursor shape changes for vim modes
function zle-keymap-select {
case $KEYMAP in
vicmd) echo -ne '\e[1 q';; # block cursor for normal mode
viins|main) echo -ne '\e[5 q';; # line cursor for insert mode
esac
}
zle -N zle-keymap-select
# Ensure we start with line cursor in insert mode
function zle-line-init {
echo -ne '\e[5 q'
}
zle -N zle-line-init
# Fix cursor after each command
function preexec {
echo -ne '\e[5 q'
}
# Additional vim-like bindings
bindkey -M vicmd 'k' history-search-backward
bindkey -M vicmd 'j' history-search-forward
bindkey -M vicmd '/' history-incremental-search-backward
bindkey -M vicmd '?' history-incremental-search-forward
# Better word movement in insert mode
bindkey '^[[1;5C' forward-word # Ctrl+Right
bindkey '^[[1;5D' backward-word # Ctrl+Left
'';
};
# Essential packages for enhanced zsh experience
home.packages = with pkgs; [
zsh-powerlevel10k
fzf
fd
ripgrep
bat
];
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
# Manage Powerlevel10k configuration
home.file.".p10k.zsh".source = ../config/p10k.zsh;
}