Skip to content

Commit 57446f7

Browse files
authored
Merge pull request #232 from FrothyMarrow/telescope-grep-opts
utility/telescope: provide configurable vimgrep options
2 parents f7bd0ff + 4e8ec4c commit 57446f7

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

modules/utility/telescope/config.nix

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
...
66
}: let
77
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim;
8+
inherit (nvim.lua) listToLuaTable;
89

910
cfg = config.vim.telescope;
10-
self = import ./telescope.nix {inherit lib;};
11+
self = import ./telescope.nix {inherit pkgs lib;};
1112
mappingDefinitions = self.options.vim.telescope.mappings;
1213

1314
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
@@ -56,17 +57,7 @@ in {
5657
local telescope = require('telescope')
5758
telescope.setup {
5859
defaults = {
59-
vimgrep_arguments = {
60-
"${pkgs.ripgrep}/bin/rg",
61-
"--color=never",
62-
"--no-heading",
63-
"--with-filename",
64-
"--line-number",
65-
"--column",
66-
"--smart-case",
67-
"--hidden",
68-
"--no-ignore",
69-
},
60+
vimgrep_arguments = ${listToLuaTable cfg.vimgrep_arguments},
7061
pickers = {
7162
find_command = {
7263
"${pkgs.fd}/bin/fd",

modules/utility/telescope/telescope.nix

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
{lib, ...}: let
2-
inherit (lib) mkMappingOption mkEnableOption;
1+
{
2+
pkgs,
3+
lib,
4+
...
5+
}: let
6+
inherit (lib) mkMappingOption mkEnableOption mkOption types;
37
in {
48
options.vim.telescope = {
59
mappings = {
@@ -29,5 +33,21 @@ in {
2933
};
3034

3135
enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility";
36+
37+
vimgrep_arguments = mkOption {
38+
description = "Arguments to use for the grep command";
39+
type = types.listOf types.str;
40+
default = [
41+
"${pkgs.ripgrep}/bin/rg"
42+
"--color=never"
43+
"--no-heading"
44+
"--with-filename"
45+
"--line-number"
46+
"--column"
47+
"--smart-case"
48+
"--hidden"
49+
"--no-ignore"
50+
];
51+
};
3252
};
3353
}

0 commit comments

Comments
 (0)