mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
plugins/telescope: move to by-name
This commit is contained in:
parent
d07a9c78cc
commit
6debe9333f
19 changed files with 0 additions and 2 deletions
176
plugins/by-name/telescope/default.nix
Normal file
176
plugins/by-name/telescope/default.nix
Normal file
|
@ -0,0 +1,176 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.nixvim)
|
||||
keymaps
|
||||
mkNullOrOption
|
||||
mkPackageOption
|
||||
toLuaObject
|
||||
;
|
||||
in
|
||||
# TODO:add support for additional filetypes. This requires autocommands!
|
||||
lib.nixvim.neovim-plugin.mkNeovimPlugin {
|
||||
name = "telescope";
|
||||
originalName = "telescope.nvim";
|
||||
package = "telescope-nvim";
|
||||
|
||||
maintainers = [ maintainers.GaetanLepage ];
|
||||
|
||||
extraPackages = [ pkgs.bat ];
|
||||
|
||||
# TODO introduced 2024-03-24: remove 2024-05-24
|
||||
deprecateExtraOptions = true;
|
||||
optionsRenamedToSettings = [ "defaults" ];
|
||||
|
||||
imports = [
|
||||
./extensions
|
||||
|
||||
# TODO introduced 2024-05-24: remove 2024-08-24
|
||||
(mkRemovedOptionModule
|
||||
[
|
||||
"plugins"
|
||||
"telescope"
|
||||
"keymapsSilent"
|
||||
]
|
||||
"This option no longer has any effect now that the `plugin.telescope.keymaps` implementation uses `<cmd>`."
|
||||
)
|
||||
];
|
||||
|
||||
extraOptions = {
|
||||
keymaps = mkOption {
|
||||
type =
|
||||
with types;
|
||||
attrsOf (
|
||||
either str (submodule {
|
||||
options = {
|
||||
action = mkOption {
|
||||
type = types.str;
|
||||
description = "The telescope action to run.";
|
||||
};
|
||||
mode = keymaps.mkModeOption "n";
|
||||
options = keymaps.mapConfigOptions;
|
||||
};
|
||||
})
|
||||
);
|
||||
description = "Keymaps for telescope.";
|
||||
default = { };
|
||||
example = {
|
||||
"<leader>fg" = "live_grep";
|
||||
"<C-p>" = {
|
||||
action = "git_files";
|
||||
options.desc = "Telescope Git Files";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
highlightTheme = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
description = "The colorscheme to use for syntax highlighting";
|
||||
default = config.colorscheme;
|
||||
};
|
||||
|
||||
enabledExtensions = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
A list of enabled extensions.
|
||||
|
||||
You should only use this option directly if the Telescope extension you wish to enable is not natively supported
|
||||
by nixvim.
|
||||
|
||||
Most extensions are available as `plugins.telescope.extensions.<name>.enable`, although some plugins that do
|
||||
more than just provide Telescope extensions may use `plugins.<name>.enableTelescope` instead.
|
||||
|
||||
If you add an extension to this list manually, it is your responsibility to ensure the relevant plugin is also
|
||||
added to `extraPackages`.
|
||||
'';
|
||||
};
|
||||
|
||||
iconsPackage = lib.mkPackageOption pkgs [
|
||||
"vimPlugins"
|
||||
"nvim-web-devicons"
|
||||
] { nullable = true; };
|
||||
};
|
||||
|
||||
callSetup = false;
|
||||
extraConfig = cfg: {
|
||||
extraPlugins = mkIf (cfg.iconsPackage != null) [ cfg.iconsPackage ];
|
||||
|
||||
extraConfigVim = mkIf (cfg.highlightTheme != null) ''
|
||||
let $BAT_THEME = '${cfg.highlightTheme}'
|
||||
'';
|
||||
|
||||
keymaps = mapAttrsToList (
|
||||
key: mapping:
|
||||
let
|
||||
actionStr = if isString mapping then mapping else mapping.action;
|
||||
in
|
||||
{
|
||||
mode = mapping.mode or "n";
|
||||
inherit key;
|
||||
action = "<cmd>Telescope ${actionStr}<cr>";
|
||||
options = mapping.options or { };
|
||||
}
|
||||
) cfg.keymaps;
|
||||
|
||||
extraConfigLua = ''
|
||||
require('telescope').setup(${toLuaObject cfg.settings})
|
||||
|
||||
local __telescopeExtensions = ${toLuaObject cfg.enabledExtensions}
|
||||
for i, extension in ipairs(__telescopeExtensions) do
|
||||
require('telescope').load_extension(extension)
|
||||
end
|
||||
'';
|
||||
|
||||
# planets picker requires files in data/memes/planets
|
||||
performance.combinePlugins.pathsToLink = [ "/data/memes/planets" ];
|
||||
};
|
||||
|
||||
settingsOptions = {
|
||||
defaults = mkNullOrOption (with types; attrsOf anything) ''
|
||||
Default configuration for telescope.
|
||||
'';
|
||||
|
||||
pickers = mkNullOrOption (with types; attrsOf anything) ''
|
||||
Default configuration for builtin pickers.
|
||||
'';
|
||||
|
||||
extensions = mkOption {
|
||||
type = with types; attrsOf anything;
|
||||
default = { };
|
||||
# NOTE: We hide this option from the documentation as users should use the top-level
|
||||
# `extensions.*` options.
|
||||
# They can still directly change this `settings.adapters` option.
|
||||
# In this case, they are responsible for explicitly installing the manually added extensions.
|
||||
visible = false;
|
||||
};
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
defaults = {
|
||||
file_ignore_patterns = [
|
||||
"^.git/"
|
||||
"^.mypy_cache/"
|
||||
"^__pycache__/"
|
||||
"^output/"
|
||||
"^data/"
|
||||
"%.ipynb"
|
||||
];
|
||||
set_env.COLORTERM = "truecolor";
|
||||
sorting_strategy = "ascending";
|
||||
selection_caret = "> ";
|
||||
layout_config.prompt_position = "top";
|
||||
mappings = {
|
||||
i = {
|
||||
"<A-j>".__raw = "require('telescope.actions').move_selection_next";
|
||||
"<A-k>".__raw = "require('telescope.actions').move_selection_previous";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
107
plugins/by-name/telescope/extensions/_helpers.nix
Normal file
107
plugins/by-name/telescope/extensions/_helpers.nix
Normal file
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib.nixvim) mkSettingsOption toSnakeCase;
|
||||
inherit (lib) mkPackageOption;
|
||||
in
|
||||
rec {
|
||||
mkExtension =
|
||||
{
|
||||
name,
|
||||
package,
|
||||
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 = lib.toList option;
|
||||
|
||||
optionPathSnakeCase = map toSnakeCase optionPath;
|
||||
in
|
||||
lib.mkRenamedOptionModule (basePluginPath ++ optionPath) (settingsPath ++ optionPathSnakeCase)
|
||||
) optionsRenamedToSettings);
|
||||
|
||||
options.plugins.telescope.extensions.${name} = {
|
||||
enable = lib.mkEnableOption "the `${name}` telescope extension";
|
||||
|
||||
package = mkPackageOption pkgs name {
|
||||
default = [
|
||||
"vimPlugins"
|
||||
package
|
||||
];
|
||||
};
|
||||
|
||||
settings = mkSettingsOption {
|
||||
description = "settings for the `${name}` telescope extension.";
|
||||
options = settingsOptions;
|
||||
example = settingsExample;
|
||||
};
|
||||
} // extraOptions;
|
||||
|
||||
config =
|
||||
let
|
||||
cfg = config.plugins.telescope.extensions.${name};
|
||||
in
|
||||
lib.mkIf cfg.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
extraPlugins = [ cfg.package ];
|
||||
|
||||
plugins.telescope = {
|
||||
enabledExtensions = [ extensionName ];
|
||||
settings.extensions.${extensionName} = cfg.settings;
|
||||
};
|
||||
}
|
||||
(extraConfig cfg)
|
||||
]
|
||||
);
|
||||
};
|
||||
|
||||
# FIXME: don't manually put Default in the description
|
||||
# TODO: Comply with #603
|
||||
mkModeMappingsOption =
|
||||
mode: defaults:
|
||||
lib.mkOption {
|
||||
type = with lib.types; attrsOf strLuaFn;
|
||||
default = { };
|
||||
description = ''
|
||||
Keymaps in ${mode} mode.
|
||||
|
||||
Default:
|
||||
```nix
|
||||
${defaults}
|
||||
```
|
||||
'';
|
||||
apply = lib.mapAttrs (_: lib.nixvim.mkRaw);
|
||||
};
|
||||
|
||||
mkMappingsOption =
|
||||
{ insertDefaults, normalDefaults }:
|
||||
{
|
||||
i = mkModeMappingsOption "insert" insertDefaults;
|
||||
n = mkModeMappingsOption "normal" normalDefaults;
|
||||
};
|
||||
}
|
11
plugins/by-name/telescope/extensions/default.nix
Normal file
11
plugins/by-name/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
|
||||
];
|
||||
}
|
233
plugins/by-name/telescope/extensions/file-browser.nix
Normal file
233
plugins/by-name/telescope/extensions/file-browser.nix
Normal file
|
@ -0,0 +1,233 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
telescopeHelpers = import ./_helpers.nix { inherit lib config pkgs; };
|
||||
inherit (lib.nixvim) defaultNullOpts mkNullOrStr;
|
||||
in
|
||||
telescopeHelpers.mkExtension {
|
||||
name = "file-browser";
|
||||
extensionName = "file_browser";
|
||||
package = "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 = mkNullOrStr ''
|
||||
Custom theme, will use your global theme by default.
|
||||
'';
|
||||
|
||||
path = defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } ''
|
||||
Directory to browse files from.
|
||||
`vim.fn.expanded` automatically.
|
||||
'';
|
||||
|
||||
cwd = defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } ''
|
||||
Directory to browse folders from.
|
||||
`vim.fn.expanded` automatically.
|
||||
'';
|
||||
|
||||
cwd_to_path = defaultNullOpts.mkBool false ''
|
||||
Whether folder browser is launched from `path` rather than `cwd`.
|
||||
'';
|
||||
|
||||
grouped = defaultNullOpts.mkBool false ''
|
||||
Group initial sorting by directories and then files.
|
||||
'';
|
||||
|
||||
files = defaultNullOpts.mkBool true ''
|
||||
Start in file (true) or folder (false) browser.
|
||||
'';
|
||||
|
||||
add_dirs = defaultNullOpts.mkBool true ''
|
||||
Whether the file browser shows folders.
|
||||
'';
|
||||
|
||||
depth = defaultNullOpts.mkUnsignedInt 1 ''
|
||||
File tree depth to display, `false` for unlimited depth.
|
||||
'';
|
||||
|
||||
auto_depth = defaultNullOpts.mkBool false ''
|
||||
Unlimit or set `depth` to `auto_depth` & unset grouped on prompt for file_browser.
|
||||
'';
|
||||
|
||||
select_buffer = defaultNullOpts.mkBool false ''
|
||||
Select current buffer if possible.
|
||||
May imply `hidden=true`.
|
||||
'';
|
||||
|
||||
hidden =
|
||||
defaultNullOpts.mkNullable
|
||||
(
|
||||
with types;
|
||||
either bool (submodule {
|
||||
options = {
|
||||
file_browser = defaultNullOpts.mkBool false "";
|
||||
|
||||
folder_browser = defaultNullOpts.mkBool false "";
|
||||
};
|
||||
})
|
||||
)
|
||||
{
|
||||
file_browser = false;
|
||||
folder_browser = false;
|
||||
}
|
||||
"Determines whether to show hidden files or not.";
|
||||
|
||||
respect_gitignore = defaultNullOpts.mkBool false ''
|
||||
Induces slow-down w/ plenary finder (true if `fd` available).
|
||||
'';
|
||||
|
||||
browse_files = defaultNullOpts.mkLuaFn "require('telescope._extensions.file_browser.finders').browse_files" "A custom lua function to override for the file 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 = defaultNullOpts.mkBool false ''
|
||||
Hide `../` in the file browser.
|
||||
'';
|
||||
|
||||
collapse_dirs = defaultNullOpts.mkBool false ''
|
||||
Skip with only a single (possibly hidden) sub-dir in file_browser.
|
||||
'';
|
||||
|
||||
quiet = defaultNullOpts.mkBool false ''
|
||||
Suppress any notification from file_browser actions.
|
||||
'';
|
||||
|
||||
dir_icon = defaultNullOpts.mkStr "" ''
|
||||
Change the icon for a directory.
|
||||
'';
|
||||
|
||||
dir_icon_hl = defaultNullOpts.mkStr "Default" ''
|
||||
Change the highlight group of dir icon.
|
||||
'';
|
||||
|
||||
display_stat = defaultNullOpts.mkAttrsOf types.anything {
|
||||
date = true;
|
||||
size = true;
|
||||
mode = true;
|
||||
} "Ordered stat; see upstream for more info.";
|
||||
|
||||
hijack_netrw = defaultNullOpts.mkBool false ''
|
||||
Use telescope file browser when opening directory paths.
|
||||
'';
|
||||
|
||||
use_fd = defaultNullOpts.mkBool true ''
|
||||
Use `fd` if available over `plenary.scandir`.
|
||||
'';
|
||||
|
||||
git_status = defaultNullOpts.mkBool true ''
|
||||
Show the git status of files (true if `git` is found).
|
||||
'';
|
||||
|
||||
prompt_path = 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;
|
||||
};
|
||||
};
|
||||
}
|
154
plugins/by-name/telescope/extensions/frecency.nix
Normal file
154
plugins/by-name/telescope/extensions/frecency.nix
Normal file
|
@ -0,0 +1,154 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.nixvim) defaultNullOpts mkNullOrOption mkNullOrStr;
|
||||
in
|
||||
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
|
||||
name = "frecency";
|
||||
package = "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 = defaultNullOpts.mkBool true ''
|
||||
If true, it removes stale entries count over than `db_validate_threshold`.
|
||||
'';
|
||||
|
||||
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 = defaultNullOpts.mkBool true ''
|
||||
If true, it shows confirmation dialog by `vim.ui.select()` before validating DB.
|
||||
'';
|
||||
|
||||
db_validate_threshold = defaultNullOpts.mkUnsignedInt 10 ''
|
||||
It will removes over than this count in validating DB.
|
||||
'';
|
||||
|
||||
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 = defaultNullOpts.mkBool false ''
|
||||
Disable devicons (if available).
|
||||
'';
|
||||
|
||||
hide_current_buffer = defaultNullOpts.mkBool false ''
|
||||
If true, it does not show the current buffer in candidates.
|
||||
'';
|
||||
|
||||
filter_delimiter = defaultNullOpts.mkStr ":" ''
|
||||
Delimiters to indicate the filter like `:CWD:`.
|
||||
'';
|
||||
|
||||
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 = 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 = 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 = defaultNullOpts.mkBool false ''
|
||||
To see the scores generated by the algorithm in the results, set this to true.
|
||||
'';
|
||||
|
||||
show_unindexed = defaultNullOpts.mkBool true ''
|
||||
Determines if non-indexed files are included in workspace filter results.
|
||||
'';
|
||||
|
||||
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)
|
||||
|
||||
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 = 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";
|
||||
};
|
||||
};
|
||||
}
|
54
plugins/by-name/telescope/extensions/fzf-native.nix
Normal file
54
plugins/by-name/telescope/extensions/fzf-native.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib.nixvim) defaultNullOpts;
|
||||
in
|
||||
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
|
||||
name = "fzf-native";
|
||||
extensionName = "fzf";
|
||||
package = "telescope-fzf-native-nvim";
|
||||
|
||||
# TODO: introduced 2024-03-24, remove on 2024-05-24
|
||||
optionsRenamedToSettings = [
|
||||
"fuzzy"
|
||||
"overrideGenericSorter"
|
||||
"overrideFileSorter"
|
||||
"caseMode"
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
fuzzy = defaultNullOpts.mkBool true ''
|
||||
Whether to fuzzy search. False will do exact matching.
|
||||
'';
|
||||
|
||||
override_generic_sorter = defaultNullOpts.mkBool true ''
|
||||
Override the generic sorter.
|
||||
'';
|
||||
|
||||
override_file_sorter = defaultNullOpts.mkBool true ''
|
||||
Override the file sorter.
|
||||
'';
|
||||
|
||||
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";
|
||||
};
|
||||
|
||||
extraConfig = cfg: {
|
||||
# Native library is in build/libfzf.so
|
||||
performance.combinePlugins.pathsToLink = [ "/build" ];
|
||||
};
|
||||
}
|
40
plugins/by-name/telescope/extensions/fzy-native.nix
Normal file
40
plugins/by-name/telescope/extensions/fzy-native.nix
Normal file
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (lib.nixvim) defaultNullOpts;
|
||||
in
|
||||
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
|
||||
name = "fzy-native";
|
||||
extensionName = "fzy_native";
|
||||
package = "telescope-fzy-native-nvim";
|
||||
|
||||
# TODO: introduced 2024-03-24, remove on 2024-05-24
|
||||
optionsRenamedToSettings = [
|
||||
"overrideFileSorter"
|
||||
"overrideGenericSorter"
|
||||
];
|
||||
|
||||
settingsOptions = {
|
||||
override_file_sorter = defaultNullOpts.mkBool true ''
|
||||
Whether to override the file sorter.
|
||||
'';
|
||||
|
||||
override_generic_sorter = defaultNullOpts.mkBool true ''
|
||||
Whether to override the generic sorter.
|
||||
'';
|
||||
};
|
||||
|
||||
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" ];
|
||||
};
|
||||
}
|
138
plugins/by-name/telescope/extensions/media-files.nix
Normal file
138
plugins/by-name/telescope/extensions/media-files.nix
Normal file
|
@ -0,0 +1,138 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.nixvim) defaultNullOpts;
|
||||
in
|
||||
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
|
||||
name = "media-files";
|
||||
extensionName = "media_files";
|
||||
package = "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 ? name,
|
||||
enabledByDefault ? false,
|
||||
}:
|
||||
{
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = enabledByDefault;
|
||||
description = ''
|
||||
Whether to install the ${name} dependency.
|
||||
${desc}
|
||||
'';
|
||||
};
|
||||
|
||||
package = mkPackageOption pkgs name { default = package; };
|
||||
};
|
||||
in
|
||||
{
|
||||
chafa = mkDepOption {
|
||||
name = "chafa";
|
||||
enabledByDefault = true;
|
||||
desc = "Required for image support.";
|
||||
};
|
||||
|
||||
imageMagick = mkDepOption {
|
||||
name = "ImageMagick";
|
||||
package = "imagemagick";
|
||||
desc = "Required for svg previews.";
|
||||
};
|
||||
|
||||
ffmpegthumbnailer = mkDepOption {
|
||||
name = "ffmpegthumbnailer";
|
||||
desc = "Required for video preview support.";
|
||||
};
|
||||
|
||||
pdftoppm = mkDepOption {
|
||||
name = "pdmtoppm";
|
||||
package = "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";
|
||||
};
|
||||
}
|
14
plugins/by-name/telescope/extensions/ui-select.nix
Normal file
14
plugins/by-name/telescope/extensions/ui-select.nix
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
(import ./_helpers.nix { inherit lib config pkgs; }).mkExtension {
|
||||
name = "ui-select";
|
||||
package = "telescope-ui-select-nvim";
|
||||
|
||||
settingsExample = {
|
||||
specific_opts.codeactions = false;
|
||||
};
|
||||
}
|
130
plugins/by-name/telescope/extensions/undo.nix
Normal file
130
plugins/by-name/telescope/extensions/undo.nix
Normal file
|
@ -0,0 +1,130 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
inherit (lib.nixvim) defaultNullOpts mkNullOrOption;
|
||||
telescopeHelpers = import ./_helpers.nix { inherit lib config pkgs; };
|
||||
in
|
||||
telescopeHelpers.mkExtension {
|
||||
name = "undo";
|
||||
package = "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 = 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 = mkNullOrOption (with types; listOf str) ''
|
||||
Should be in this format: `[ "bash" "-c" "echo '$DIFF' | delta" ]`
|
||||
'';
|
||||
|
||||
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 = defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.scrolloff" ''
|
||||
Defaults to the scrolloff.
|
||||
'';
|
||||
};
|
||||
|
||||
entry_format = defaultNullOpts.mkStr "state #$ID, $STAT, $TIME" ''
|
||||
The format to show on telescope for the different versions of the file.
|
||||
'';
|
||||
|
||||
time_format = 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;
|
||||
vim_diff_opts.ctxlen = 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