From 4e8ec4cd5b5fd83358ef5635b73a07037f25cd66 Mon Sep 17 00:00:00 2001 From: Frothy <76622149+FrothyMarrow@users.noreply.github.com> Date: Mon, 19 Feb 2024 17:39:43 -0500 Subject: [PATCH] utility/telescope: provide configurable vimgrep options --- modules/utility/telescope/config.nix | 15 +++------------ modules/utility/telescope/telescope.nix | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/modules/utility/telescope/config.nix b/modules/utility/telescope/config.nix index 53cde96..2431423 100644 --- a/modules/utility/telescope/config.nix +++ b/modules/utility/telescope/config.nix @@ -5,9 +5,10 @@ ... }: let inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim; + inherit (nvim.lua) listToLuaTable; cfg = config.vim.telescope; - self = import ./telescope.nix {inherit lib;}; + self = import ./telescope.nix {inherit pkgs lib;}; mappingDefinitions = self.options.vim.telescope.mappings; mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions; @@ -56,17 +57,7 @@ in { local telescope = require('telescope') telescope.setup { defaults = { - vimgrep_arguments = { - "${pkgs.ripgrep}/bin/rg", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - "--hidden", - "--no-ignore", - }, + vimgrep_arguments = ${listToLuaTable cfg.vimgrep_arguments}, pickers = { find_command = { "${pkgs.fd}/bin/fd", diff --git a/modules/utility/telescope/telescope.nix b/modules/utility/telescope/telescope.nix index 12ea887..9cfd092 100644 --- a/modules/utility/telescope/telescope.nix +++ b/modules/utility/telescope/telescope.nix @@ -1,5 +1,9 @@ -{lib, ...}: let - inherit (lib) mkMappingOption mkEnableOption; +{ + pkgs, + lib, + ... +}: let + inherit (lib) mkMappingOption mkEnableOption mkOption types; in { options.vim.telescope = { mappings = { @@ -29,5 +33,21 @@ in { }; enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility"; + + vimgrep_arguments = mkOption { + description = "Arguments to use for the grep command"; + type = types.listOf types.str; + default = [ + "${pkgs.ripgrep}/bin/rg" + "--color=never" + "--no-heading" + "--with-filename" + "--line-number" + "--column" + "--smart-case" + "--hidden" + "--no-ignore" + ]; + }; }; }