plugins/filetrees: move to by-name

This commit is contained in:
Matt Sturgeon 2024-09-05 02:38:30 +01:00
parent ad85cd760e
commit d016b139fc
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
9 changed files with 0 additions and 5 deletions

View file

@ -0,0 +1,515 @@
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.chadtree;
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);
in
{
options.plugins.chadtree = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "chadtree";
package = lib.mkPackageOption pkgs "chadtree" {
default = [
"vimPlugins"
"chadtree"
];
};
iconsPackage = lib.mkPackageOption pkgs [
"vimPlugins"
"nvim-web-devicons"
] { nullable = true; };
options = {
follow = helpers.defaultNullOpts.mkBool true ''
CHADTree will highlight currently open file, and open all its parents.
'';
lang = helpers.mkNullOrOption types.str ''
CHADTree will guess your locale from unix environmental variables.
Set to `c` to disable emojis.
'';
mimetypes = {
warn =
mkListStr
[
"audio"
"font"
"image"
"video"
]
''
Show a warning before opening these datatypes.
'';
allowExts = mkListStr [ ".ts" ] ''
Skip warning for these extensions.
'';
};
pageIncrement = helpers.defaultNullOpts.mkInt 5 ''
Change how many lines `{` and `}` scroll.
'';
pollingRate = helpers.defaultNullOpts.mkNum 2.0 ''
CHADTree's background refresh rate.
'';
session = helpers.defaultNullOpts.mkBool true ''
Save & restore currently open folders.
'';
showHidden = helpers.defaultNullOpts.mkBool false ''
Hide some files and folders by default. By default this can be toggled using the `.` key.
see `chadtree_settings.ignore` for more details.
'';
versionControl = helpers.defaultNullOpts.mkBool true ''
Enable version control. This can also be toggled. But unlike `show_hidden`, does not have a default keybind.
'';
ignore = {
nameExact =
mkListStr
[
".DS_Store"
".directory"
"thumbs.db"
".git"
]
''
Files whose name match these exactly will be ignored.
'';
nameGlob = mkListStr [ ] ''
Files whose name match these glob patterns will be ignored.
ie. `*.py` will match all python files
'';
pathGlob = mkListStr [ ] ''
Files whose full path match these glob patterns will be ignored.
'';
};
};
view = {
openDirection =
helpers.defaultNullOpts.mkEnum
[
"left"
"right"
]
"left"
''
Which way does CHADTree open?
'';
sortBy =
mkListStr
[
"is_folder"
"ext"
"file_name"
]
''
CHADTree can sort by the following criterion.
Reorder them if you want a different sorting order.
legal keys: some of
`["is_folder" "ext" "file_name"]`
'';
width = helpers.defaultNullOpts.mkInt 40 ''
How big is CHADTree when initially opened?
'';
windowOptions =
helpers.defaultNullOpts.mkAttributeSet
''
{
cursorline = true;
number = false;
relativenumber = false;
signcolumn = "no";
winfixwidth = true;
wrap = false;
}
''
''
Set of window local options to for CHADTree windows.
'';
};
theme = {
highlights = {
ignored = helpers.defaultNullOpts.mkStr "Comment" ''
These are used for files that are ignored by user supplied pattern
in `chadtree.ignore` and by version control.
'';
bookmarks = helpers.defaultNullOpts.mkStr "Title" ''
These are used to show bookmarks.
'';
quickfix = helpers.defaultNullOpts.mkStr "Label" ''
These are used to notify the number of times a file / folder appears in the `quickfix` list.
'';
versionControl = helpers.defaultNullOpts.mkStr "Comment" ''
These are used to put a version control status beside each file.
'';
};
iconGlyphSet =
helpers.defaultNullOpts.mkEnum
[
"devicons"
"emoji"
"ascii"
"ascii_hollow"
]
"devicons"
''
Icon glyph set to use.
'';
textColourSet =
helpers.defaultNullOpts.mkEnum
[
"env"
"solarized_dark_256"
"solarized_dark"
"solarized_light"
"solarized_universal"
"nord"
"trapdoor"
"nerdtree_syntax_light"
"nerdtree_syntax_dark"
]
"env"
''
On `unix`, the command `ls` can produce coloured results based on the `LS_COLORS` environmental variable.
CHADTree can pretend it's `ls` by setting `chadtree.theme.textColourSet` to `env`.
If you are not happy with that, you can choose one of the many others.
'';
iconColourSet =
helpers.defaultNullOpts.mkEnum
[
"github"
"none"
]
"github"
''
Right now you all the file icons are coloured according to Github colours.
You may also disable colouring if you wish.
'';
};
keymap = {
windowManagement = {
quit = mkListStr [ "q" ] ''
Close CHADTree window, quit if it is the last window.
'';
bigger =
mkListStr
[
"+"
"="
]
''
Resize CHADTree window bigger.
'';
smaller =
mkListStr
[
"-"
"_"
]
''
Resize CHADTree window smaller.
'';
refresh = mkListStr [ "<c-r>" ] ''
Refresh CHADTree.
'';
};
rerooting = {
changeDir = mkListStr [ "b" ] ''
Change vim's working directory.
'';
changeFocus = mkListStr [ "c" ] ''
Set CHADTree's root to folder at cursor. Does not change working directory.
'';
changeFocusUp = mkListStr [ "C" ] ''
Set CHADTree's root one level up.
'';
};
openFileFolder = {
primary = mkListStr [ "<enter>" ] ''
Open file at cursor.
'';
secondary = mkListStr [ "<tab> <2-leftmouse>" ] ''
Open file at cursor, keep cursor in CHADTree's window.
'';
tertiary =
mkListStr
[
"<m-enter>"
"<middlemouse>"
]
''
Open file at cursor in a new tab.
'';
vSplit = mkListStr [ "w" ] ''
Open file at cursor in vertical split.
'';
hSplit = mkListStr [ "W" ] ''
Open file at cursor in horizontal split.
'';
openSys = mkListStr [ "o" ] ''
Open file with GUI tools using `open` or `xdg open`.
This will open third party tools such as Finder or KDE Dolphin or GNOME nautilus, etc.
Depends on platform and user setup.
'';
collapse = mkListStr [ "o" ] ''
Collapse all subdirectories for directory at cursor.
'';
};
cursor = {
refocus = mkListStr [ "~" ] ''
Put cursor at the root of CHADTree.
'';
jumpToCurrent = mkListStr [ "J" ] ''
Position cursor in CHADTree at currently open buffer, if the buffer points to a location visible under CHADTree.
'';
stat = mkListStr [ "K" ] ''
Print `ls --long` stat for file under cursor.
'';
copyName = mkListStr [ "y" ] ''
Copy paths of files under cursor or visual block.
'';
copyBasename = mkListStr [ "Y" ] ''
Copy names of files under cursor or visual block.
'';
copyRelname = mkListStr [ "<c-y>" ] ''
Copy relative paths of files under cursor or visual block.
'';
};
filtering = {
filter = mkListStr [ "f" ] ''
Set a glob pattern to narrow down visible files.
'';
clearFilter = mkListStr [ "F" ] ''
Clear filter.
'';
};
bookmarks = {
bookmarkGoto = mkListStr [ "m" ] ''
Goto bookmark `A-Z`.
'';
};
selecting = {
select = mkListStr [ "s" ] ''
Select files under cursor or visual block.
'';
clearSelection = mkListStr [ "S" ] ''
Clear selection.
'';
};
fileOperations = {
new = mkListStr [ "a" ] ''
Create new file at location under cursor. Files ending with platform specific path separator will be folders.
Intermediary folders are created automatically.
ie. `uwu/owo/` under unix will create `uwu/` then `owo/` under it. Both are folders.
'';
link = mkListStr [ "A" ] ''
Create links at location under cursor from selection.
Links are always relative.
Intermediary folders are created automatically.
'';
rename = mkListStr [ "r" ] ''
Rename file under cursor.
'';
toggleExec = mkListStr [ "X" ] ''
Toggle all the `+x` bits of the selected / highlighted files.
Except for directories, where `-x` will prevent reading.
'';
copy = mkListStr [ "p" ] ''
Copy the selected files to location under cursor.
'';
cut = mkListStr [ "x" ] ''
Move the selected files to location under cursor.
'';
delete = mkListStr [ "d" ] ''
Delete the selected files. Items deleted cannot be recovered.
'';
trash = mkListStr [ "t" ] ''
Trash the selected files using platform specific `trash` command, if they are available.
Items trashed may be recovered.
'';
};
toggles = {
toggleHidden = mkListStr [ "." ] ''
Toggle show_hidden on and off. See `chadtree.showHidden` for details.
'';
toggleFollow = mkListStr [ "u" ] ''
Toggle `follow` on and off. See `chadtree.follow` for details.
'';
toggleVersionControl = mkListStr [ "i" ] ''
Toggle version control integration on and off.
'';
};
};
};
config =
let
setupOptions = with cfg; {
xdg = true;
options = with options; {
inherit follow;
inherit lang;
mimetypes = with mimetypes; {
inherit warn;
allow_exts = allowExts;
};
page_increment = pageIncrement;
polling_rate = pollingRate;
inherit session;
show_hidden = showHidden;
version_control = versionControl;
ignore = with ignore; {
name_exact = nameExact;
name_glob = nameGlob;
path_glob = pathGlob;
};
};
view = with view; {
open_direction = openDirection;
sort_by = sortBy;
inherit width;
window_options = windowOptions;
};
theme = with theme; {
highlights = with highlights; {
inherit ignored;
inherit bookmarks;
inherit quickfix;
version_control = versionControl;
};
icon_glyph_set = iconGlyphSet;
text_colour_set = textColourSet;
icon_colour_set = iconColourSet;
};
keymap =
with keymap;
with windowManagement;
with rerooting;
with openFileFolder;
with cursor;
with filtering;
with bookmarks;
with selecting;
with fileOperations;
with toggles;
{
inherit quit;
inherit bigger;
inherit smaller;
inherit refresh;
change_dir = changeDir;
change_focus = changeFocus;
change_focus_up = changeFocusUp;
inherit primary;
inherit secondary;
inherit tertiary;
v_split = vSplit;
h_split = hSplit;
open_sys = openSys;
inherit collapse;
inherit refocus;
jump_to_current = jumpToCurrent;
inherit stat;
copy_name = copyName;
copy_basename = copyBasename;
copy_relname = copyRelname;
inherit filter;
clear_filter = clearFilter;
bookmark_goto = bookmarkGoto;
inherit select;
clear_selection = clearSelection;
inherit new;
inherit link;
inherit rename;
toggle_exec = toggleExec;
inherit copy;
inherit cut;
inherit delete;
inherit trash;
toggle_hidden = toggleHidden;
toggle_follow = toggleFollow;
toggle_version_control = toggleVersionControl;
};
};
in
mkIf cfg.enable {
extraPlugins =
[ cfg.package ]
++ (optional (
cfg.iconsPackage != null && (cfg.theme == null || cfg.theme.iconGlyphSet == "devicons")
) cfg.iconsPackage);
extraConfigLua = ''
vim.api.nvim_set_var("chadtree_settings", ${helpers.toLuaObject setupOptions})
'';
};
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,155 @@
{
lib,
...
}:
let
inherit (lib.nixvim) defaultNullOpts;
types = lib.nixvim.nixvimTypes;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "yazi";
originalName = "yazi.nvim";
package = "yazi-nvim";
maintainers = [ lib.maintainers.khaneliman ];
description = ''
Yazi is a blazing fast file manager for the terminal.
This plugin allows you to open yazi in a floating window in Neovim.
Some default keybindings have additional dependencies you may need to install or enable.
See the [upstream docs](https://github.com/mikavilpas/yazi.nvim?tab=readme-ov-file#%EF%B8%8F-keybindings) for details.
'';
settingsOptions = {
log_level = defaultNullOpts.mkLogLevel' {
pluginDefault = "off";
description = ''
The log level to use. Off by default, but can be used to diagnose
issues. You can find the location of the log file by running
`:checkhealth yazi` in Neovim.
'';
};
open_for_directories = defaultNullOpts.mkBool false "";
use_ya_for_events_reading = defaultNullOpts.mkBool false ''
Use the `ya` command to read events.
Allows more complex behaviors using the `ya` messaging system.
'';
use_yazi_client_id_flag = defaultNullOpts.mkBool false "Allows passing which instance of yazi is being controlled.";
enable_mouse_support = defaultNullOpts.mkBool false "Enables mouse support.";
open_file_function = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(chosen_file)
vim.cmd(string.format("edit %s", vim.fn.fnameescape(chosen_file)))
end
'';
description = ''
What Neovim should do a when a file was opened (selected) in yazi.
Defaults to simply opening the file.
'';
};
clipboard_register = defaultNullOpts.mkStr "*" ''
Some yazi.nvim commands copy text to the clipboard. This is the register
yazi.nvim should use for copying. Defaults to "*", the system clipboard.
'';
keymaps =
defaultNullOpts.mkNullable (types.either types.attrs (types.enum [ false ]))
{
show_help = "<f1>";
open_file_in_vertical_split = "<c-v>";
open_file_in_horizontal_split = "<c-x>";
open_file_in_tab = "<c-t>";
grep_in_directory = "<c-s>";
replace_in_directory = "<c-g>";
cycle_open_buffers = "<tab>";
copy_relative_path_to_selected_files = "<c-y>";
send_to_quickfix_list = "<c-q>";
}
''
Customize the keymaps that are active when yazi is open and focused.
Also:
- use e.g. `open_file_in_tab = false` to disable a keymap
- you can customize only some of the keymaps if you want
- Set to `false` to disable all default keymaps.
'';
set_keymappings_function = defaultNullOpts.mkLuaFn null ''
Completely override the keymappings for yazi. This function will be
called in the context of the yazi terminal buffer.
'';
hooks = {
yazi_opened = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(preselected_path, yazi_buffer_id, config)
end
'';
description = ''
If you want to execute a custom action when yazi has been opened,
you can define it here.
'';
};
yazi_closed_successfully = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(chosen_file, config, state)
end
'';
description = "When yazi was successfully closed";
};
yazi_opened_multiple_files = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = ''
function(chosen_files)
vim.cmd("args" .. table.concat(chosen_files, " "))
end
'';
description = ''
When yazi opened multiple files. The default is to send them to the
quickfix list, but if you want to change that, you can define it here
'';
};
};
highlight_groups = defaultNullOpts.mkAttributeSet { hovered_buffer = null; } ''
Add highlight groups to different yazi events.
NOTE: this only works if `use_ya_for_events_reading` is enabled, etc.
'';
floating_window_scaling_factor =
defaultNullOpts.mkNum 0.9
"The floating window scaling factor. 1 means 100%, 0.9 means 90%, etc.";
yazi_floating_window_winblend = defaultNullOpts.mkNullableWithRaw' {
type = types.ints.between 0 100;
pluginDefault = 0;
description = "`0` for fully opaque and `100` for fully transparent. See :h winblend";
};
yazi_floating_window_border = defaultNullOpts.mkBorder "rounded" "yazi" ''
The type of border to use for the floating window.
Supports all available border types from `vim.api.keyset.win_config.border`.
'';
};
settingsExample = {
log_level = "debug";
open_for_directories = true;
enable_mouse_support = true;
floating_window_scaling_factor = 0.5;
yazi_floating_window_border = "single";
yazi_floating_window_winblend = 50;
};
}