Skip to content

Commit

Permalink
feat(telescope): add custom setup options
Browse files Browse the repository at this point in the history
  • Loading branch information
horriblename committed Jan 2, 2024
1 parent 8fe23c0 commit 9f8626d
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 49 deletions.
49 changes: 2 additions & 47 deletions modules/utility/telescope/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim;

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;
Expand Down Expand Up @@ -54,52 +54,7 @@ in {

vim.luaConfigRC.telescope = nvim.dag.entryAnywhere ''
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",
},
pickers = {
find_command = {
"${pkgs.fd}/bin/fd",
},
},
},
prompt_prefix = "  ",
selection_caret = " ",
entry_prefix = " ",
initial_mode = "insert",
selection_strategy = "reset",
sorting_strategy = "ascending",
layout_strategy = "horizontal",
layout_config = {
horizontal = {
prompt_position = "top",
preview_width = 0.55,
results_width = 0.8,
},
vertical = {
mirror = false,
},
width = 0.8,
height = 0.8,
preview_cutoff = 120,
},
file_ignore_patterns = { "node_modules", ".git/", "dist/", "build/", "target/", "result/" }, -- TODO: make this configurable
color_devicons = true,
path_display = { "absolute" },
set_env = { ["COLORTERM"] = "truecolor" },
winblend = 0,
border = {},
}
telescope.setup(${nvim.lua.toLuaObject cfg.setupOpts})
${
if config.vim.ui.noice.enable
Expand Down
60 changes: 58 additions & 2 deletions modules/utility/telescope/telescope.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,59 @@
{lib, ...}: let
inherit (lib) mkMappingOption mkEnableOption;
{
pkgs,
lib,
...
}: let
inherit (lib) mkMappingOption mkEnableOption types mkOption nvim;
mkOptOfType = type: default:
mkOption {
# TODO: description
description = "See plugin docs for more info";
inherit type default;
};

setupOptions = {
defaults = {
vimgrep_arguments = mkOptOfType (with types; listOf str) [
"${pkgs.ripgrep}/bin/rg"
"--color=never"
"--no-heading"
"--with-filename"
"--line-number"
"--column"
"--smart-case"
"--hidden"
"--no-ignore"
];
pickers.find_command = mkOptOfType (with types; listOf str) ["${pkgs.fd}/bin/fd"];
prompt_prefix = mkOptOfType types.str "  ";
selection_caret = mkOptOfType types.str " ";
entry_prefix = mkOptOfType types.str " ";
initial_mode = mkOptOfType types.str "insert";
selection_strategy = mkOptOfType types.str "reset";
sorting_strategy = mkOptOfType types.str "ascending";
layout_strategy = mkOptOfType types.str "horizontal";
layout_config = {
horizontal = {
prompt_position = mkOptOfType types.str "top";
preview_width = mkOptOfType types.float 0.55;
results_width = mkOptOfType types.float 0.8;
};
vertical = {
mirror = mkOptOfType types.bool false;
};
width = mkOptOfType types.float 0.8;
height = mkOptOfType types.float 0.8;
preview_cutoff = mkOptOfType types.int 120;
};
file_ignore_patterns = mkOptOfType (types.listOf types.str) ["node_modules" ".git/" "dist/" "build/" "target/" "result/"];
color_devicons = mkOptOfType types.bool true;
path_display = mkOptOfType (types.listOf types.str) ["absolute"];
set_env = {
COLORTERM = mkOptOfType types.str "truecolor";
};
winblend = mkOptOfType types.int 0;
};
};
in {
options.vim.telescope = {
mappings = {
Expand Down Expand Up @@ -29,5 +83,7 @@ in {
};

enable = mkEnableOption "telescope.nvim: multi-purpose search and picker utility";

setupOpts = nvim.types.mkPluginSetupOption "Telescope" setupOptions;
};
}

0 comments on commit 9f8626d

Please sign in to comment.