plugins/telescope: migrate helpers -> lib.nixvim

This commit is contained in:
Austin Horstman 2024-08-22 00:00:55 -05:00
parent d7b506efdd
commit 83c2844bec
No known key found for this signature in database
9 changed files with 390 additions and 441 deletions

View file

@ -1,13 +1,15 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim) keymaps mkNullOrOption toLuaObject;
in
# TODO:add support for additional filetypes. This requires autocommands!
helpers.neovim-plugin.mkNeovimPlugin config {
lib.nixvim.neovim-plugin.mkNeovimPlugin config {
name = "telescope";
originalName = "telescope.nvim";
defaultPackage = pkgs.vimPlugins.telescope-nvim;
@ -45,8 +47,8 @@ helpers.neovim-plugin.mkNeovimPlugin config {
type = types.str;
description = "The telescope action to run.";
};
mode = helpers.keymaps.mkModeOption "n";
options = helpers.keymaps.mapConfigOptions;
mode = keymaps.mkModeOption "n";
options = keymaps.mapConfigOptions;
};
})
);
@ -105,9 +107,9 @@ helpers.neovim-plugin.mkNeovimPlugin config {
) cfg.keymaps;
extraConfigLua = ''
require('telescope').setup(${helpers.toLuaObject cfg.settings})
require('telescope').setup(${toLuaObject cfg.settings})
local __telescopeExtensions = ${helpers.toLuaObject cfg.enabledExtensions}
local __telescopeExtensions = ${toLuaObject cfg.enabledExtensions}
for i, extension in ipairs(__telescopeExtensions) do
require('telescope').load_extension(extension)
end
@ -118,11 +120,11 @@ helpers.neovim-plugin.mkNeovimPlugin config {
};
settingsOptions = {
defaults = helpers.mkNullOrOption (with types; attrsOf anything) ''
defaults = mkNullOrOption (with types; attrsOf anything) ''
Default configuration for telescope.
'';
pickers = helpers.mkNullOrOption (with types; attrsOf anything) ''
pickers = mkNullOrOption (with types; attrsOf anything) ''
Default configuration for builtin pickers.
'';

View file

@ -1,10 +1,8 @@
{
lib,
config,
helpers,
...
}:
{ lib, config, ... }:
with lib;
let
inherit (lib.nixvim) mkPluginPackageOption mkSettingsOption toSnakeCase;
in
rec {
mkExtension =
{
@ -36,7 +34,7 @@ rec {
let
optionPath = if isString option then [ option ] else option; # option is already a path (i.e. a list)
optionPathSnakeCase = map helpers.toSnakeCase optionPath;
optionPathSnakeCase = map toSnakeCase optionPath;
in
mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
) optionsRenamedToSettings);
@ -44,9 +42,9 @@ rec {
options.plugins.telescope.extensions.${name} = {
enable = mkEnableOption "the `${name}` telescope extension";
package = helpers.mkPluginPackageOption name defaultPackage;
package = mkPluginPackageOption name defaultPackage;
settings = helpers.mkSettingsOption {
settings = mkSettingsOption {
description = "settings for the `${name}` telescope extension.";
options = settingsOptions;
example = settingsExample;
@ -73,7 +71,7 @@ rec {
mkModeMappingsOption =
mode: defaults:
mkOption {
type = with helpers.nixvimTypes; attrsOf strLuaFn;
type = with types; attrsOf strLuaFn;
default = { };
description = ''
Keymaps in ${mode} mode.
@ -83,7 +81,7 @@ rec {
${defaults}
```
'';
apply = mapAttrs (_: helpers.mkRaw);
apply = mapAttrs (_: mkRaw);
};
mkMappingsOption =

View file

@ -1,20 +1,13 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
telescopeHelpers = import ./_helpers.nix {
inherit
lib
helpers
config
pkgs
;
};
telescopeHelpers = import ./_helpers.nix { inherit lib config pkgs; };
inherit (lib.nixvim) defaultNullOpts mkNullOrStr;
in
telescopeHelpers.mkExtension {
name = "file-browser";
@ -79,58 +72,58 @@ telescopeHelpers.mkExtension {
];
settingsOptions = {
theme = helpers.mkNullOrStr ''
theme = mkNullOrStr ''
Custom theme, will use your global theme by default.
'';
path = helpers.defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } ''
path = defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } ''
Directory to browse files from.
`vim.fn.expanded` automatically.
'';
cwd = helpers.defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } ''
cwd = defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } ''
Directory to browse folders from.
`vim.fn.expanded` automatically.
'';
cwd_to_path = helpers.defaultNullOpts.mkBool false ''
cwd_to_path = defaultNullOpts.mkBool false ''
Whether folder browser is launched from `path` rather than `cwd`.
'';
grouped = helpers.defaultNullOpts.mkBool false ''
grouped = defaultNullOpts.mkBool false ''
Group initial sorting by directories and then files.
'';
files = helpers.defaultNullOpts.mkBool true ''
files = defaultNullOpts.mkBool true ''
Start in file (true) or folder (false) browser.
'';
add_dirs = helpers.defaultNullOpts.mkBool true ''
add_dirs = defaultNullOpts.mkBool true ''
Whether the file browser shows folders.
'';
depth = helpers.defaultNullOpts.mkUnsignedInt 1 ''
depth = defaultNullOpts.mkUnsignedInt 1 ''
File tree depth to display, `false` for unlimited depth.
'';
auto_depth = helpers.defaultNullOpts.mkBool false ''
auto_depth = defaultNullOpts.mkBool false ''
Unlimit or set `depth` to `auto_depth` & unset grouped on prompt for file_browser.
'';
select_buffer = helpers.defaultNullOpts.mkBool false ''
select_buffer = defaultNullOpts.mkBool false ''
Select current buffer if possible.
May imply `hidden=true`.
'';
hidden =
helpers.defaultNullOpts.mkNullable
defaultNullOpts.mkNullable
(
with types;
either bool (submodule {
options = {
file_browser = helpers.defaultNullOpts.mkBool false "";
file_browser = defaultNullOpts.mkBool false "";
folder_browser = helpers.defaultNullOpts.mkBool false "";
folder_browser = defaultNullOpts.mkBool false "";
};
})
)
@ -140,53 +133,53 @@ telescopeHelpers.mkExtension {
}
"Determines whether to show hidden files or not.";
respect_gitignore = helpers.defaultNullOpts.mkBool false ''
respect_gitignore = defaultNullOpts.mkBool false ''
Induces slow-down w/ plenary finder (true if `fd` available).
'';
browse_files = helpers.defaultNullOpts.mkLuaFn "require('telescope._extensions.file_browser.finders').browse_files" "A custom lua function to override for the file browser.";
browse_files = defaultNullOpts.mkLuaFn "require('telescope._extensions.file_browser.finders').browse_files" "A custom lua function to override for the file browser.";
browse_folders = helpers.defaultNullOpts.mkLuaFn "require('telescope._extensions.file_browser.finders').browse_folders" "A custom lua function to override for the folder browser.";
browse_folders = defaultNullOpts.mkLuaFn "require('telescope._extensions.file_browser.finders').browse_folders" "A custom lua function to override for the folder browser.";
hide_parent_dir = helpers.defaultNullOpts.mkBool false ''
hide_parent_dir = defaultNullOpts.mkBool false ''
Hide `../` in the file browser.
'';
collapse_dirs = helpers.defaultNullOpts.mkBool false ''
collapse_dirs = defaultNullOpts.mkBool false ''
Skip with only a single (possibly hidden) sub-dir in file_browser.
'';
quiet = helpers.defaultNullOpts.mkBool false ''
quiet = defaultNullOpts.mkBool false ''
Suppress any notification from file_browser actions.
'';
dir_icon = helpers.defaultNullOpts.mkStr "" ''
dir_icon = defaultNullOpts.mkStr "" ''
Change the icon for a directory.
'';
dir_icon_hl = helpers.defaultNullOpts.mkStr "Default" ''
dir_icon_hl = defaultNullOpts.mkStr "Default" ''
Change the highlight group of dir icon.
'';
display_stat = helpers.defaultNullOpts.mkAttrsOf types.anything {
display_stat = defaultNullOpts.mkAttrsOf types.anything {
date = true;
size = true;
mode = true;
} "Ordered stat; see upstream for more info.";
hijack_netrw = helpers.defaultNullOpts.mkBool false ''
hijack_netrw = defaultNullOpts.mkBool false ''
Use telescope file browser when opening directory paths.
'';
use_fd = helpers.defaultNullOpts.mkBool true ''
use_fd = defaultNullOpts.mkBool true ''
Use `fd` if available over `plenary.scandir`.
'';
git_status = helpers.defaultNullOpts.mkBool true ''
git_status = defaultNullOpts.mkBool true ''
Show the git status of files (true if `git` is found).
'';
prompt_path = helpers.defaultNullOpts.mkBool false ''
prompt_path = defaultNullOpts.mkBool false ''
Show the current relative path from cwd as the prompt prefix.
'';

View file

@ -1,164 +1,154 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
(import ./_helpers.nix {
inherit
lib
helpers
config
pkgs
;
}).mkExtension
{
name = "frecency";
defaultPackage = pkgs.vimPlugins.telescope-frecency-nvim;
let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption mkNullOrStr;
in
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
name = "frecency";
defaultPackage = pkgs.vimPlugins.telescope-frecency-nvim;
# TODO: introduced 2024-03-24, remove on 2024-05-24
optionsRenamedToSettings = [
"dbRoot"
"defaultWorkspace"
"ignorePatterns"
"showScores"
"workspaces"
# TODO: introduced 2024-03-24, remove on 2024-05-24
optionsRenamedToSettings = [
"dbRoot"
"defaultWorkspace"
"ignorePatterns"
"showScores"
"workspaces"
];
imports =
let
basePluginPath = [
"plugins"
"telescope"
"extensions"
"frecency"
];
in
[
(mkRemovedOptionModule (
basePluginPath ++ [ "showUnindexed" ]
) "This option has been removed upstream.")
(mkRemovedOptionModule (
basePluginPath ++ [ "deviconsDisabled" ]
) "This option has been removed upstream.")
];
imports =
let
basePluginPath = [
"plugins"
"telescope"
"extensions"
"frecency"
];
in
[
(mkRemovedOptionModule (
basePluginPath ++ [ "showUnindexed" ]
) "This option has been removed upstream.")
(mkRemovedOptionModule (
basePluginPath ++ [ "deviconsDisabled" ]
) "This option has been removed upstream.")
];
settingsOptions = {
auto_validate = helpers.defaultNullOpts.mkBool true ''
If true, it removes stale entries count over than `db_validate_threshold`.
'';
settingsOptions = {
auto_validate = defaultNullOpts.mkBool true ''
If true, it removes stale entries count over than `db_validate_threshold`.
'';
db_root = helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data'"; } ''
Path to parent directory of custom database location.
Defaults to `$XDG_DATA_HOME/nvim` if unset.
'';
db_root = defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data'"; } ''
Path to parent directory of custom database location.
Defaults to `$XDG_DATA_HOME/nvim` if unset.
'';
db_safe_mode = helpers.defaultNullOpts.mkBool true ''
If true, it shows confirmation dialog by `vim.ui.select()` before validating DB.
'';
db_safe_mode = defaultNullOpts.mkBool true ''
If true, it shows confirmation dialog by `vim.ui.select()` before validating DB.
'';
db_validate_threshold = helpers.defaultNullOpts.mkUnsignedInt 10 ''
It will removes over than this count in validating DB.
'';
db_validate_threshold = defaultNullOpts.mkUnsignedInt 10 ''
It will removes over than this count in validating DB.
'';
default_workspace = helpers.mkNullOrStr ''
Default workspace tag to filter by e.g. `'CWD'` to filter by default to the current
directory.
Can be overridden at query time by specifying another filter like `':*:'`.
'';
default_workspace = mkNullOrStr ''
Default workspace tag to filter by e.g. `'CWD'` to filter by default to the current
directory.
Can be overridden at query time by specifying another filter like `':*:'`.
'';
disable_devicons = helpers.defaultNullOpts.mkBool false ''
Disable devicons (if available).
'';
disable_devicons = defaultNullOpts.mkBool false ''
Disable devicons (if available).
'';
hide_current_buffer = helpers.defaultNullOpts.mkBool false ''
If true, it does not show the current buffer in candidates.
'';
hide_current_buffer = defaultNullOpts.mkBool false ''
If true, it does not show the current buffer in candidates.
'';
filter_delimiter = helpers.defaultNullOpts.mkStr ":" ''
Delimiters to indicate the filter like `:CWD:`.
'';
filter_delimiter = defaultNullOpts.mkStr ":" ''
Delimiters to indicate the filter like `:CWD:`.
'';
ignore_patterns =
helpers.defaultNullOpts.mkListOf types.str
[
"*.git/*"
"*/tmp/*"
"term://*"
]
''
Patterns in this table control which files are indexed (and subsequently which you'll see
in the finder results).
'';
ignore_patterns =
defaultNullOpts.mkListOf types.str
[
"*.git/*"
"*/tmp/*"
"term://*"
]
''
Patterns in this table control which files are indexed (and subsequently which you'll see
in the finder results).
'';
max_timestamps = helpers.defaultNullOpts.mkPositiveInt 10 ''
Set the max count of timestamps DB keeps when you open files.
It ignores the value and use `10` if you set less than or equal to `0`.
max_timestamps = defaultNullOpts.mkPositiveInt 10 ''
Set the max count of timestamps DB keeps when you open files.
It ignores the value and use `10` if you set less than or equal to `0`.
CAUTION: When you reduce the value of this option, it removes old timestamps when you open
the file.
It is reasonable to set this value more than or equal to the default value: `10`.
'';
CAUTION: When you reduce the value of this option, it removes old timestamps when you open
the file.
It is reasonable to set this value more than or equal to the default value: `10`.
'';
show_filter_column =
helpers.defaultNullOpts.mkNullable (with types; either bool (listOf str)) true
''
Show the path of the active filter before file paths.
In default, it uses the tail of paths for `'LSP'` and `'CWD'` tags.
You can configure this by setting a table for this option.
'';
show_filter_column = defaultNullOpts.mkNullable (with types; either bool (listOf str)) true ''
Show the path of the active filter before file paths.
In default, it uses the tail of paths for `'LSP'` and `'CWD'` tags.
You can configure this by setting a table for this option.
'';
show_scores = helpers.defaultNullOpts.mkBool false ''
To see the scores generated by the algorithm in the results, set this to true.
'';
show_scores = defaultNullOpts.mkBool false ''
To see the scores generated by the algorithm in the results, set this to true.
'';
show_unindexed = helpers.defaultNullOpts.mkBool true ''
Determines if non-indexed files are included in workspace filter results.
'';
show_unindexed = defaultNullOpts.mkBool true ''
Determines if non-indexed files are included in workspace filter results.
'';
workspace_scan_cmd =
helpers.mkNullOrOption (with helpers.nixvimTypes; either rawLua (listOf str))
''
This option can be set values as `"LUA"|string[]|null`.
With the default value: `null`, it uses these way below to make entries for workspace
files.
It tries in order until it works successfully.
workspace_scan_cmd = mkNullOrOption (with types; either rawLua (listOf str)) ''
This option can be set values as `"LUA"|string[]|null`.
With the default value: `null`, it uses these way below to make entries for workspace
files.
It tries in order until it works successfully.
1. `rg -.g '!.git' --files`
2. `fdfind -Htf`
3. `fd -Htf`
4. Native Lua code (old way)
1. `rg -.g '!.git' --files`
2. `fdfind -Htf`
3. `fd -Htf`
4. Native Lua code (old way)
If you like another commands, set them to this option, like
```nix
workspace_scan_cmd = ["find" "." "-type" "f"];
```
If you like another commands, set them to this option, like
```nix
workspace_scan_cmd = ["find" "." "-type" "f"];
```
If you prefer Native Lua code, set `workspace_scan_cmd.__raw = "LUA"`.
'';
If you prefer Native Lua code, set `workspace_scan_cmd.__raw = "LUA"`.
'';
workspaces = helpers.defaultNullOpts.mkAttrsOf types.str { } ''
This attrs contains mappings of `workspace_tag` -> `workspace_directory`.
The key corresponds to the `:tag_name` used to select the filter in queries.
The value corresponds to the top level directory by which results will be filtered.
'';
workspaces = defaultNullOpts.mkAttrsOf types.str { } ''
This attrs contains mappings of `workspace_tag` -> `workspace_directory`.
The key corresponds to the `:tag_name` used to select the filter in queries.
The value corresponds to the top level directory by which results will be filtered.
'';
};
settingsExample = {
db_root = "/home/my_username/path/to/db_root";
show_scores = false;
show_unindexed = true;
ignore_patterns = [
"*.git/*"
"*/tmp/*"
];
disable_devicons = false;
workspaces = {
conf = "/home/my_username/.config";
data = "/home/my_username/.local/share";
project = "/home/my_username/projects";
wiki = "/home/my_username/wiki";
};
settingsExample = {
db_root = "/home/my_username/path/to/db_root";
show_scores = false;
show_unindexed = true;
ignore_patterns = [
"*.git/*"
"*/tmp/*"
];
disable_devicons = false;
workspaces = {
conf = "/home/my_username/.config";
data = "/home/my_username/.local/share";
project = "/home/my_username/projects";
wiki = "/home/my_username/wiki";
};
};
}
};
}

View file

@ -1,60 +1,54 @@
{
lib,
helpers,
config,
pkgs,
...
}:
(import ./_helpers.nix {
inherit
lib
helpers
config
pkgs
;
}).mkExtension
{
name = "fzf-native";
extensionName = "fzf";
defaultPackage = pkgs.vimPlugins.telescope-fzf-native-nvim;
let
inherit (lib.nixvim) defaultNullOpts;
in
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
name = "fzf-native";
extensionName = "fzf";
defaultPackage = pkgs.vimPlugins.telescope-fzf-native-nvim;
# TODO: introduced 2024-03-24, remove on 2024-05-24
optionsRenamedToSettings = [
"fuzzy"
"overrideGenericSorter"
"overrideFileSorter"
"caseMode"
];
# TODO: introduced 2024-03-24, remove on 2024-05-24
optionsRenamedToSettings = [
"fuzzy"
"overrideGenericSorter"
"overrideFileSorter"
"caseMode"
];
settingsOptions = {
fuzzy = helpers.defaultNullOpts.mkBool true ''
Whether to fuzzy search. False will do exact matching.
'';
settingsOptions = {
fuzzy = defaultNullOpts.mkBool true ''
Whether to fuzzy search. False will do exact matching.
'';
override_generic_sorter = helpers.defaultNullOpts.mkBool true ''
Override the generic sorter.
'';
override_generic_sorter = defaultNullOpts.mkBool true ''
Override the generic sorter.
'';
override_file_sorter = helpers.defaultNullOpts.mkBool true ''
Override the file sorter.
'';
override_file_sorter = defaultNullOpts.mkBool true ''
Override the file sorter.
'';
case_mode = helpers.defaultNullOpts.mkEnumFirstDefault [
"smart_case"
"ignore_case"
"respect_case"
] "Case mode.";
};
case_mode = defaultNullOpts.mkEnumFirstDefault [
"smart_case"
"ignore_case"
"respect_case"
] "Case mode.";
};
settingsExample = {
fuzzy = false;
override_generic_sorter = true;
override_file_sorter = false;
case_mode = "ignore_case";
};
settingsExample = {
fuzzy = false;
override_generic_sorter = true;
override_file_sorter = false;
case_mode = "ignore_case";
};
extraConfig = cfg: {
# Native library is in build/libfzf.so
performance.combinePlugins.pathsToLink = [ "/build" ];
};
}
extraConfig = cfg: {
# Native library is in build/libfzf.so
performance.combinePlugins.pathsToLink = [ "/build" ];
};
}

View file

@ -1,46 +1,40 @@
{
lib,
helpers,
config,
pkgs,
...
}:
(import ./_helpers.nix {
inherit
lib
helpers
config
pkgs
;
}).mkExtension
{
name = "fzy-native";
extensionName = "fzy_native";
defaultPackage = pkgs.vimPlugins.telescope-fzy-native-nvim;
let
inherit (lib.nixvim) defaultNullOpts;
in
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
name = "fzy-native";
extensionName = "fzy_native";
defaultPackage = pkgs.vimPlugins.telescope-fzy-native-nvim;
# TODO: introduced 2024-03-24, remove on 2024-05-24
optionsRenamedToSettings = [
"overrideFileSorter"
"overrideGenericSorter"
];
# TODO: introduced 2024-03-24, remove on 2024-05-24
optionsRenamedToSettings = [
"overrideFileSorter"
"overrideGenericSorter"
];
settingsOptions = {
override_file_sorter = helpers.defaultNullOpts.mkBool true ''
Whether to override the file sorter.
'';
settingsOptions = {
override_file_sorter = defaultNullOpts.mkBool true ''
Whether to override the file sorter.
'';
override_generic_sorter = helpers.defaultNullOpts.mkBool true ''
Whether to override the generic sorter.
'';
};
override_generic_sorter = defaultNullOpts.mkBool true ''
Whether to override the generic sorter.
'';
};
settingsExample = {
override_file_sorter = true;
override_generic_sorter = false;
};
settingsExample = {
override_file_sorter = true;
override_generic_sorter = false;
};
extraConfig = cfg: {
# fzy-native itself is in deps directory
performance.combinePlugins.pathsToLink = [ "/deps/fzy-lua-native" ];
};
}
extraConfig = cfg: {
# fzy-native itself is in deps directory
performance.combinePlugins.pathsToLink = [ "/deps/fzy-lua-native" ];
};
}

View file

@ -1,148 +1,142 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
(import ./_helpers.nix {
inherit
lib
helpers
config
pkgs
;
}).mkExtension
{
name = "media-files";
extensionName = "media_files";
defaultPackage = pkgs.vimPlugins.telescope-media-files-nvim;
let
inherit (lib.nixvim) defaultNullOpts;
in
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
name = "media-files";
extensionName = "media_files";
defaultPackage = pkgs.vimPlugins.telescope-media-files-nvim;
# TODO: introduced 2024-03-24, remove on 2024-05-24
imports =
let
telescopeExtensionsPath = [
"plugins"
"telescope"
"extensions"
];
in
mapAttrsToList
(
oldOptionName: newOptionPath:
mkRenamedOptionModule (
telescopeExtensionsPath
++ [
"media_files"
oldOptionName
]
) (telescopeExtensionsPath ++ [ "media-files" ] ++ newOptionPath)
)
{
enable = [ "enable" ];
package = [ "package" ];
filetypes = [
"settings"
"filetypes"
];
find_cmd = [
"settings"
"find_cmd"
];
};
extraOptions = {
dependencies =
let
mkDepOption =
{
name,
desc,
package ? pkgs.${name},
enabledByDefault ? false,
}:
{
enable = mkOption {
type = types.bool;
default = enabledByDefault;
description = ''
Whether to install the ${name} dependency.
${desc}
'';
};
package = mkOption {
type = types.package;
default = package;
description = "The package to use for the ${name} dependency.";
};
};
in
{
chafa = mkDepOption {
name = "chafa";
enabledByDefault = true;
desc = "Required for image support.";
};
imageMagick = mkDepOption {
name = "ImageMagick";
package = pkgs.imagemagick;
desc = "Required for svg previews.";
};
ffmpegthumbnailer = mkDepOption {
name = "ffmpegthumbnailer";
desc = "Required for video preview support.";
};
pdftoppm = mkDepOption {
name = "pdmtoppm";
package = pkgs.poppler_utils;
desc = "Required for pdf preview support.";
};
epub-thumbnailer = mkDepOption {
name = "epub-thumbnailer";
desc = "Required for epub preview support";
};
fontpreview = mkDepOption {
name = "fontpreview";
desc = "Required for font preview support.";
};
};
};
extraConfig = cfg: {
extraPackages = flatten (
mapAttrsToList (name: { enable, package }: optional enable package) cfg.dependencies
);
};
settingsOptions = {
filetypes = helpers.defaultNullOpts.mkListOf types.str [
"png"
"jpg"
"gif"
"mp4"
"webm"
"pdf"
] "Filetypes whitelist.";
find_cmd = helpers.defaultNullOpts.mkStr "fd" ''
Which find command to use.
'';
};
settingsExample = {
filetypes = [
"png"
"webp"
"jpg"
"jpeg"
# TODO: introduced 2024-03-24, remove on 2024-05-24
imports =
let
telescopeExtensionsPath = [
"plugins"
"telescope"
"extensions"
];
find_cmd = "rg";
};
}
in
mapAttrsToList
(
oldOptionName: newOptionPath:
mkRenamedOptionModule (
telescopeExtensionsPath
++ [
"media_files"
oldOptionName
]
) (telescopeExtensionsPath ++ [ "media-files" ] ++ newOptionPath)
)
{
enable = [ "enable" ];
package = [ "package" ];
filetypes = [
"settings"
"filetypes"
];
find_cmd = [
"settings"
"find_cmd"
];
};
extraOptions = {
dependencies =
let
mkDepOption =
{
name,
desc,
package ? pkgs.${name},
enabledByDefault ? false,
}:
{
enable = mkOption {
type = types.bool;
default = enabledByDefault;
description = ''
Whether to install the ${name} dependency.
${desc}
'';
};
package = mkOption {
type = types.package;
default = package;
description = "The package to use for the ${name} dependency.";
};
};
in
{
chafa = mkDepOption {
name = "chafa";
enabledByDefault = true;
desc = "Required for image support.";
};
imageMagick = mkDepOption {
name = "ImageMagick";
package = pkgs.imagemagick;
desc = "Required for svg previews.";
};
ffmpegthumbnailer = mkDepOption {
name = "ffmpegthumbnailer";
desc = "Required for video preview support.";
};
pdftoppm = mkDepOption {
name = "pdmtoppm";
package = pkgs.poppler_utils;
desc = "Required for pdf preview support.";
};
epub-thumbnailer = mkDepOption {
name = "epub-thumbnailer";
desc = "Required for epub preview support";
};
fontpreview = mkDepOption {
name = "fontpreview";
desc = "Required for font preview support.";
};
};
};
extraConfig = cfg: {
extraPackages = flatten (
mapAttrsToList (name: { enable, package }: optional enable package) cfg.dependencies
);
};
settingsOptions = {
filetypes = defaultNullOpts.mkListOf types.str [
"png"
"jpg"
"gif"
"mp4"
"webm"
"pdf"
] "Filetypes whitelist.";
find_cmd = defaultNullOpts.mkStr "fd" ''
Which find command to use.
'';
};
settingsExample = {
filetypes = [
"png"
"webp"
"jpg"
"jpeg"
];
find_cmd = "rg";
};
}

View file

@ -1,23 +1,14 @@
{
lib,
helpers,
config,
pkgs,
...
}:
(import ./_helpers.nix {
inherit
lib
helpers
config
pkgs
;
}).mkExtension
{
name = "ui-select";
defaultPackage = pkgs.vimPlugins.telescope-ui-select-nvim;
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
name = "ui-select";
defaultPackage = pkgs.vimPlugins.telescope-ui-select-nvim;
settingsExample = {
specific_opts.codeactions = false;
};
}
settingsExample = {
specific_opts.codeactions = false;
};
}

View file

@ -1,20 +1,13 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
telescopeHelpers = import ./_helpers.nix {
inherit
lib
helpers
config
pkgs
;
};
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
telescopeHelpers = import ./_helpers.nix { inherit lib config pkgs; };
in
telescopeHelpers.mkExtension {
name = "undo";
@ -60,34 +53,34 @@ telescopeHelpers.mkExtension {
];
settingsOptions = {
use_delta = helpers.defaultNullOpts.mkBool true ''
use_delta = defaultNullOpts.mkBool true ''
When set to true, [delta](https://github.com/dandavison/delta) is used for fancy diffs in
the preview section.
If set to false, `telescope-undo` will not use `delta` even when available and fall back to a
plain diff with treesitter highlights.
'';
use_custom_command = helpers.mkNullOrOption (with types; listOf str) ''
use_custom_command = mkNullOrOption (with types; listOf str) ''
Should be in this format: `[ "bash" "-c" "echo '$DIFF' | delta" ]`
'';
side_by_side = helpers.defaultNullOpts.mkBool false ''
side_by_side = defaultNullOpts.mkBool false ''
If set to true tells `delta` to render diffs side-by-side. Thus, requires `delta` to be used.
Be aware that `delta` always uses its own configuration, so it might be that you're getting
the side-by-side view even if this is set to false.
'';
vim_diff_opts = {
ctxlen = helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.scrolloff" ''
ctxlen = defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.scrolloff" ''
Defaults to the scrolloff.
'';
};
entry_format = helpers.defaultNullOpts.mkStr "state #$ID, $STAT, $TIME" ''
entry_format = defaultNullOpts.mkStr "state #$ID, $STAT, $TIME" ''
The format to show on telescope for the different versions of the file.
'';
time_format = helpers.defaultNullOpts.mkStr "" ''
time_format = defaultNullOpts.mkStr "" ''
Can be set to a [Lua date format string](https://www.lua.org/pil/22.1.html).
'';