Skip to content

Commit

Permalink
neovim: Fix telescope's config
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusauler committed Apr 13, 2024
1 parent a31b899 commit ba90aad
Showing 1 changed file with 37 additions and 23 deletions.
60 changes: 37 additions & 23 deletions hm-modules/common/neovim/plugins/telescope.nix
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
{ config, lib, pkgs, ... }:
{ config, lib, nixpkgs-channel, pkgs, ... }:

let
cfg = config.modules.neovim;
cfg-plug = config.programs.nixvim.plugins;

keymaps = {
"<leader>ff" = { action = "find_files"; options.desc = "Telescope: Find files"; };
"<leader>fg" = { action = "live_grep"; options.desc = "Telescope: Live grep"; };
"<leader>fb" = { action = "buffers"; options.desc = "Telescope: Buffers"; };
"<leader>fh" = { action = "help_tags"; options.desc = "Telescope: Help tags"; };
};

settings = {
# FIXME: Use mkRaw helper once I figure out how to get helpers working
defaults.vimgrep_arguments.__raw = /* lua */ ''
(function()
local telescopeConfig = require("telescope.config")
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
table.insert(vimgrep_arguments, "--hidden")
table.insert(vimgrep_arguments, "--glob")
table.insert(vimgrep_arguments, "!**/.git/*")
return vimgrep_arguments
end)()
'';

pickers.find_files.find_command = [ "rg" "--files" "--hidden" "--glob" "!**/.git/*" ];
};
in
lib.mkIf cfg.enable {
programs.nixvim = {
extraPackages = lib.optional cfg-plug.telescope.enable pkgs.fd;
extraPackages = lib.optionals cfg-plug.telescope.enable [ pkgs.fd pkgs.ripgrep ];

plugins.telescope = {
keymaps = {
"<leader>ff" = { action = "find_files"; desc = "Telescope: Find files"; };
"<leader>fg" = { action = "live_grep"; desc = "Telescope: Live grep"; };
"<leader>fb" = { action = "buffers"; desc = "Telescope: Buffers"; };
"<leader>fh" = { action = "help_tags"; desc = "Telescope: Help tags"; };
};

# FIXME: Use mkRaw helper once I figure out how to get helpers working
defaults.vimgrep_arguments.__raw = /* lua */ ''
(function()
local telescopeConfig = require("telescope.config")
local vimgrep_arguments = { unpack(telescopeConfig.values.vimgrep_arguments) }
table.insert(vimgrep_arguments, "--hidden")
table.insert(vimgrep_arguments, "--glob")
table.insert(vimgrep_arguments, "!**/.git/*")
return vimgrep_arguments
end)()
'';

extraOptions.pickers.find_files.find_command = [ "rg" "--files" "--hidden" "--glob" "!**/.git/*" ];
};
keymaps = lib.mapAttrs
(_: value:
if nixpkgs-channel == "stable" then
{ inherit (value) action; } // value.options
else
value
)
keymaps;
} // (if nixpkgs-channel == "stable" then {
inherit (settings) defaults;
extraOptions = { inherit (settings) pickers; };
} else { inherit settings; });
};
}

0 comments on commit ba90aad

Please sign in to comment.