From 293a087289b494d4c6076f9ccc431b049fa27524 Mon Sep 17 00:00:00 2001 From: Francis Hamel <36383308+francishamel@users.noreply.github.com> Date: Sat, 21 Dec 2024 14:25:35 -0500 Subject: [PATCH] Fzf improvements (#348) * Remove unnecessary ignored file * Use proper option for setting color scheme * Enable zsh integration for fzf * Improve commands/options used by fzf * Enable fd * Enable jq Also setup jqp which is a jq playground. * Fix fzf-tab height * Add keybinding to open fzf selected files in hx --- .gitignore | 1 - home-manager/flake-module.nix | 2 ++ home-manager/modules/fd.nix | 5 ++++ home-manager/modules/fzf.nix | 51 +++++++++++++++++++++++++++++------ home-manager/modules/jq.nix | 12 +++++++++ 5 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 home-manager/modules/fd.nix create mode 100644 home-manager/modules/jq.nix diff --git a/.gitignore b/.gitignore index 2bbdbfe..92b2793 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ .direnv -result diff --git a/home-manager/flake-module.nix b/home-manager/flake-module.nix index 851a270..906fbe6 100644 --- a/home-manager/flake-module.nix +++ b/home-manager/flake-module.nix @@ -9,11 +9,13 @@ ./modules/bat.nix ./modules/direnv.nix ./modules/eza.nix + ./modules/fd.nix ./modules/fonts.nix ./modules/fzf.nix ./modules/git.nix ./modules/gui.nix ./modules/helix.nix + ./modules/jq.nix ./modules/pet.nix ./modules/ripgrep.nix ./modules/ssh.nix diff --git a/home-manager/modules/fd.nix b/home-manager/modules/fd.nix new file mode 100644 index 0000000..1d9a6bb --- /dev/null +++ b/home-manager/modules/fd.nix @@ -0,0 +1,5 @@ +{ ... }: + +{ + programs.fd.enable = true; +} diff --git a/home-manager/modules/fzf.nix b/home-manager/modules/fzf.nix index b2209fd..52c3574 100644 --- a/home-manager/modules/fzf.nix +++ b/home-manager/modules/fzf.nix @@ -1,15 +1,50 @@ -{ pkgs, ... }: - +{ config, pkgs, lib, ... }: +let + fd = "${config.programs.fd.package}/bin/fd"; + fileCommand = "${fd} --type=file"; + openWithHx = '' + fzf_with_hx() { + ${config.programs.fzf.package}/bin/fzf --multi --bind 'enter:become(${config.programs.helix.package}/bin/hx {+})' + } + bindkey -s '^o' 'fzf_with_hx\n' + ''; +in { - home = { - packages = [ pkgs.zsh-fzf-tab ]; - sessionVariables.FZF_DEFAULT_OPTS = "--color=bg+:#3B4252,bg:#2E3440,spinner:#81A1C1,hl:#616E88,fg:#D8DEE9,header:#616E88,info:#81A1C1,pointer:#81A1C1,marker:#81A1C1,fg+:#D8DEE9,prompt:#81A1C1,hl+:#81A1C1"; - }; + home.packages = [ pkgs.zsh-fzf-tab ]; programs = { - fzf.enable = true; + fzf = { + enable = true; + enableZshIntegration = true; + colors = { + "bg+" = "#3B4252"; + "bg" = "#2E3440"; + "spinner" = "#81A1C1"; + "hl" = "#616E88"; + "fg" = "#D8DEE9"; + "header" = "#616E88"; + "info" = "#81A1C1"; + "pointer" = "#81A1C1"; + "marker" = "#81A1C1"; + "fg+" = "#D8DEE9"; + "prompt" = "#81A1C1"; + "hl+" = "#81A1C1"; + }; + defaultCommand = fileCommand; + defaultOptions = [ + "--height=40%" + "--layout=reverse" + "--info=inline" + "--border" + "--margin=1" + "--padding=1" + ]; + fileWidgetCommand = fileCommand; + changeDirWidgetCommand = "${fd} --type=directory"; + }; zsh.initExtra = '' source ${pkgs.zsh-fzf-tab}/share/fzf-tab/fzf-tab.plugin.zsh - ''; + zstyle ':fzf-tab:*' fzf-flags --height=40% + '' + lib.optionalString (config.programs.helix.enable) openWithHx; }; } diff --git a/home-manager/modules/jq.nix b/home-manager/modules/jq.nix new file mode 100644 index 0000000..ed67823 --- /dev/null +++ b/home-manager/modules/jq.nix @@ -0,0 +1,12 @@ +{ pkgs, ... }: + +{ + home.packages = [ + pkgs.jqp + ]; + + programs = { + jq.enable = true; + zsh.shellAliases.jqp = "jqp --theme nord"; + }; +}