From 6f512840395fa404385aadacf560f52ef152479a Mon Sep 17 00:00:00 2001
From: tv <tv@krebsco.de>
Date: Thu, 15 Nov 2018 10:43:28 +0100
Subject: [PATCH] tv vim: add fzf

---
 tv/2configs/vim.nix | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tv/2configs/vim.nix b/tv/2configs/vim.nix
index 2ac7f7518..544fe94ae 100644
--- a/tv/2configs/vim.nix
+++ b/tv/2configs/vim.nix
@@ -14,6 +14,16 @@ let {
   };
 
   extra-runtimepath = concatMapStringsSep "," (pkg: "${pkg.rtp}") [
+    # cannot use pkgs.vimPlugins.fzf-vim as it's missing :Rg
+    (pkgs.vimUtils.buildVimPlugin {
+      name = "junegunn";
+      src = pkgs.fetchgit {
+        url = git://github.com/junegunn/fzf.vim;
+        rev = "ad1833ecbc9153b6e34a4292dc089a58c4bcb8dc";
+        sha256 = "1z2q71q6l9hq9fqfqpj1svhyk4yk1bzw1ljhksx4bnpz8gkfbx2m";
+      };
+    })
+    pkgs.vimPlugins.fzfWrapper
     pkgs.vimPlugins.undotree
     pkgs.vimPlugins.vim-elixir
     (pkgs.vimUtils.buildVimPlugin {
@@ -309,6 +319,11 @@ let {
     paths = [
       (pkgs.writeDashBin "vim" ''
         set -efu
+        export FZF_DEFAULT_COMMAND='${pkgs.ripgrep}/bin/rg --files'
+        export PATH=$PATH:${makeBinPath [
+          pkgs.fzf
+          pkgs.ripgrep
+        ]}
         (umask 0077; exec ${pkgs.coreutils}/bin/mkdir -p ${toString need-dirs})
         exec ${pkgs.vim}/bin/vim "$@"
       '')
@@ -385,5 +400,9 @@ let {
     noremap <esc>[c <nop> | noremap! <esc>[c <nop>
     noremap <esc>[d <nop> | noremap! <esc>[d <nop>
     vnoremap u <nop>
+
+    " fzf
+    nnoremap <esc>q :Files<cr>
+    nnoremap <esc>w :Rg<cr>
   '';
 }