diff --git a/flake.nix b/flake.nix index f40e4fe..e859b60 100644 --- a/flake.nix +++ b/flake.nix @@ -255,6 +255,7 @@ gitsigns-nvim = { }; neoformat = { }; hop-nvim = { }; + telescope-nvim = { }; }; plugins = with prev.nix2lua.lib; { diff --git a/modules/telescope-nvim.nix b/modules/telescope-nvim.nix new file mode 100644 index 0000000..a85af5a --- /dev/null +++ b/modules/telescope-nvim.nix @@ -0,0 +1,34 @@ +{ nix2lua, vim, ... }: + +with nix2lua.lib; + +let + defaultKeymaps = [ + { mode = "n"; bind = "ff"; command = "Telescope find_files hidden=true"; } + { mode = "n"; bind = "fb"; command = "Telescope buffers"; } + { mode = "n"; bind = "fh"; command = "Telescope help_tags"; } + + { mode = "n"; bind = "fg"; command = lambda0 (call0 "telescope.extensions.live_grep_args.live_grep_args"); } + ]; +in + + +{ configs ? { } +, keymaps ? defaultKeymaps +, extraKeymaps ? [ ] + # TODO: add possibility to configure extensions +}: + +{ + # telescope requirements + plenary-nvim = true; + + # telescope extension + telescope-live-grep-args-nvim = true; + + telescope-nvim = [ + (local (set "telescope" (require "telescope"))) + (pipe1 (var "telescope") (call "setup" configs)) + (pipe1 (var "telescope") (call "load_extension" "live_grep_args")) + ] ++ map vim.keymap.set (keymaps ++ extraKeymaps); +}