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
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ neovim-dev: ## Set up local Neovim development environment.
rm "$(HOME)/.config/nvim"; \
fi
@mkdir -p "$(HOME)/.config/nvim"
@ln -sf "$(PWD)/config/nvim/init.lua" "$(HOME)/.config/nvim/init.lua"
@ln -sf "$(PWD)/config/nvim/nvim-pack-lock.json" "$(HOME)/.config/nvim/nvim-pack-lock.json"
@ln -sf "$(PWD)/home-manager/programs/neovim/init.lua" "$(HOME)/.config/nvim/init.lua"
@ln -sf "$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json" "$(HOME)/.config/nvim/nvim-pack-lock.json"
Comment on lines +477 to +478

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The path to the Neovim configuration directory is repeated. To improve maintainability and reduce redundancy, you can combine these commands into a single logical line and use a shell variable for the directory path.

	@NVIM_DIR="$(PWD)/home-manager/programs/neovim"; \
	ln -sf "$$NVIM_DIR/init.lua" "$(HOME)/.config/nvim/init.lua"; \
	ln -sf "$$NVIM_DIR/nvim-pack-lock.json" "$(HOME)/.config/nvim/nvim-pack-lock.json"

@echo "✅ Local Neovim development environment ready"
@echo "🚧 To restore the Nix-managed version, run 'make switch'"

Expand All @@ -489,13 +489,13 @@ neovim-update: ## Update Neovim plugins.
neovim-sync: ## Sync Neovim plugins.
@echo "🔄 Syncing neovim plugins..."
@nvim --headless +"lua vim.cmd('source ' .. vim.fn.stdpath('config') .. '/init.lua')" +qa
@if [ -f "$(PWD)/config/nvim/nvim-pack-lock.json" ]; then \
@if [ -f "$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json" ]; then \
if [ "$$(uname)" = "Darwin" ]; then \
sed -i '' -e '$$ { /^$$/d; }' "$(PWD)/config/nvim/nvim-pack-lock.json"; \
sed -i '' -e '$$ { /^$$/d; }' "$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json"; \
else \
sed -i -e '$$ { /^$$/d; }' "$(PWD)/config/nvim/nvim-pack-lock.json"; \
sed -i -e '$$ { /^$$/d; }' "$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json"; \
fi && \
printf '\n' >> "$(PWD)/config/nvim/nvim-pack-lock.json"; \
printf '\n' >> "$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json"; \
fi
Comment on lines +492 to 499

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The path to nvim-pack-lock.json is repeated multiple times within this target. To improve readability and maintainability, you can store it in a variable at the beginning of the command block.

	@NVIM_PACK_LOCK="$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json"; \
	if [ -f "$$NVIM_PACK_LOCK" ]; then \
		if [ "$$(uname)" = "Darwin" ]; then \
			sed -i '' -e '$$ { /^$$/d; }' "$$NVIM_PACK_LOCK"; \
		else \
			sed -i -e '$$ { /^$$/d; }' "$$NVIM_PACK_LOCK"; \
		fi && \
		printf '\n' >> "$$NVIM_PACK_LOCK"; \
	fi

@echo "✅ Neovim plugins synced"

Expand All @@ -512,18 +512,18 @@ lua-check-neovim: ## Check Neovim configuration.
echo "⚠️ Neovim is not installed or not in PATH"; \
exit 1; \
fi
@NVIM_CONFIG="$(PWD)/config/nvim/init.lua"; \
@NVIM_CONFIG="$(PWD)/home-manager/programs/neovim/init.lua"; \
if [ ! -f "$$NVIM_CONFIG" ]; then \
echo "⚠️ Could not find Neovim configuration at $$NVIM_CONFIG"; \
exit 1; \
fi
@echo "📝 Validating Neovim configuration syntax..."
@mkdir -p ~/.config/nvim
@ln -sf "$(PWD)/config/nvim/init.lua" ~/.config/nvim/init.lua
@if [ -f "$(PWD)/config/nvim/nvim-pack-lock.json" ]; then \
ln -sf "$(PWD)/config/nvim/nvim-pack-lock.json" ~/.config/nvim/nvim-pack-lock.json; \
@ln -sf "$(PWD)/home-manager/programs/neovim/init.lua" ~/.config/nvim/init.lua
@if [ -f "$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json" ]; then \
ln -sf "$(PWD)/home-manager/programs/neovim/nvim-pack-lock.json" ~/.config/nvim/nvim-pack-lock.json; \
fi
@nvim --headless -c "lua dofile('$(PWD)/config/nvim/init.lua')" -c "qa" 2>&1; \
@nvim --headless -c "lua dofile('$(PWD)/home-manager/programs/neovim/init.lua')" -c "qa" 2>&1; \
Comment on lines +515 to +526

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This target defines a shell variable NVIM_CONFIG in one command block, but subsequent commands that could use it are run in separate shells, making the variable unavailable. This is confusing and potentially error-prone. Additionally, the path to the Neovim directory is repeated. To fix this and improve maintainability, you should combine the commands into a single logical block and use variables consistently.

	@NVIM_DIR="$(PWD)/home-manager/programs/neovim"; \
	NVIM_CONFIG="$$NVIM_DIR/init.lua"; \
	if [ ! -f "$$NVIM_CONFIG" ]; then \
		echo "⚠️  Could not find Neovim configuration at $$NVIM_CONFIG"; \
		exit 1; \
	fi; \
	echo "📝 Validating Neovim configuration syntax..."; \
	mkdir -p ~/.config/nvim; \
	ln -sf "$$NVIM_CONFIG" ~/.config/nvim/init.lua; \
	if [ -f "$$NVIM_DIR/nvim-pack-lock.json" ]; then \
		ln -sf "$$NVIM_DIR/nvim-pack-lock.json" ~/.config/nvim/nvim-pack-lock.json; \
	fi; \
	nvim --headless -c "lua dofile('$$NVIM_CONFIG')" -c "qa" 2>&1; \

EXIT_CODE=$$?; \
if [ $$EXIT_CODE -eq 0 ]; then \
echo "✅ Neovim configuration is valid"; \
Expand Down
1 change: 0 additions & 1 deletion config/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
./ghostty
./hammerspoon
./karabiner
./nvim
./opencode
./serena
./starship
Expand Down
18 changes: 0 additions & 18 deletions config/nvim/default.nix

This file was deleted.

File renamed without changes.
22 changes: 21 additions & 1 deletion home-manager/programs/neovim/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{ pkgs, ... }:
{
config,
lib,
pkgs,
...
}:
let
nvimInitLua = ./init.lua;
nvimPackLockJson = ./nvim-pack-lock.json;
in
{
programs.neovim = {
enable = true;
Expand All @@ -7,4 +16,15 @@
vimAlias = true;
vimdiffAlias = true;
};

home.file.".config/nvim/init.lua" = {
source = config.lib.file.mkOutOfStoreSymlink nvimInitLua;

Copilot AI Nov 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable nvimInitLua is a relative path (./init.lua), but mkOutOfStoreSymlink requires an absolute path. This will create a broken symlink. Convert nvimInitLua to an absolute path using "${./.}/init.lua" or reference it relative to the module location.

Copilot uses AI. Check for mistakes.
force = true;
};

home.activation.copyNvimPackLock = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
$DRY_RUN_CMD mkdir -p "$HOME/.config/nvim"
$DRY_RUN_CMD cp -f ${nvimPackLockJson} "$HOME/.config/nvim/nvim-pack-lock.json"
$DRY_RUN_CMD chmod 644 "$HOME/.config/nvim/nvim-pack-lock.json"
'';
Comment on lines +25 to +29

Copilot AI Nov 26, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The explanatory comment from the original file explaining why this file is copied instead of symlinked (so Neovim can write to it) has been removed. This comment should be preserved as it documents important behavior that's not obvious from the code.

Copilot uses AI. Check for mistakes.
}
File renamed without changes.
Loading