Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 22 additions & 61 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
nix-homebrew = {
url = "github:zhaofengli-wip/nix-homebrew";
};
nixvim = {
url = "github:nix-community/nixvim";
nix-wrapper-modules = {
url = "github:BirdeeHub/nix-wrapper-modules";
inputs.nixpkgs.follows = "nixpkgs";
};
hardware = {
Expand Down
4 changes: 1 addition & 3 deletions lib/flakeHelpers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{ inputs, lib, self, overlays }:

let
inherit (inputs) nixpkgs nix-darwin home-manager nixvim vscode-server hardware charon-key sops-nix antigravity-nix;
inherit (inputs) nixpkgs nix-darwin home-manager vscode-server hardware charon-key sops-nix antigravity-nix;

# Helper to wrap a module file and filter out 'meta' attribute
# NixOS modules don't allow arbitrary top-level attributes
Expand Down Expand Up @@ -96,7 +96,6 @@ in
modules = [ host-config ]
++ [
home-manager.darwinModules.home-manager
nixvim.nixDarwinModules.nixvim
charon-key.darwinModules.default
# antigravity-nix exposes only packages/overlays (no darwinModules);
# google-antigravity* are injected via overlays/additions.nix
Expand Down Expand Up @@ -128,7 +127,6 @@ in
++ [
# Core NixOS modules from inputs
home-manager.nixosModules.home-manager
nixvim.nixosModules.nixvim
vscode-server.nixosModules.default
charon-key.nixosModules.default
sops-nix.nixosModules.sops
Expand Down
11 changes: 0 additions & 11 deletions modules/home/editors/neovim/dotfiles/colorschema.nix

This file was deleted.

11 changes: 0 additions & 11 deletions modules/home/editors/neovim/dotfiles/general.nix

This file was deleted.

5 changes: 0 additions & 5 deletions modules/home/editors/neovim/dotfiles/keymaps.nix

This file was deleted.

35 changes: 35 additions & 0 deletions modules/home/editors/neovim/dotfiles/nvim/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- ╭──────────────────────────────────────────────────────────╮
-- │ LazyVim-like Neovim Configuration │
-- │ Plugins are pre-installed by Nix (nix-wrapper-modules) │
-- │ Edit these Lua files → restart nvim — no rebuild! │
-- ╰──────────────────────────────────────────────────────────╯

-- Leader key must be set before any plugin loads
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"

-- Enable byte-compiled loader for faster startup
vim.loader.enable()

-- Load core configuration
require("config.options")
require("config.keymaps")
require("config.autocmds")

-- Auto-load all plugin configs from lua/plugins/**/*.lua
local function load_plugin_configs(base_dir)
local config_path = vim.fn.stdpath("config") .. "/lua/" .. base_dir
if vim.fn.isdirectory(config_path) == 0 then
return
end

for _, file in ipairs(vim.fn.glob(config_path .. "/**/*.lua", false, true)) do
local module = file:match("lua/(.+)%.lua$"):gsub("/", ".")
local ok, err = pcall(require, module)
if not ok then
vim.notify("Error loading " .. module .. ":\n" .. err, vim.log.levels.ERROR)
end
end
end

load_plugin_configs("plugins")
74 changes: 74 additions & 0 deletions modules/home/editors/neovim/dotfiles/nvim/lua/config/autocmds.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
-- LazyVim-style autocommands
local autocmd = vim.api.nvim_create_autocmd
local augroup = vim.api.nvim_create_augroup

-- Highlight on yank
autocmd("TextYankPost", {
group = augroup("highlight_yank", { clear = true }),
callback = function()
vim.highlight.on_yank()
end,
})

-- Resize splits on window resize
autocmd("VimResized", {
group = augroup("resize_splits", { clear = true }),
callback = function()
local current_tab = vim.fn.tabpagenr()
vim.cmd("tabdo wincmd =")
vim.cmd("tabnext " .. current_tab)
end,
})

-- Restore cursor position when opening a buffer
autocmd("BufReadPost", {
group = augroup("last_loc", { clear = true }),
callback = function(event)
local exclude = { "gitcommit" }
local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].last_loc then
return
end
vim.b[buf].last_loc = true
local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})

-- Close some filetypes with <q>
autocmd("FileType", {
group = augroup("close_with_q", { clear = true }),
pattern = {
"help", "lspinfo", "notify", "qf", "query",
"startuptime", "checkhealth",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true })
end,
})

-- Auto create parent dirs when saving a new file
autocmd("BufWritePre", {
group = augroup("auto_create_dir", { clear = true }),
callback = function(event)
if event.match:match("^%w%w+:[\\/][\\/]") then
return
end
local file = vim.uv.fs_realpath(event.match) or event.match
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})

-- Wrap and spell in text filetypes
autocmd("FileType", {
group = augroup("wrap_spell", { clear = true }),
pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" },
callback = function()
vim.opt_local.wrap = true
vim.opt_local.spell = true
end,
})
64 changes: 64 additions & 0 deletions modules/home/editors/neovim/dotfiles/nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
-- LazyVim-style keymaps
local map = vim.keymap.set

-- ── Window navigation ──
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window" })
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" })
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" })
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window" })

-- ── Resize windows ──
map("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
map("n", "<C-Down>", "<cmd>resize -2<cr>", { desc = "Decrease window height" })
map("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Decrease window width" })
map("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase window width" })

-- ── Buffer navigation ──
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
map("n", "<leader>bd", function() Snacks.bufdelete() end, { desc = "Close buffer" })
map("n", "<leader>bD", "<cmd>bdelete!<cr>", { desc = "Close buffer (force)" })

-- ── Move lines ──
map("n", "<A-j>", "<cmd>move .+1<cr>==", { desc = "Move line down" })
map("n", "<A-k>", "<cmd>move .-2<cr>==", { desc = "Move line up" })
map("v", "<A-j>", ":move '>+1<cr>gv=gv", { desc = "Move selection down" })
map("v", "<A-k>", ":move '<-2<cr>gv=gv", { desc = "Move selection up" })
map("i", "<A-j>", "<esc><cmd>move .+1<cr>==gi", { desc = "Move line down" })
map("i", "<A-k>", "<esc><cmd>move .-2<cr>==gi", { desc = "Move line up" })

-- ── Save / Quit ──
map("n", "<leader>w", "<cmd>w<cr>", { desc = "Save" })
map("n", "<leader>q", "<cmd>q<cr>", { desc = "Quit" })
map("n", "<leader>Q", "<cmd>qa<cr>", { desc = "Quit all" })

-- ── Clear search highlight ──
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and clear hlsearch" })
map("n", "<leader>ur", "<cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><cr>", { desc = "Redraw / clear hlsearch" })

-- ── Better indenting (stay in visual mode) ──
map("v", "<", "<gv")
map("v", ">", ">gv")

-- ── New file ──
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New file" })

-- ── Diagnostics ──
map("n", "]d", vim.diagnostic.goto_next, { desc = "Next diagnostic" })
map("n", "[d", vim.diagnostic.goto_prev, { desc = "Prev diagnostic" })
map("n", "<leader>cd", vim.diagnostic.open_float, { desc = "Line diagnostics" })

-- ── Terminal ──
map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })

-- ── Misc ──
map("n", "<leader>R", function()
-- Clear Lua module cache for our config
for name, _ in pairs(package.loaded) do
if name:match("^config%.") or name:match("^plugins%.") then
package.loaded[name] = nil
end
end
dofile(vim.fn.stdpath("config") .. "/init.lua")
vim.notify("Config reloaded!", vim.log.levels.INFO)
end, { desc = "Reload config" })
Loading
Loading