updated nvim config, added local_ai

This commit is contained in:
2026-08-16 10:16:13 -07:00
parent 35cf83cb70
commit da513216a3
17 changed files with 734 additions and 321 deletions

View File

@@ -6,6 +6,7 @@
./foot.nix
./brave.nix
./zsh.nix
./nvim
];
xdg.portal.config.common.default = "*";

View File

@@ -0,0 +1,2 @@
-- Bootstrap lazy.nvim, LazyVim and custom plugins
require("config.lazy")

View File

@@ -0,0 +1,5 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds set by LazyVim:
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Custom autocmds can be defined here

View File

@@ -0,0 +1,8 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps set by LazyVim:
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
local map = vim.keymap.set
-- Custom keymaps can be added below:
-- Example: map("n", "<leader>pv", vim.cmd.Ex, { desc = "Open file explorer" })

View File

@@ -0,0 +1,56 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
spec = {
-- 1. Add LazyVim core and import its default plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- 2. Optional LazyVim Extras (uncomment or add extras as needed)
{ import = "lazyvim.plugins.extras.lang.nix" },
{ import = "lazyvim.plugins.extras.lang.rust" },
{ import = "lazyvim.plugins.extras.lang.python" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
-- 3. Import user plugins from lua/plugins/*.lua
{ import = "plugins" },
},
defaults = {
-- Plugins load during startup unless explicitly marked lazy
lazy = false,
-- Always track latest git commit
version = false,
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = {
enabled = true,
notify = false,
},
performance = {
rtp = {
paths = vim.env.NVIM_TREESITTER_PARSERS and { vim.env.NVIM_TREESITTER_PARSERS } or {},
disabled_plugins = {
"gzip",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
})

View File

@@ -0,0 +1,17 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set by LazyVim:
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
local opt = vim.opt
-- Tab and indentation settings
opt.tabstop = 4
opt.shiftwidth = 4
opt.expandtab = true
-- Line numbers
opt.number = true
opt.relativenumber = true
-- Clipboard integration with system/Wayland
opt.clipboard = "unnamedplus"

View File

@@ -0,0 +1,24 @@
return {
-- Tokyo Night colorscheme configuration
{
"folke/tokyonight.nvim",
lazy = false,
priority = 1000,
opts = {
style = "night",
transparent = true,
styles = {
sidebars = "transparent",
floats = "transparent",
},
},
},
-- Configure LazyVim to use tokyonight by default
{
"LazyVim/LazyVim",
opts = {
colorscheme = "tokyonight",
},
},
}

View File

@@ -0,0 +1,48 @@
-- User custom plugin configurations and overrides
return {
-- Disable Mason on NixOS (all LSPs/formatters/linters are managed declaratively via Nix)
{ "mason.nvim", enabled = false },
{ "mason-lspconfig.nvim", enabled = false },
{ "mason-nvim-dap.nvim", enabled = false },
-- Treesitter configuration tailored for NixOS
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Nix provides all precompiled grammars in ~/.config/nvim/parser and rtp.
-- Clear LazyVim's default ensure_installed list to prevent compile triggers on startup.
opts.ensure_installed = {}
opts.auto_install = false
opts.sync_install = false
opts.highlight = {
enable = true,
additional_vim_regex_highlighting = false,
}
opts.indent = { enable = true }
end,
},
-- Example: Telescope / fzf configuration
{
"nvim-telescope/telescope.nvim",
opts = {
defaults = {
layout_strategy = "horizontal",
layout_config = { prompt_position = "top" },
sorting_strategy = "ascending",
winblend = 0,
},
},
},
-- Linting configuration (graceful fallback if linters are not yet in PATH)
{
"mfussenegger/nvim-lint",
opts = function(_, opts)
opts.linters_by_ft = opts.linters_by_ft or {}
if vim.fn.executable("statix") == 0 then
opts.linters_by_ft["nix"] = {}
end
end,
},
}

76
home/nvim/default.nix Normal file
View File

@@ -0,0 +1,76 @@
{ config, pkgs, lib, ... }:
let
treesitterParsers = pkgs.symlinkJoin {
name = "treesitter-parsers";
paths = builtins.attrValues pkgs.vimPlugins.nvim-treesitter.passthru.grammarPlugins;
};
in
{
programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
withNodeJs = true;
withPython3 = true;
extraPackages = with pkgs; [
# Native compilation tools & Treesitter CLI
gcc
clang
gnumake
cmake
tree-sitter
# Search & Fuzzy Finding
ripgrep
fd
fzf
# Archive and Network Utilities
git
curl
unzip
gnutar
gzip
# Language Servers, Linters & Formatters (Declarative, no Mason needed)
# Nix
nil
nixfmt
statix
# Lua
lua-language-server
stylua
# C / C++
llvmPackages_latest.clang-tools
llvmPackages_latest.lldb
# Rust
rust-analyzer
# Python
pyright
ruff
# Web / TypeScript / JavaScript / HTML / CSS / JSON
vtsls
vscode-langservers-extracted
prettier
# Shell
shfmt
shellcheck
];
extraWrapperArgs = [
"--set" "NVIM_TREESITTER_PARSERS" "${treesitterParsers}"
];
};
# Symlink LazyVim configuration to ~/.config/nvim recursively
xdg.configFile."nvim" = {
source = ./config;
recursive = true;
};
# Symlink precompiled Treesitter parsers directly into ~/.config/nvim/parser
xdg.configFile."nvim/parser".source = "${treesitterParsers}/parser";
}

View File

@@ -1,207 +1,220 @@
{ config, pkgs, lib, ... }:
{
config,
pkgs,
lib,
...
}:
{
programs.bat = {
enable = true;
config = {
theme = "base16";
};
programs.bat = {
enable = true;
config = {
theme = "base16";
};
};
programs.lsd = {
enable = true;
enableZshIntegration = false; # We explicitly define custom aliases below
};
programs.lsd = {
enable = true;
enableZshIntegration = false; # We explicitly define custom aliases below
};
programs.fzf = {
enable = true;
enableZshIntegration = true;
defaultOptions = [
"--color=dark"
"--color=fg:-1,bg:-1,hl:#c678dd,fg+:#ffffff,bg+:#4b5263,hl+:#d858fe"
"--color=info:#98c379,prompt:#61afef,pointer:#be5046,marker:#e5c07b,spinner:#61afef,header:#61afef"
];
};
programs.zoxide = {
enable = true;
enableZshIntegration = true;
options = [ "--cmd" "cd" ];
};
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting = {
enable = true;
highlighters = [ "main" "brackets" ];
};
oh-my-zsh = {
enable = true;
plugins = [
"git"
"tmux"
"battery"
"colored-man-pages"
"jsontools"
];
extraConfig = ''
COMPLETION_WAITING_DOTS="..."
ZVM_INIT_MODE="sourcing"
'';
};
plugins = [
{
name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
{
name = "fzf-tab";
src = pkgs.zsh-fzf-tab;
file = "share/fzf-tab/fzf-tab.plugin.zsh";
}
{
name = "zsh-interactive-cd";
src = pkgs.fetchFromGitHub {
owner = "changyuheng";
repo = "zsh-interactive-cd";
rev = "e7d4802aa526ec069dafec6709549f4344ce9d4a";
sha256 = "sha256-j23Ew18o7i/7dLlrTu0/54+6mbY8srsptfrDP/9BI/Q=";
};
file = "zsh-interactive-cd.plugin.zsh";
}
];
sessionVariables = {
EDITOR = "nvim";
BAT_THEME = "base16";
ZSH_TMUX_FIXTERM = "true";
GPG_TTY = "$(tty)";
PNPM_HOME = "$HOME/.local/share/pnpm";
};
shellAliases = {
vim = "nvim";
cat = "bat --paging=never";
ls = "lsd";
l = "ls -al";
clear = "clear -x";
rm = "rm -I";
zshconf = "$EDITOR $HOME/NixOS-Configs/home/zsh.nix";
hyprconf = "$EDITOR $HOME/NixOS-Configs/home/hypr/hyprland.nix";
setup = "source ./setup_env.sh";
gpuenv = "__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia";
digital = "$HOME/Tools/Digital/Digital.sh";
};
initContent = lib.mkMerge [
(lib.mkBefore ''
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
fi
'')
(lib.mkAfter ''
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Path configuration
export PATH="$HOME/.local/bin:$HOME/bin:$HOME/.cargo/bin:$PNPM_HOME:$PATH"
if [ -d "$HOME/Tools/xilinx/Vivado/2023.1/bin" ]; then
export PATH="$HOME/Tools/xilinx/Vivado/2023.1/bin:$PATH"
fi
# Miniconda / conda profile hook if installed
if [ -f /opt/miniconda3/etc/profile.d/conda.sh ]; then
source /opt/miniconda3/etc/profile.d/conda.sh
fi
# Environment modules support if available
if (( ''${+functions[module]} )) || [ -f /etc/modules/init/zsh ]; then
[ -f /etc/modules/init/zsh ] && source /etc/modules/init/zsh
module use --append "$HOME/.config/modulefiles" 2>/dev/null || true
fi
# Auto-tmux configuration
use_auto_tmux () {
! ([ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] || $(pgrep -x "i3" > /dev/null || pgrep -x "sway" > /dev/null || pgrep -x "Hyprland" > /dev/null))
}
if use_auto_tmux; then
export ZSH_TMUX_AUTOSTART=true
export ZSH_TMUX_AUTOCONNECT=false
export ZSH_TMUX_AUTOQUIT=true
else
export ZSH_TMUX_AUTOSTART=false
export ZSH_TMUX_AUTOCONNECT=false
export ZSH_TMUX_AUTOQUIT=false
fi
if [[ -n "$TMUX" ]]; then
tmux-window-name() {
if [ -n "$TMUX_PLUGIN_MANAGER_PATH" ] && [ -f "$TMUX_PLUGIN_MANAGER_PATH/tmux-window-name/scripts/rename_session_windows.py" ]; then
("$TMUX_PLUGIN_MANAGER_PATH/tmux-window-name/scripts/rename_session_windows.py" &)
fi
}
autoload -Uz add-zsh-hook
add-zsh-hook chpwd tmux-window-name
fi
# Custom helper functions
perlmutter_pass () {
echo -n 'bw master password: '
read -s MASTER_PASS
echo
echo -n 'Copying passkey...'
echo "$(echo "$MASTER_PASS" | bw get password iris.nersc.gov 2>/dev/null)$(echo "$MASTER_PASS" | bw get totp iris.nersc.gov 2>/dev/null)" | wl-copy
echo 'Done.'
}
compiler_explorer () {
docker run -d -p 10240:10240 --name compiler-explorer madduci/docker-compiler-explorer
}
airplay_server () {
uxplay -p 10000 -nh -n "$(hostname)" -restrict -allow 88:66:5A:76:32:F5 -allow C4:AC:AA:76:B7:80
}
zathura_md () {
cat "$1" | pandoc -f markdown -t pdf | zathura -
}
fooocus () {
if [ -f "$HOME/Tools/Fooocus/entry_with_update.py" ]; then
"$HOME/.conda/envs/fooocus/bin/python" "$HOME/Tools/Fooocus/entry_with_update.py"
else
echo "Fooocus not found at $HOME/Tools/Fooocus"
fi
}
# Per-host / system local overrides fallback
if [ -f "$HOME/.config/zsh/$(hostname)/env.sh" ]; then
source "$HOME/.config/zsh/$(hostname)/env.sh"
elif [ -f "$HOME/.zshrc.local" ]; then
source "$HOME/.zshrc.local"
fi
# Fetch / Banner on interactive terminal start
if [[ -o interactive ]] && [ -z "$TMUX" ] && command -v pfetch >/dev/null 2>&1; then
pfetch
fi
'')
];
};
home.packages = with pkgs; [
pfetch-rs
bitwarden-cli
pandoc
zathura
tmux
programs.fzf = {
enable = true;
enableZshIntegration = true;
defaultOptions = [
"--color=dark"
"--color=fg:-1,bg:-1,hl:#c678dd,fg+:#ffffff,bg+:#4b5263,hl+:#d858fe"
"--color=info:#98c379,prompt:#61afef,pointer:#be5046,marker:#e5c07b,spinner:#61afef,header:#61afef"
];
};
programs.zoxide = {
enable = true;
enableZshIntegration = true;
options = [
"--cmd"
"cd"
];
};
programs.zsh = {
enable = true;
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting = {
enable = true;
highlighters = [
"main"
"brackets"
];
};
oh-my-zsh = {
enable = true;
plugins = [
"git"
"tmux"
"battery"
"colored-man-pages"
"jsontools"
];
extraConfig = ''
COMPLETION_WAITING_DOTS="..."
ZVM_INIT_MODE="sourcing"
'';
};
plugins = [
{
name = "powerlevel10k";
src = pkgs.zsh-powerlevel10k;
file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
}
{
name = "fzf-tab";
src = pkgs.zsh-fzf-tab;
file = "share/fzf-tab/fzf-tab.plugin.zsh";
}
{
name = "zsh-interactive-cd";
src = pkgs.fetchFromGitHub {
owner = "changyuheng";
repo = "zsh-interactive-cd";
rev = "e7d4802aa526ec069dafec6709549f4344ce9d4a";
sha256 = "sha256-j23Ew18o7i/7dLlrTu0/54+6mbY8srsptfrDP/9BI/Q=";
};
file = "zsh-interactive-cd.plugin.zsh";
}
];
sessionVariables = {
EDITOR = "nvim";
BAT_THEME = "base16";
ZSH_TMUX_FIXTERM = "true";
GPG_TTY = "$(tty)";
PNPM_HOME = "$HOME/.local/share/pnpm";
};
shellAliases = {
vim = "nvim";
cat = "bat --paging=never";
ls = "lsd";
l = "ls -al";
clear = "clear -x";
rm = "rm -I";
zshconf = "$EDITOR $HOME/NixOS-Configs/home/zsh.nix";
hyprconf = "$EDITOR $HOME/NixOS-Configs/home/hypr/hyprland.nix";
setup = "source ./setup_env.sh";
gpuenv = "__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia";
digital = "$HOME/Tools/Digital/Digital.sh";
nixos_test = "sudo nixos_rebuild test --flake $HOME/NixOS-Configs#hades";
nixos_switch = "sudo nixos_rebuild switch --flake $HOME/NixOS-Configs#hades";
};
initContent = lib.mkMerge [
(lib.mkBefore ''
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
if [[ -r "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh" ]]; then
source "''${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-''${(%):-%n}.zsh"
fi
'')
(lib.mkAfter ''
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# Path configuration
export PATH="$HOME/.local/bin:$HOME/bin:$HOME/.cargo/bin:$PNPM_HOME:$PATH"
if [ -d "$HOME/Tools/xilinx/Vivado/2023.1/bin" ]; then
export PATH="$HOME/Tools/xilinx/Vivado/2023.1/bin:$PATH"
fi
# Miniconda / conda profile hook if installed
if [ -f /opt/miniconda3/etc/profile.d/conda.sh ]; then
source /opt/miniconda3/etc/profile.d/conda.sh
fi
# Environment modules support if available
if (( ''${+functions[module]} )) || [ -f /etc/modules/init/zsh ]; then
[ -f /etc/modules/init/zsh ] && source /etc/modules/init/zsh
module use --append "$HOME/.config/modulefiles" 2>/dev/null || true
fi
# Auto-tmux configuration
use_auto_tmux () {
! ([ -z "$DISPLAY" ] && [ -z "$WAYLAND_DISPLAY" ] || $(pgrep -x "i3" > /dev/null || pgrep -x "sway" > /dev/null || pgrep -x "Hyprland" > /dev/null))
}
if use_auto_tmux; then
export ZSH_TMUX_AUTOSTART=true
export ZSH_TMUX_AUTOCONNECT=false
export ZSH_TMUX_AUTOQUIT=true
else
export ZSH_TMUX_AUTOSTART=false
export ZSH_TMUX_AUTOCONNECT=false
export ZSH_TMUX_AUTOQUIT=false
fi
if [[ -n "$TMUX" ]]; then
tmux-window-name() {
if [ -n "$TMUX_PLUGIN_MANAGER_PATH" ] && [ -f "$TMUX_PLUGIN_MANAGER_PATH/tmux-window-name/scripts/rename_session_windows.py" ]; then
("$TMUX_PLUGIN_MANAGER_PATH/tmux-window-name/scripts/rename_session_windows.py" &)
fi
}
autoload -Uz add-zsh-hook
add-zsh-hook chpwd tmux-window-name
fi
# Custom helper functions
perlmutter_pass () {
echo -n 'bw master password: '
read -s MASTER_PASS
echo
echo -n 'Copying passkey...'
echo "$(echo "$MASTER_PASS" | bw get password iris.nersc.gov 2>/dev/null)$(echo "$MASTER_PASS" | bw get totp iris.nersc.gov 2>/dev/null)" | wl-copy
echo 'Done.'
}
compiler_explorer () {
docker run -d -p 10240:10240 --name compiler-explorer madduci/docker-compiler-explorer
}
airplay_server () {
uxplay -p 10000 -nh -n "$(hostname)" -restrict -allow 88:66:5A:76:32:F5 -allow C4:AC:AA:76:B7:80
}
zathura_md () {
cat "$1" | pandoc -f markdown -t pdf | zathura -
}
fooocus () {
if [ -f "$HOME/Tools/Fooocus/entry_with_update.py" ]; then
"$HOME/.conda/envs/fooocus/bin/python" "$HOME/Tools/Fooocus/entry_with_update.py"
else
echo "Fooocus not found at $HOME/Tools/Fooocus"
fi
}
# Per-host / system local overrides fallback
if [ -f "$HOME/.config/zsh/$(hostname)/env.sh" ]; then
source "$HOME/.config/zsh/$(hostname)/env.sh"
elif [ -f "$HOME/.zshrc.local" ]; then
source "$HOME/.zshrc.local"
fi
# Fetch / Banner on interactive terminal start
if [[ -o interactive ]] && [ -z "$TMUX" ] && command -v pfetch >/dev/null 2>&1; then
pfetch
fi
'')
];
};
home.packages = with pkgs; [
pfetch-rs
bitwarden-cli
pandoc
zathura
tmux
];
}