Skip to content

Commit

Permalink
Fzf improvements (#348)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
francishamel authored Dec 21, 2024
1 parent c5d81a1 commit 293a087
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 9 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
.direnv
result
2 changes: 2 additions & 0 deletions home-manager/flake-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions home-manager/modules/fd.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ ... }:

{
programs.fd.enable = true;
}
51 changes: 43 additions & 8 deletions home-manager/modules/fzf.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}
12 changes: 12 additions & 0 deletions home-manager/modules/jq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{ pkgs, ... }:

{
home.packages = [
pkgs.jqp
];

programs = {
jq.enable = true;
zsh.shellAliases.jqp = "jqp --theme nord";
};
}

0 comments on commit 293a087

Please sign in to comment.