mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/telescope: refactor extensions
This commit is contained in:
parent
3c0951ebc8
commit
b38f24f348
23 changed files with 1136 additions and 601 deletions
|
@ -20,15 +20,7 @@ with lib;
|
|||
deprecateExtraOptions = true;
|
||||
optionsRenamedToSettings = ["defaults"];
|
||||
|
||||
imports = [
|
||||
./file-browser.nix
|
||||
./frecency.nix
|
||||
./fzf-native.nix
|
||||
./fzy-native.nix
|
||||
./media-files.nix
|
||||
./ui-select.nix
|
||||
./undo.nix
|
||||
];
|
||||
imports = [./extensions];
|
||||
|
||||
extraOptions = {
|
||||
keymaps = mkOption {
|
||||
|
|
98
plugins/telescope/extensions/_helpers.nix
Normal file
98
plugins/telescope/extensions/_helpers.nix
Normal file
|
@ -0,0 +1,98 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
with lib; rec {
|
||||
mkExtension = {
|
||||
name,
|
||||
defaultPackage,
|
||||
extensionName ? name,
|
||||
settingsOptions ? {},
|
||||
settingsExample ? null,
|
||||
extraOptions ? {},
|
||||
imports ? [],
|
||||
optionsRenamedToSettings ? [],
|
||||
extraConfig ? cfg: {},
|
||||
}: {
|
||||
# TODO remove this once all deprecation warnings will have been removed.
|
||||
imports = let
|
||||
basePluginPath = ["plugins" "telescope" "extensions" name];
|
||||
settingsPath = basePluginPath ++ ["settings"];
|
||||
in
|
||||
imports
|
||||
++ (
|
||||
map
|
||||
(
|
||||
option: let
|
||||
optionPath =
|
||||
if isString option
|
||||
then [option]
|
||||
else option; # option is already a path (i.e. a list)
|
||||
|
||||
optionPathSnakeCase = map helpers.toSnakeCase optionPath;
|
||||
in
|
||||
mkRenamedOptionModule
|
||||
(basePluginPath ++ optionPath)
|
||||
(settingsPath ++ optionPathSnakeCase)
|
||||
)
|
||||
optionsRenamedToSettings
|
||||
);
|
||||
|
||||
options.plugins.telescope.extensions.${name} =
|
||||
{
|
||||
enable = mkEnableOption "the `${name}` telescope extension";
|
||||
|
||||
package = helpers.mkPackageOption name defaultPackage;
|
||||
|
||||
settings = helpers.mkSettingsOption {
|
||||
description = "settings for the `${name}` telescope extension.";
|
||||
options = settingsOptions;
|
||||
example = settingsExample;
|
||||
};
|
||||
}
|
||||
// extraOptions;
|
||||
|
||||
config = let
|
||||
cfg = config.plugins.telescope.extensions.${name};
|
||||
in
|
||||
mkIf cfg.enable
|
||||
(
|
||||
mkMerge [
|
||||
{
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
plugins.telescope = {
|
||||
enabledExtensions = [extensionName];
|
||||
settings.extensions.${extensionName} = cfg.settings;
|
||||
};
|
||||
}
|
||||
(extraConfig cfg)
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
mkModeMappingsOption = mode: defaults:
|
||||
mkOption {
|
||||
type = with helpers.nixvimTypes; attrsOf strLuaFn;
|
||||
default = {};
|
||||
description = ''
|
||||
Keymaps in ${mode} mode.
|
||||
|
||||
Default:
|
||||
```nix
|
||||
${defaults}
|
||||
```
|
||||
'';
|
||||
apply = mapAttrs (_: helpers.mkRaw);
|
||||
};
|
||||
|
||||
mkMappingsOption = {
|
||||
insertDefaults,
|
||||
normalDefaults,
|
||||
}: {
|
||||
i = mkModeMappingsOption "insert" insertDefaults;
|
||||
n = mkModeMappingsOption "normal" normalDefaults;
|
||||
};
|
||||
}
|
11
plugins/telescope/extensions/default.nix
Normal file
11
plugins/telescope/extensions/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
imports = [
|
||||
./file-browser.nix
|
||||
./frecency.nix
|
||||
./fzf-native.nix
|
||||
./fzy-native.nix
|
||||
./media-files.nix
|
||||
./ui-select.nix
|
||||
./undo.nix
|
||||
];
|
||||
}
|
242
plugins/telescope/extensions/file-browser.nix
Normal file
242
plugins/telescope/extensions/file-browser.nix
Normal file
|
@ -0,0 +1,242 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
telescopeHelpers = import ./_helpers.nix {inherit lib helpers config pkgs;};
|
||||
in
|
||||
telescopeHelpers.mkExtension {
|
||||
name = "file-browser";
|
||||
extensionName = "file_browser";
|
||||
defaultPackage = pkgs.vimPlugins.telescope-file-browser-nvim;
|
||||
|
||||
# TODO: introduced 2024-03-24, remove on 2024-05-24
|
||||
optionsRenamedToSettings = [
|
||||
"theme"
|
||||
"path"
|
||||
"cwd"
|
||||
"cwdToPath"
|
||||
"grouped"
|
||||
# "files" TODO this warning is causing an 'infinite recursion error'... No idea why
|
||||
"addDirs"
|
||||
"depth"
|
||||
"autoDepth"
|
||||
"selectBuffer"
|
||||
"hidden"
|
||||
"respectGitignore"
|
||||
"browseFiles"
|
||||
"browseFolders"
|
||||
"hideParentDir"
|
||||
"collapseDirs"
|
||||
"quiet"
|
||||
"dirIcon"
|
||||
"dirIconHl"
|
||||
"displayStat"
|
||||
"hijackNetrw"
|
||||
"useFd"
|
||||
"gitStatus"
|
||||
"promptPath"
|
||||
];
|
||||
imports = [
|
||||
(
|
||||
mkRemovedOptionModule
|
||||
["plugins" "telescope" "extensions" "file-browser" "mappings"]
|
||||
''
|
||||
Use `plugins.telescope.extension.file-browser.settings.mappings` instead but beware, you need to specify the full name of the callback:
|
||||
Example:
|
||||
```
|
||||
mappings = {
|
||||
i = {
|
||||
"<A-c>" = "require('telescope._extensions.file_browser.actions').create";
|
||||
"<S-CR>" = "require('telescope._extensions.file_browser.actions').create_from_prompt";
|
||||
"<A-r>" = "require('telescope._extensions.file_browser.actions').rename";
|
||||
};
|
||||
n = {
|
||||
"c" = "require('telescope._extensions.file_browser.actions').create";
|
||||
"r" = "require('telescope._extensions.file_browser.actions').rename";
|
||||
"m" = "require('telescope._extensions.file_browser.actions').move";
|
||||
};
|
||||
}
|
||||
```
|
||||
''
|
||||
)
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
theme = helpers.mkNullOrStr ''
|
||||
Custom theme, will use your global theme by default.
|
||||
'';
|
||||
|
||||
path = helpers.defaultNullOpts.mkStr ''{__raw = "vim.loop.cwd()";}'' ''
|
||||
Directory to browse files from.
|
||||
`vim.fn.expanded` automatically.
|
||||
'';
|
||||
|
||||
cwd = helpers.defaultNullOpts.mkStr ''{__raw = "vim.loop.cwd()";}'' ''
|
||||
Directory to browse folders from.
|
||||
`vim.fn.expanded` automatically.
|
||||
'';
|
||||
|
||||
cwd_to_path = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether folder browser is launched from `path` rather than `cwd`.
|
||||
'';
|
||||
|
||||
grouped = helpers.defaultNullOpts.mkBool false ''
|
||||
Group initial sorting by directories and then files.
|
||||
'';
|
||||
|
||||
files = helpers.defaultNullOpts.mkBool true ''
|
||||
Start in file (true) or folder (false) browser.
|
||||
'';
|
||||
|
||||
add_dirs = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether the file browser shows folders.
|
||||
'';
|
||||
|
||||
depth = helpers.defaultNullOpts.mkUnsignedInt 1 ''
|
||||
File tree depth to display, `false` for unlimited depth.
|
||||
'';
|
||||
|
||||
auto_depth = helpers.defaultNullOpts.mkBool false ''
|
||||
Unlimit or set `depth` to `auto_depth` & unset grouped on prompt for file_browser.
|
||||
'';
|
||||
|
||||
select_buffer = helpers.defaultNullOpts.mkBool false ''
|
||||
Select current buffer if possible.
|
||||
May imply `hidden=true`.
|
||||
'';
|
||||
|
||||
hidden =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with types;
|
||||
either
|
||||
bool
|
||||
(submodule {
|
||||
options = {
|
||||
file_browser = helpers.defaultNullOpts.mkBool false "";
|
||||
|
||||
folder_browser = helpers.defaultNullOpts.mkBool false "";
|
||||
};
|
||||
})
|
||||
)
|
||||
''
|
||||
{
|
||||
file_browser = false;
|
||||
folder_browser = false;
|
||||
}
|
||||
''
|
||||
"Determines whether to show hidden files or not.";
|
||||
|
||||
respect_gitignore = helpers.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_folders =
|
||||
helpers.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 `../` in the file browser.
|
||||
'';
|
||||
|
||||
collapse_dirs = helpers.defaultNullOpts.mkBool false ''
|
||||
Skip with only a single (possibly hidden) sub-dir in file_browser.
|
||||
'';
|
||||
|
||||
quiet = helpers.defaultNullOpts.mkBool false ''
|
||||
Suppress any notification from file_browser actions.
|
||||
'';
|
||||
|
||||
dir_icon = helpers.defaultNullOpts.mkStr "" ''
|
||||
Change the icon for a directory.
|
||||
'';
|
||||
|
||||
dir_icon_hl = helpers.defaultNullOpts.mkStr "Default" ''
|
||||
Change the highlight group of dir icon.
|
||||
'';
|
||||
|
||||
display_stat =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.anything
|
||||
''
|
||||
{
|
||||
date = true;
|
||||
size = true;
|
||||
mode = true;
|
||||
}
|
||||
''
|
||||
"Ordered stat; see upstream for more info.";
|
||||
|
||||
hijack_netrw = helpers.defaultNullOpts.mkBool false ''
|
||||
Use telescope file browser when opening directory paths.
|
||||
'';
|
||||
|
||||
use_fd = helpers.defaultNullOpts.mkBool true ''
|
||||
Use `fd` if available over `plenary.scandir`.
|
||||
'';
|
||||
|
||||
git_status = helpers.defaultNullOpts.mkBool true ''
|
||||
Show the git status of files (true if `git` is found).
|
||||
'';
|
||||
|
||||
prompt_path = helpers.defaultNullOpts.mkBool false ''
|
||||
Show the current relative path from cwd as the prompt prefix.
|
||||
'';
|
||||
|
||||
mappings = telescopeHelpers.mkMappingsOption {
|
||||
insertDefaults = ''
|
||||
{
|
||||
"<A-c>" = "require('telescope._extensions.file_browser.actions').create";
|
||||
"<S-CR>" = "require('telescope._extensions.file_browser.actions').create_from_prompt";
|
||||
"<A-r>" = "require('telescope._extensions.file_browser.actions').rename";
|
||||
"<A-m>" = "require('telescope._extensions.file_browser.actions').move";
|
||||
"<A-y>" = "require('telescope._extensions.file_browser.actions').copy";
|
||||
"<A-d>" = "require('telescope._extensions.file_browser.actions').remove";
|
||||
"<C-o>" = "require('telescope._extensions.file_browser.actions').open";
|
||||
"<C-g>" = "require('telescope._extensions.file_browser.actions').goto_parent_dir";
|
||||
"<C-e>" = "require('telescope._extensions.file_browser.actions').goto_home_dir";
|
||||
"<C-w>" = "require('telescope._extensions.file_browser.actions').goto_cwd";
|
||||
"<C-t>" = "require('telescope._extensions.file_browser.actions').change_cwd";
|
||||
"<C-f>" = "require('telescope._extensions.file_browser.actions').toggle_browser";
|
||||
"<C-h>" = "require('telescope._extensions.file_browser.actions').toggle_hidden";
|
||||
"<C-s>" = "require('telescope._extensions.file_browser.actions').toggle_all";
|
||||
"<bs>" = "require('telescope._extensions.file_browser.actions').backspace";
|
||||
}
|
||||
'';
|
||||
|
||||
normalDefaults = ''
|
||||
{
|
||||
"c" = "require('telescope._extensions.file_browser.actions').create";
|
||||
"r" = "require('telescope._extensions.file_browser.actions').rename";
|
||||
"m" = "require('telescope._extensions.file_browser.actions').move";
|
||||
"y" = "require('telescope._extensions.file_browser.actions').copy";
|
||||
"d" = "require('telescope._extensions.file_browser.actions').remove";
|
||||
"o" = "require('telescope._extensions.file_browser.actions').open";
|
||||
"g" = "require('telescope._extensions.file_browser.actions').goto_parent_dir";
|
||||
"e" = "require('telescope._extensions.file_browser.actions').goto_home_dir";
|
||||
"w" = "require('telescope._extensions.file_browser.actions').goto_cwd";
|
||||
"t" = "require('telescope._extensions.file_browser.actions').change_cwd";
|
||||
"f" = "require('telescope._extensions.file_browser.actions').toggle_browser";
|
||||
"h" = "require('telescope._extensions.file_browser.actions').toggle_hidden";
|
||||
"s" = "require('telescope._extensions.file_browser.actions').toggle_all";
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
file_browser = {
|
||||
theme = "ivy";
|
||||
hijack_netrw = true;
|
||||
};
|
||||
};
|
||||
}
|
168
plugins/telescope/extensions/frecency.nix
Normal file
168
plugins/telescope/extensions/frecency.nix
Normal file
|
@ -0,0 +1,168 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
(
|
||||
import ./_helpers.nix {inherit lib helpers 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"
|
||||
];
|
||||
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`.
|
||||
'';
|
||||
|
||||
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_safe_mode = helpers.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.
|
||||
'';
|
||||
|
||||
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 `':*:'`.
|
||||
'';
|
||||
|
||||
disable_devicons = helpers.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.
|
||||
'';
|
||||
|
||||
filter_delimiter = helpers.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).
|
||||
'';
|
||||
|
||||
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`.
|
||||
|
||||
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_scores = helpers.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.
|
||||
'';
|
||||
|
||||
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.
|
||||
|
||||
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 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.
|
||||
'';
|
||||
};
|
||||
|
||||
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";
|
||||
};
|
||||
};
|
||||
}
|
49
plugins/telescope/extensions/fzf-native.nix
Normal file
49
plugins/telescope/extensions/fzf-native.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
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;
|
||||
|
||||
# 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.
|
||||
'';
|
||||
|
||||
override_generic_sorter = helpers.defaultNullOpts.mkBool true ''
|
||||
Override the generic sorter.
|
||||
'';
|
||||
|
||||
override_file_sorter = helpers.defaultNullOpts.mkBool true ''
|
||||
Override the file sorter.
|
||||
'';
|
||||
|
||||
case_mode =
|
||||
helpers.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";
|
||||
};
|
||||
}
|
36
plugins/telescope/extensions/fzy-native.nix
Normal file
36
plugins/telescope/extensions/fzy-native.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
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;
|
||||
|
||||
# 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.
|
||||
'';
|
||||
|
||||
override_generic_sorter = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether to override the generic sorter.
|
||||
'';
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
override_file_sorter = true;
|
||||
override_generic_sorter = false;
|
||||
};
|
||||
}
|
120
plugins/telescope/extensions/media-files.nix
Normal file
120
plugins/telescope/extensions/media-files.nix
Normal file
|
@ -0,0 +1,120 @@
|
|||
{
|
||||
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;
|
||||
|
||||
# TODO: introduced 2024-03-24, remove on 2024-05-24
|
||||
optionsRenamedToSettings = [
|
||||
"filetypes"
|
||||
"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"];
|
||||
find_cmd = "rg";
|
||||
};
|
||||
}
|
18
plugins/telescope/extensions/ui-select.nix
Normal file
18
plugins/telescope/extensions/ui-select.nix
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
(
|
||||
import ./_helpers.nix {inherit lib helpers config pkgs;}
|
||||
)
|
||||
.mkExtension {
|
||||
name = "ui-select";
|
||||
defaultPackage = pkgs.vimPlugins.telescope-ui-select-nvim;
|
||||
|
||||
settingsExample = {
|
||||
specific_opts.codeactions = false;
|
||||
};
|
||||
}
|
118
plugins/telescope/extensions/undo.nix
Normal file
118
plugins/telescope/extensions/undo.nix
Normal file
|
@ -0,0 +1,118 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
telescopeHelpers = import ./_helpers.nix {inherit lib helpers config pkgs;};
|
||||
in
|
||||
telescopeHelpers.mkExtension {
|
||||
name = "undo";
|
||||
defaultPackage = pkgs.vimPlugins.telescope-undo-nvim;
|
||||
|
||||
# TODO: introduced 2024-03-24, remove on 2024-05-24
|
||||
optionsRenamedToSettings = [
|
||||
"useDelta"
|
||||
"useCustomCommand"
|
||||
"sideBySide"
|
||||
"diffContextLines"
|
||||
"entryFormat"
|
||||
"timeFormat"
|
||||
];
|
||||
imports = [
|
||||
(
|
||||
mkRemovedOptionModule
|
||||
["plugins" "telescope" "extensions" "undo" "mappings"]
|
||||
''
|
||||
Use `plugins.telescope.extension.undo.settings.mappings` instead but beware, you need to specify the full name of the callback:
|
||||
Example:
|
||||
```
|
||||
mappings = {
|
||||
i = {
|
||||
"<cr>" = "require('telescope-undo.actions').yank_additions";
|
||||
"<s-cr>" = "require('telescope-undo.actions').yank_deletions";
|
||||
"<c-cr>" = "require('telescope-undo.actions').restore";
|
||||
};
|
||||
n = {
|
||||
"y" = "require('telescope-undo.actions').yank_additions";
|
||||
"Y" = "require('telescope-undo.actions').yank_deletions";
|
||||
"u" = "require('telescope-undo.actions').restore";
|
||||
};
|
||||
}
|
||||
```
|
||||
''
|
||||
)
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
use_delta = helpers.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) ''
|
||||
Should be in this format: `[ "bash" "-c" "echo '$DIFF' | delta" ]`
|
||||
'';
|
||||
|
||||
side_by_side = helpers.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.
|
||||
'';
|
||||
|
||||
diff_context_lines = helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.scrolloff" ''
|
||||
Defaults to the scrolloff.
|
||||
'';
|
||||
|
||||
entry_format = helpers.defaultNullOpts.mkStr "state #$ID, $STAT, $TIME" ''
|
||||
The format to show on telescope for the different versions of the file.
|
||||
'';
|
||||
|
||||
time_format = helpers.defaultNullOpts.mkStr "" ''
|
||||
Can be set to a [Lua date format string](https://www.lua.org/pil/22.1.html).
|
||||
'';
|
||||
|
||||
mappings = telescopeHelpers.mkMappingsOption {
|
||||
insertDefaults = ''
|
||||
{
|
||||
"<cr>" = "require('telescope-undo.actions').yank_additions";
|
||||
"<s-cr>" = "require('telescope-undo.actions').yank_deletions";
|
||||
"<c-cr>" = "require('telescope-undo.actions').restore";
|
||||
}
|
||||
'';
|
||||
|
||||
normalDefaults = ''
|
||||
{
|
||||
"y" = "require('telescope-undo.actions').yank_additions";
|
||||
"Y" = "require('telescope-undo.actions').yank_deletions";
|
||||
"u" = "require('telescope-undo.actions').restore";
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
use_delta = true;
|
||||
use_custom_command = ["bash" "-c" "echo '$DIFF' | delta"];
|
||||
side_by_side = true;
|
||||
diff_context_lines = 8;
|
||||
entry_format = "state #$ID";
|
||||
time_format = "!%Y-%m-%dT%TZ";
|
||||
mappings = {
|
||||
i = {
|
||||
"<cr>" = "require('telescope-undo.actions').yank_additions";
|
||||
"<s-cr>" = "require('telescope-undo.actions').yank_deletions";
|
||||
"<c-cr>" = "require('telescope-undo.actions').restore";
|
||||
};
|
||||
n = {
|
||||
"y" = "require('telescope-undo.actions').yank_additions";
|
||||
"Y" = "require('telescope-undo.actions').yank_deletions";
|
||||
"u" = "require('telescope-undo.actions').restore";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,216 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.telescope.extensions.file_browser;
|
||||
|
||||
hiddenOption = types.submodule {
|
||||
options = {
|
||||
fileBrowser = helpers.mkNullOrOption types.bool "";
|
||||
|
||||
folderBrowser = helpers.mkNullOrOption types.bool "";
|
||||
};
|
||||
};
|
||||
|
||||
statOption = types.submodule {
|
||||
options = {
|
||||
width = helpers.mkNullOrOption types.int "";
|
||||
display = helpers.mkNullOrOption types.str "";
|
||||
hl = helpers.mkNullOrOption types.str "";
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.plugins.telescope.extensions.file_browser = {
|
||||
enable = mkEnableOption "file browser extension for telescope";
|
||||
|
||||
package = helpers.mkPackageOption "telescope file_browser" pkgs.vimPlugins.telescope-file-browser-nvim;
|
||||
|
||||
theme = helpers.mkNullOrOption types.str "Custom theme, will use your global theme by default.";
|
||||
|
||||
path = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "vim.loop.cwd()" ''
|
||||
Directory to browse files from.
|
||||
`vim.fn.expanded` automatically.
|
||||
'';
|
||||
|
||||
cwd = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "vim.loop.cwd()" ''
|
||||
Directory to browse folders from.
|
||||
`vim.fn.expanded` automatically.
|
||||
'';
|
||||
|
||||
cwdToPath = helpers.defaultNullOpts.mkBool false ''
|
||||
Whether folder browser is launched from `path` rather than `cwd`.
|
||||
'';
|
||||
|
||||
grouped = helpers.defaultNullOpts.mkBool false ''
|
||||
Group initial sorting by directories and then files.
|
||||
'';
|
||||
|
||||
files = helpers.defaultNullOpts.mkBool true ''
|
||||
Start in file (true) or folder (false) browser.
|
||||
'';
|
||||
|
||||
addDirs = helpers.defaultNullOpts.mkBool true ''
|
||||
Whether the file browser shows folders.
|
||||
'';
|
||||
|
||||
depth = helpers.defaultNullOpts.mkInt 1 ''
|
||||
File tree depth to display, `false` for unlimited depth.
|
||||
'';
|
||||
|
||||
autoDepth = helpers.defaultNullOpts.mkBool false ''
|
||||
Unlimit or set `depth` to `auto_depth` & unset grouped on prompt for file_browser.
|
||||
'';
|
||||
|
||||
selectBuffer = helpers.defaultNullOpts.mkBool false ''
|
||||
Select current buffer if possible.
|
||||
May imply `hidden=true`.
|
||||
'';
|
||||
|
||||
hidden = helpers.defaultNullOpts.mkNullable (types.either types.bool hiddenOption) "false" ''
|
||||
Determines whether to show hidden files or not.
|
||||
'';
|
||||
|
||||
respectGitignore = helpers.defaultNullOpts.mkBool false ''
|
||||
Induces slow-down w/ plenary finder (true if `fd` available).
|
||||
'';
|
||||
|
||||
browseFiles = helpers.defaultNullOpts.mkLuaFn "fb_finders.browse_files" ''
|
||||
A custom lua function to override for the file browser.
|
||||
'';
|
||||
|
||||
browseFolders = helpers.defaultNullOpts.mkLuaFn "fb_finders.browse_folders" ''
|
||||
A custom lua function to override for the folder browser.
|
||||
'';
|
||||
|
||||
hideParentDir = helpers.defaultNullOpts.mkBool false ''
|
||||
Hide `../` in the file browser.
|
||||
'';
|
||||
|
||||
collapseDirs = helpers.defaultNullOpts.mkBool false ''
|
||||
Skip with only a single (possibly hidden) sub-dir in file_browser.
|
||||
'';
|
||||
|
||||
quiet = helpers.defaultNullOpts.mkBool false ''
|
||||
Suppress any notification from file_browser actions.
|
||||
'';
|
||||
|
||||
dirIcon = helpers.defaultNullOpts.mkStr "" ''
|
||||
Change the icon for a directory.
|
||||
'';
|
||||
|
||||
dirIconHl = helpers.defaultNullOpts.mkStr "Default" ''
|
||||
Change the highlight group of dir icon.
|
||||
'';
|
||||
|
||||
displayStat =
|
||||
helpers.defaultNullOpts.mkNullable (with types; attrsOf (either bool statOption))
|
||||
"{ date = true, size = true, mode = true }" ''
|
||||
Ordered stat; see upstream for more info.
|
||||
'';
|
||||
|
||||
hijackNetrw = helpers.defaultNullOpts.mkBool false ''
|
||||
Use telescope file browser when opening directory paths.
|
||||
'';
|
||||
|
||||
useFd = helpers.defaultNullOpts.mkBool true ''
|
||||
Use `fd` if available over `plenary.scandir`.
|
||||
'';
|
||||
|
||||
gitStatus = helpers.defaultNullOpts.mkBool true ''
|
||||
Show the git status of files (true if `git` is found).
|
||||
'';
|
||||
|
||||
promptPath = helpers.defaultNullOpts.mkBool false ''
|
||||
Show the current relative path from cwd as the prompt prefix.
|
||||
'';
|
||||
|
||||
mappings =
|
||||
helpers.mkNullOrOption (
|
||||
with types;
|
||||
attrsOf (attrsOf (either str helpers.nixvimTypes.rawLua))
|
||||
) ''
|
||||
`fb_actions` mappings.
|
||||
Mappings can also be a lua function.
|
||||
'';
|
||||
};
|
||||
|
||||
config = let
|
||||
options = with cfg; {
|
||||
inherit
|
||||
depth
|
||||
cwd
|
||||
files
|
||||
grouped
|
||||
path
|
||||
quiet
|
||||
theme
|
||||
;
|
||||
add_dirs = addDirs;
|
||||
auto_depth = autoDepth;
|
||||
browse_files = browseFiles;
|
||||
browse_folders = browseFolders;
|
||||
collapse_dirs = collapseDirs;
|
||||
cwd_to_path = cwdToPath;
|
||||
dir_icon = dirIcon;
|
||||
dir_icon_hl = dirIconHl;
|
||||
display_stat =
|
||||
helpers.ifNonNull' displayStat
|
||||
(
|
||||
with builtins;
|
||||
mapAttrs (
|
||||
_: attr:
|
||||
if isBool attr
|
||||
then attr
|
||||
else
|
||||
attr
|
||||
// {
|
||||
display = helpers.mkRaw attr.display;
|
||||
}
|
||||
)
|
||||
displayStat
|
||||
);
|
||||
|
||||
git_status = gitStatus;
|
||||
hidden = helpers.ifNonNull' hidden (
|
||||
if isBool hidden
|
||||
then hidden
|
||||
else
|
||||
with hidden; {
|
||||
file_browser = fileBrowser;
|
||||
folder_browser = folderBrowser;
|
||||
}
|
||||
);
|
||||
hide_parent_dir = hideParentDir;
|
||||
hijack_netrw = hijackNetrw;
|
||||
mappings = helpers.ifNonNull' mappings (
|
||||
with builtins;
|
||||
mapAttrs (
|
||||
_:
|
||||
mapAttrs (
|
||||
_: action:
|
||||
if isString action
|
||||
then helpers.mkRaw "require('telescope._extensions.file_browser.actions').${action}"
|
||||
else action
|
||||
)
|
||||
)
|
||||
mappings
|
||||
);
|
||||
prompt_path = promptPath;
|
||||
respect_gitignore = respectGitignore;
|
||||
select_buffer = selectBuffer;
|
||||
use_fd = useFd;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
plugins.telescope = {
|
||||
enabledExtensions = ["file_browser"];
|
||||
settings.extensions.file_browser = options;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.telescope.extensions.frecency;
|
||||
in {
|
||||
options.plugins.telescope.extensions.frecency = {
|
||||
enable = mkEnableOption "frecency";
|
||||
|
||||
package = helpers.mkPackageOption "telescope extension frecency" pkgs.vimPlugins.telescope-frecency-nvim;
|
||||
|
||||
dbRoot = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "Path to parent directory of custom database location. Defaults to $XDG_DATA_HOME/nvim";
|
||||
default = null;
|
||||
};
|
||||
defaultWorkspace = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "Default workspace tag to filter by e.g 'CWD' to filter by default to the current directory";
|
||||
default = null;
|
||||
};
|
||||
ignorePatterns = mkOption {
|
||||
type = types.nullOr (types.listOf types.str);
|
||||
description = "Patterns in this list control which files are indexed";
|
||||
default = null;
|
||||
};
|
||||
showScores = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Whether to show scores generated by the algorithm in the results";
|
||||
default = null;
|
||||
};
|
||||
workspaces = mkOption {
|
||||
type = types.nullOr (types.attrsOf types.str);
|
||||
description = "this table contains mappings of workspace_tag -> workspace_directory";
|
||||
default = null;
|
||||
};
|
||||
showUnindexed = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Determines if non-indexed files are included in workspace filter results";
|
||||
default = null;
|
||||
};
|
||||
deviconsDisabled = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Disable devicons (if available)";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
configuration = {
|
||||
db_root = cfg.dbRoot;
|
||||
default_workspace = cfg.defaultWorkspace;
|
||||
ignore_patterns = cfg.ignorePatterns;
|
||||
show_scores = cfg.showScores;
|
||||
inherit (cfg) workspaces;
|
||||
show_unindexed = cfg.showUnindexed;
|
||||
devicons_disabled = cfg.deviconsDisabled;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPackages = [pkgs.sqlite];
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
cfg.package
|
||||
sqlite-lua
|
||||
];
|
||||
|
||||
plugins.telescope = {
|
||||
enabledExtensions = ["frecency"];
|
||||
settings.extensions.frecency = configuration;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.telescope.extensions.fzf-native;
|
||||
in {
|
||||
options.plugins.telescope.extensions.fzf-native = {
|
||||
enable = mkEnableOption "fzf-native";
|
||||
|
||||
package = helpers.mkPackageOption "telescope extension fzf-native" pkgs.vimPlugins.telescope-fzf-native-nvim;
|
||||
|
||||
fuzzy = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Whether to fuzzy search. False will do exact matching";
|
||||
default = null;
|
||||
};
|
||||
overrideGenericSorter = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Override the generice sorter";
|
||||
default = null;
|
||||
};
|
||||
overrideFileSorter = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Override the file sorter";
|
||||
default = null;
|
||||
};
|
||||
caseMode = mkOption {
|
||||
type = types.nullOr (types.enum ["smart_case" "ignore_case" "respect_case"]);
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
configuration = {
|
||||
inherit (cfg) fuzzy;
|
||||
override_generic_sorter = cfg.overrideGenericSorter;
|
||||
override_file_sorter = cfg.overrideFileSorter;
|
||||
case_mode = cfg.caseMode;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
plugins.telescope = {
|
||||
enabledExtensions = ["fzf"];
|
||||
settings.extensions.fzf = configuration;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.telescope.extensions.fzy-native;
|
||||
in {
|
||||
options.plugins.telescope.extensions.fzy-native = {
|
||||
enable = mkEnableOption "fzy-native";
|
||||
|
||||
overrideGenericSorter = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Override the generice sorter";
|
||||
default = null;
|
||||
};
|
||||
overrideFileSorter = mkOption {
|
||||
type = types.nullOr types.bool;
|
||||
description = "Override the file sorter";
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
configuration = {
|
||||
override_generic_sorter = cfg.overrideGenericSorter;
|
||||
override_file_sorter = cfg.overrideFileSorter;
|
||||
};
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = [pkgs.vimPlugins.telescope-fzy-native-nvim];
|
||||
|
||||
plugins.telescope = {
|
||||
enabledExtensions = ["fzy_native"];
|
||||
settings.extensions.fzy_native = options;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.telescope.extensions.media_files;
|
||||
in {
|
||||
options.plugins.telescope.extensions.media_files = {
|
||||
enable = mkEnableOption "media_files extension for telescope";
|
||||
|
||||
package = helpers.mkPackageOption "telescope extension media_files" pkgs.vimPlugins.telescope-media-files-nvim;
|
||||
|
||||
filetypes = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr (listOf str);
|
||||
};
|
||||
|
||||
find_cmd = mkOption {
|
||||
default = null;
|
||||
type = with types; nullOr str;
|
||||
example = ''"rg"'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
plugins.telescope = {
|
||||
enabledExtensions = ["media_files"];
|
||||
};
|
||||
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
popup-nvim
|
||||
plenary-nvim
|
||||
cfg.package
|
||||
];
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
ueberzug
|
||||
];
|
||||
};
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.telescope.extensions.ui-select;
|
||||
in {
|
||||
options.plugins.telescope.extensions.ui-select = {
|
||||
enable = mkEnableOption "ui-select extension for telescope";
|
||||
|
||||
package = helpers.mkPackageOption "telescope extension ui-select" pkgs.vimPlugins.telescope-ui-select-nvim;
|
||||
|
||||
settings = mkOption {
|
||||
type = with types; attrsOf anything;
|
||||
default = {};
|
||||
example = {
|
||||
specific_opts.codeactions = false;
|
||||
};
|
||||
description = "Settings for this extension.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
plugins.telescope = {
|
||||
enabledExtensions = ["ui-select"];
|
||||
settings.extensions.ui-select = cfg.settings;
|
||||
};
|
||||
|
||||
extraPlugins = [cfg.package];
|
||||
};
|
||||
}
|
|
@ -1,115 +0,0 @@
|
|||
{
|
||||
lib,
|
||||
helpers,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.plugins.telescope.extensions.undo;
|
||||
in {
|
||||
options.plugins.telescope.extensions.undo = {
|
||||
enable = mkEnableOption "undo";
|
||||
|
||||
package = helpers.mkPackageOption "telescope extension undo" pkgs.vimPlugins.telescope-undo-nvim;
|
||||
|
||||
useDelta = helpers.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.
|
||||
'';
|
||||
|
||||
useCustomCommand = helpers.mkNullOrOption (with types; listOf str) ''
|
||||
should be in this format: [ "bash" "-c" "echo '$DIFF' | delta" ]
|
||||
'';
|
||||
|
||||
sideBySide = helpers.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.
|
||||
'';
|
||||
|
||||
diffContextLines = helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.scrolloff" ''
|
||||
Defaults to the scrolloff.
|
||||
'';
|
||||
|
||||
entryFormat = helpers.defaultNullOpts.mkStr "state #$ID, $STAT, $TIME" ''
|
||||
The format to show on telescope for the different versions of the file.
|
||||
'';
|
||||
|
||||
timeFormat = helpers.defaultNullOpts.mkStr "" ''
|
||||
Can be set to a [Lua date format string](https://www.lua.org/pil/22.1.html).
|
||||
'';
|
||||
|
||||
mappings = {
|
||||
i =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with types;
|
||||
attrsOf str
|
||||
)
|
||||
''
|
||||
{
|
||||
"<cr>" = "yank_additions";
|
||||
"<s-cr>" = "yank_deletions";
|
||||
"<c-cr>" = "restore";
|
||||
}
|
||||
''
|
||||
"Keymaps in insert mode";
|
||||
n =
|
||||
helpers.defaultNullOpts.mkNullable
|
||||
(
|
||||
with types;
|
||||
attrsOf str
|
||||
)
|
||||
''
|
||||
{
|
||||
"y" = "yank_additions";
|
||||
"Y" = "yank_deletions";
|
||||
"u" = "restore";
|
||||
}
|
||||
''
|
||||
"Keymaps in normal mode";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
configuration = with cfg; {
|
||||
use_delta = useDelta;
|
||||
use_custom_command = useCustomCommand;
|
||||
side_by_side = sideBySide;
|
||||
diff_context_lines = diffContextLines;
|
||||
entry_format = entryFormat;
|
||||
time_format = timeFormat;
|
||||
mappings = with mappings; {
|
||||
i =
|
||||
helpers.ifNonNull' i
|
||||
(
|
||||
mapAttrs
|
||||
(key: action:
|
||||
helpers.mkRaw "require('telescope-undo.actions').${action}")
|
||||
i
|
||||
);
|
||||
|
||||
n =
|
||||
helpers.ifNonNull' n
|
||||
(
|
||||
mapAttrs
|
||||
(key: action:
|
||||
helpers.mkRaw "require('telescope-undo.actions').${action}")
|
||||
n
|
||||
);
|
||||
};
|
||||
};
|
||||
in
|
||||
mkIf
|
||||
cfg.enable
|
||||
{
|
||||
extraPlugins = [cfg.package];
|
||||
|
||||
plugins.telescope = {
|
||||
enabledExtensions = ["undo"];
|
||||
settings.extensions.undo = configuration;
|
||||
};
|
||||
};
|
||||
}
|
86
tests/test-sources/plugins/telescope/file-browser.nix
Normal file
86
tests/test-sources/plugins/telescope/file-browser.nix
Normal file
|
@ -0,0 +1,86 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
extensions.file-browser.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
defaults = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions.file-browser = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
theme = null;
|
||||
path.__raw = "vim.loop.cwd()";
|
||||
cwd.__raw = "vim.loop.cwd()";
|
||||
cwd_to_path = false;
|
||||
grouped = false;
|
||||
files = true;
|
||||
add_dirs = true;
|
||||
depth = 1;
|
||||
auto_depth = false;
|
||||
select_buffer = false;
|
||||
hidden = {
|
||||
file_browser = false;
|
||||
folder_browser = false;
|
||||
};
|
||||
respect_gitignore = false;
|
||||
browse_files = "require('telescope._extensions.file_browser.finders').browse_files";
|
||||
browse_folders = "require('telescope._extensions.file_browser.finders').browse_folders";
|
||||
hide_parent_dir = false;
|
||||
collapse_dirs = false;
|
||||
quiet = false;
|
||||
dir_icon = "";
|
||||
dir_icon_hl = "Default";
|
||||
display_stat = {
|
||||
date = true;
|
||||
size = true;
|
||||
mode = true;
|
||||
};
|
||||
hijack_netrw = false;
|
||||
use_fd = true;
|
||||
git_status = true;
|
||||
prompt_path = false;
|
||||
mappings = {
|
||||
i = {
|
||||
"<A-c>" = "require('telescope._extensions.file_browser.actions').create";
|
||||
"<S-CR>" = "require('telescope._extensions.file_browser.actions').create_from_prompt";
|
||||
"<A-r>" = "require('telescope._extensions.file_browser.actions').rename";
|
||||
"<A-m>" = "require('telescope._extensions.file_browser.actions').move";
|
||||
"<A-y>" = "require('telescope._extensions.file_browser.actions').copy";
|
||||
"<A-d>" = "require('telescope._extensions.file_browser.actions').remove";
|
||||
"<C-o>" = "require('telescope._extensions.file_browser.actions').open";
|
||||
"<C-g>" = "require('telescope._extensions.file_browser.actions').goto_parent_dir";
|
||||
"<C-e>" = "require('telescope._extensions.file_browser.actions').goto_home_dir";
|
||||
"<C-w>" = "require('telescope._extensions.file_browser.actions').goto_cwd";
|
||||
"<C-t>" = "require('telescope._extensions.file_browser.actions').change_cwd";
|
||||
"<C-f>" = "require('telescope._extensions.file_browser.actions').toggle_browser";
|
||||
"<C-h>" = "require('telescope._extensions.file_browser.actions').toggle_hidden";
|
||||
"<C-s>" = "require('telescope._extensions.file_browser.actions').toggle_all";
|
||||
"<bs>" = "require('telescope._extensions.file_browser.actions').backspace";
|
||||
};
|
||||
n = {
|
||||
"c" = "require('telescope._extensions.file_browser.actions').create";
|
||||
"r" = "require('telescope._extensions.file_browser.actions').rename";
|
||||
"m" = "require('telescope._extensions.file_browser.actions').move";
|
||||
"y" = "require('telescope._extensions.file_browser.actions').copy";
|
||||
"d" = "require('telescope._extensions.file_browser.actions').remove";
|
||||
"o" = "require('telescope._extensions.file_browser.actions').open";
|
||||
"g" = "require('telescope._extensions.file_browser.actions').goto_parent_dir";
|
||||
"e" = "require('telescope._extensions.file_browser.actions').goto_home_dir";
|
||||
"w" = "require('telescope._extensions.file_browser.actions').goto_cwd";
|
||||
"t" = "require('telescope._extensions.file_browser.actions').change_cwd";
|
||||
"f" = "require('telescope._extensions.file_browser.actions').toggle_browser";
|
||||
"h" = "require('telescope._extensions.file_browser.actions').toggle_hidden";
|
||||
"s" = "require('telescope._extensions.file_browser.actions').toggle_all";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
73
tests/test-sources/plugins/telescope/frecency.nix
Normal file
73
tests/test-sources/plugins/telescope/frecency.nix
Normal file
|
@ -0,0 +1,73 @@
|
|||
{
|
||||
empty = {
|
||||
# A warning is displayed on stdout
|
||||
tests.dontRun = true;
|
||||
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
extensions.frecency.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
defaults = {
|
||||
# A warning is displayed on stdout
|
||||
tests.dontRun = true;
|
||||
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions.frecency = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
auto_validate = true;
|
||||
db_root.__raw = "vim.fn.stdpath 'data'";
|
||||
db_safe_mode = true;
|
||||
db_validate_threshold = 10;
|
||||
default_workspace = null;
|
||||
disable_devicons = false;
|
||||
hide_current_buffer = false;
|
||||
filter_delimiter = ":";
|
||||
ignore_patterns = [
|
||||
"*.git/*"
|
||||
"*/tmp/*"
|
||||
"term://*"
|
||||
];
|
||||
max_timestamps = 10;
|
||||
show_filter_column = true;
|
||||
show_scores = false;
|
||||
show_unindexed = true;
|
||||
workspace_scan_cmd = null;
|
||||
workspaces = {};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
example = {
|
||||
# A warning is displayed on stdout
|
||||
tests.dontRun = true;
|
||||
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions.frecency = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
25
tests/test-sources/plugins/telescope/fzf-native.nix
Normal file
25
tests/test-sources/plugins/telescope/fzf-native.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
extensions.fzf-native.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
defaults = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions.fzf-native = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
fuzzy = true;
|
||||
override_generic_sorter = true;
|
||||
override_file_sorter = true;
|
||||
case_mode = "smart_case";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
23
tests/test-sources/plugins/telescope/fzy-native.nix
Normal file
23
tests/test-sources/plugins/telescope/fzy-native.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
extensions.fzy-native.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions.fzy-native = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
override_file_sorter = true;
|
||||
override_generic_sorter = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
50
tests/test-sources/plugins/telescope/media-files.nix
Normal file
50
tests/test-sources/plugins/telescope/media-files.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{pkgs, ...}: {
|
||||
empty = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
extensions.media-files.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
defaults = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions.media-files = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
filetypes = [
|
||||
"png"
|
||||
"jpg"
|
||||
"gif"
|
||||
"mp4"
|
||||
"webm"
|
||||
"pdf"
|
||||
];
|
||||
|
||||
find_cmd = "fd";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
dependencies = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
|
||||
extensions.media-files = {
|
||||
enable = true;
|
||||
|
||||
dependencies = {
|
||||
chafa.enable = true;
|
||||
imageMagick.enable = true;
|
||||
ffmpegthumbnailer.enable = true;
|
||||
pdftoppm.enable = true;
|
||||
epub-thumbnailer.enable = pkgs.stdenv.isLinux;
|
||||
fontpreview.enable = pkgs.stdenv.isLinux;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -13,22 +13,24 @@
|
|||
extensions.undo = {
|
||||
enable = true;
|
||||
|
||||
useDelta = true;
|
||||
useCustomCommand = ["bash" "-c" "echo '$DIFF' | delta"];
|
||||
sideBySide = true;
|
||||
diffContextLines = 8;
|
||||
entryFormat = "state #$ID";
|
||||
timeFormat = "!%Y-%m-%dT%TZ";
|
||||
mappings = {
|
||||
i = {
|
||||
"<cr>" = "yank_additions";
|
||||
"<s-cr>" = "yank_deletions";
|
||||
"<c-cr>" = "restore";
|
||||
};
|
||||
n = {
|
||||
"y" = "yank_additions";
|
||||
"Y" = "yank_deletions";
|
||||
"u" = "restore";
|
||||
settings = {
|
||||
use_delta = true;
|
||||
use_custom_command = ["bash" "-c" "echo '$DIFF' | delta"];
|
||||
side_by_side = true;
|
||||
diff_context_lines = 8;
|
||||
entry_format = "state #$ID";
|
||||
time_format = "!%Y-%m-%dT%TZ";
|
||||
mappings = {
|
||||
i = {
|
||||
"<cr>" = "require('telescope-undo.actions').yank_additions";
|
||||
"<s-cr>" = "require('telescope-undo.actions').yank_deletions";
|
||||
"<c-cr>" = "require('telescope-undo.actions').restore";
|
||||
};
|
||||
n = {
|
||||
"y" = "require('telescope-undo.actions').yank_additions";
|
||||
"Y" = "require('telescope-undo.actions').yank_deletions";
|
||||
"u" = "require('telescope-undo.actions').restore";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue