add cursor module

This commit is contained in:
Yan Lin 2025-12-02 23:02:30 +01:00
parent 20d61d67f8
commit 8f4b178e6b
3 changed files with 99 additions and 39 deletions

View file

@ -21,6 +21,7 @@
../../modules/tex.nix ../../modules/tex.nix
../../modules/fonts.nix ../../modules/fonts.nix
../../modules/linearmouse.nix ../../modules/linearmouse.nix
../../modules/cursor.nix
]; ];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
@ -234,44 +235,44 @@
# Uses duti to set default applications for file types via Launch Services # Uses duti to set default applications for file types via Launch Services
home.activation.setFileAssociations = config.lib.dag.entryAfter ["writeBoundary"] '' home.activation.setFileAssociations = config.lib.dag.entryAfter ["writeBoundary"] ''
# Text and code files - open with TextMate # Text and code files - open with TextMate
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .txt all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .txt all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .md all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .md all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .markdown all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .markdown all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .nix all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .nix all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .sh all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .sh all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .bash all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .bash all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .zsh all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .zsh all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .fish all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .fish all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .py all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .py all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .js all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .js all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .ts all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .ts all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .jsx all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .jsx all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .tsx all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .tsx all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .json all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .json all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .yaml all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .yaml all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .yml all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .yml all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .toml all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .toml all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .xml all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .xml all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .css all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .css all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .log all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .log all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .csv all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .csv all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .conf all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .conf all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .config all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .config all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .ini all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .ini all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .env all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .env all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .c all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .c all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .cpp all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .cpp all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .h all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .h all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .hpp all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .hpp all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .rs all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .rs all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .go all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .go all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .java all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .java all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .rb all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .rb all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .php all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .php all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .lua all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .lua all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .vim all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .vim all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .tex all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .tex all
run ${pkgs.duti}/bin/duti -s com.macromates.TextMate .bib all run ${pkgs.duti}/bin/duti -s com.todesktop.230313mzl4w4u92 .bib all
# Documents - PDF with Preview # Documents - PDF with Preview
run ${pkgs.duti}/bin/duti -s com.apple.Preview .pdf all run ${pkgs.duti}/bin/duti -s com.apple.Preview .pdf all

59
modules/cursor.nix Normal file
View file

@ -0,0 +1,59 @@
{ config, pkgs, lib, ... }:
let
configDir = if pkgs.stdenv.isDarwin
then "Library/Application Support/Cursor/User"
else ".config/Cursor/User";
cursorCmd = if pkgs.stdenv.isDarwin
then "/opt/homebrew/bin/cursor"
else "cursor";
ideSettings = {
"editor.fontFamily" = "'JetBrainsMono Nerd Font Mono', 'Noto Sans CJK SC', 'Noto Sans CJK TC', monospace";
"editor.fontSize" = 14;
"editor.tabSize" = 2;
"editor.insertSpaces" = true;
"editor.wordWrap" = "off";
"editor.lineNumbers" = "on";
"editor.autoIndent" = "advanced";
"workbench.colorTheme" = "Gruvbox Dark Hard";
"vim.leader" = "<space>";
"vim.useSystemClipboard" = true;
"vim.normalModeKeyBindingsNonRecursive" = [
{ before = ["<leader>" "w"]; commands = ["workbench.action.files.save"]; }
{ before = ["<leader>" "q"]; commands = ["workbench.action.closeActiveEditor"]; }
{ before = ["<leader>" "e"]; commands = ["workbench.action.toggleSidebarVisibility"]; }
{ before = ["<S-h>"]; commands = ["workbench.action.previousEditor"]; }
{ before = ["<S-l>"]; commands = ["workbench.action.nextEditor"]; }
{ before = ["<leader>" "x"]; commands = ["workbench.action.closeActiveEditor"]; }
{ before = ["<leader>" "X"]; commands = ["workbench.action.closeOtherEditors"]; }
{ before = ["<leader>" "t"]; commands = ["workbench.action.quickOpen"]; }
{ before = ["<leader>" "g"]; commands = ["workbench.action.findInFiles"]; }
];
};
cliConfig = {};
in
{
config = {
home.file."${configDir}/settings.json" = {
text = builtins.toJSON ideSettings;
};
home.file.".cursor/cli-config.json" = {
text = builtins.toJSON cliConfig;
};
home.activation.installCursorExtensions = config.lib.dag.entryAfter ["writeBoundary"] ''
if command -v ${cursorCmd} &> /dev/null; then
run ${cursorCmd} --install-extension vscodevim.vim 2>/dev/null || true
run ${cursorCmd} --install-extension jdinhlife.gruvbox 2>/dev/null || true
run ${cursorCmd} --install-extension jnoortheen.nix-ide 2>/dev/null || true
fi
'';
};
}

View file

@ -14,6 +14,7 @@
]; ];
casks = [ casks = [
# GUI applications - manually installed apps now managed by Homebrew # GUI applications - manually installed apps now managed by Homebrew
"cursor"
"keepassxc" "keepassxc"
"keycastr" "keycastr"
"inkscape" "inkscape"
@ -22,7 +23,6 @@
"obsidian" "obsidian"
"snipaste" "snipaste"
"ghostty" "ghostty"
"textmate"
"slidepilot" "slidepilot"
"tencent-meeting" "tencent-meeting"
"ovito" "ovito"