diff --git a/platforms/home-manager/modules/nmasur/presets/programs/fzf/default.nix b/platforms/home-manager/modules/nmasur/presets/programs/fzf/default.nix index b61530d..f9d0c49 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/fzf/default.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/fzf/default.nix @@ -25,7 +25,13 @@ in functions = { edit = { description = "Open a file in Vim"; - body = builtins.readFile ./fish/edit.fish; + body = # fish + '' + set vimfile (fzf) + and set vimfile (echo $vimfile | tr -d '\r') + and commandline -r "${builtins.baseNameOf config.home.sessionVariables.EDITOR} \"$vimfile\"" + and commandline -f execute + ''; }; fcd = { description = "Jump to directory"; @@ -51,11 +57,40 @@ in }; recent = { description = "Open a recent file in Vim"; - body = builtins.readFile ./fish/recent.fish; + body = # fish + '' + set vimfile (fd -t f --exec /usr/bin/stat -f "%m%t%N" | sort -nr | cut -f2 | fzf) + and set vimfile (echo $vimfile | tr -d '\r') + and commandline -r "${builtins.baseNameOf config.home.sessionVariables.EDITOR} $vimfile" + and commandline -f execute + ''; }; search-and-edit = { description = "Search and open the relevant file in Vim"; - body = builtins.readFile ./fish/search-and-edit.fish; + body = # fish + '' + set vimfile ( \ + rg \ + --color=always \ + --line-number \ + --no-heading \ + --smart-case \ + --iglob "!/Library/**" \ + --iglob "!/System/**" \ + --iglob "!Users/$HOME/Library/*" \ + ".*" \ + | fzf --ansi \ + --height "80%" \ + --color "hl:-1:underline,hl+:-1:underline:reverse" \ + --delimiter : \ + --preview 'bat --color=always {1} --highlight-line {2}' \ + --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' + ) + and set line_number (echo $vimfile | tr -d '\r' | cut -d':' -f2) + and set vimfile (echo $vimfile | tr -d '\r' | cut -d':' -f1) + and commandline -r "${builtins.baseNameOf config.home.sessionVariables.EDITOR} +$line_number \"$vimfile\"" + and commandline -f execute + ''; }; }; shellAbbrs = { diff --git a/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/edit.fish b/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/edit.fish deleted file mode 100644 index 87ff52f..0000000 --- a/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/edit.fish +++ /dev/null @@ -1,4 +0,0 @@ -set vimfile (fzf) -and set vimfile (echo $vimfile | tr -d '\r') -and commandline -r "vim \"$vimfile\"" -and commandline -f execute diff --git a/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/recent.fish b/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/recent.fish deleted file mode 100644 index 622a2b5..0000000 --- a/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/recent.fish +++ /dev/null @@ -1,4 +0,0 @@ -set vimfile (fd -t f --exec /usr/bin/stat -f "%m%t%N" | sort -nr | cut -f2 | fzf) -and set vimfile (echo $vimfile | tr -d '\r') -and commandline -r "vim $vimfile" -and commandline -f execute diff --git a/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/search-and-edit.fish b/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/search-and-edit.fish deleted file mode 100644 index b5fd858..0000000 --- a/platforms/home-manager/modules/nmasur/presets/programs/fzf/fish/search-and-edit.fish +++ /dev/null @@ -1,21 +0,0 @@ -set vimfile ( \ - rg \ - --color=always \ - --line-number \ - --no-heading \ - --smart-case \ - --iglob "!/Library/**" \ - --iglob "!/System/**" \ - --iglob "!Users/$HOME/Library/*" \ - ".*" \ - | fzf --ansi \ - --height "80%" \ - --color "hl:-1:underline,hl+:-1:underline:reverse" \ - --delimiter : \ - --preview 'bat --color=always {1} --highlight-line {2}' \ - --preview-window 'up,60%,border-bottom,+{2}+3/3,~3' -) -and set line_number (echo $vimfile | tr -d '\r' | cut -d':' -f2) -and set vimfile (echo $vimfile | tr -d '\r' | cut -d':' -f1) -and commandline -r "vim +$line_number \"$vimfile\"" -and commandline -f execute diff --git a/platforms/home-manager/modules/nmasur/presets/programs/helix.nix b/platforms/home-manager/modules/nmasur/presets/programs/helix.nix index 25e4008..ec8b8de 100644 --- a/platforms/home-manager/modules/nmasur/presets/programs/helix.nix +++ b/platforms/home-manager/modules/nmasur/presets/programs/helix.nix @@ -15,6 +15,15 @@ in config = lib.mkIf cfg.enable { + # Use Neovim as the editor for git commit messages + programs.git.extraConfig.core.editor = lib.mkForce "${lib.getExe pkgs.helix}"; + programs.jujutsu.settings.ui.editor = lib.mkForce "${lib.getExe pkgs.helix}"; + + # Set Neovim as the default app for text editing and manual pages + home.sessionVariables = { + EDITOR = lib.mkForce "${lib.getExe pkgs.helix}"; + }; + programs.helix = { enable = true;