treewide: make lib calls explicit

This commit is contained in:
Frothy 2024-03-23 20:14:39 -04:00
commit 974bfcc78e
56 changed files with 589 additions and 496 deletions

View file

@ -33,7 +33,7 @@ in {
vim.luaConfigRC.nvimtreelua = entryAnywhere ''
${
lib.optionalString cfg.disableNetrw ''
optionalString cfg.disableNetrw ''
-- disable netrew completely
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

View file

@ -3,29 +3,30 @@
lib,
...
}: let
inherit (lib) mkEnableOption mkOption types literalExpression;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) nullOr str bool int listOf enum attrs oneOf addCheck submodule;
in {
options.vim.filetree.nvimTree = {
enable = mkEnableOption "filetree via nvim-tree.lua";
mappings = {
toggle = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<leader>t";
description = "Toggle NvimTree";
};
refresh = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<leader>tr";
description = "Refresh NvimTree";
};
findFile = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<leader>tg";
description = "Find file in NvimTree";
};
focus = mkOption {
type = types.nullOr types.str;
type = nullOr str;
default = "<leader>tf";
description = "Focus NvimTree";
};
@ -34,19 +35,19 @@ in {
disableNetrw = mkOption {
default = false;
description = "Disables netrw and replaces it with tree";
type = types.bool;
type = bool;
};
hijackNetrw = mkOption {
default = true;
description = "Prevents netrw from automatically opening when opening directories";
type = types.bool;
type = bool;
};
autoreloadOnWrite = mkOption {
default = true;
description = "Auto reload tree on write";
type = types.bool;
type = bool;
};
updateFocusedFile = mkOption {
@ -55,16 +56,16 @@ in {
until it finds the file.
'';
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkOption {
type = types.bool;
type = bool;
default = false;
description = "update focused file";
};
updateRoot = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Update the root directory of the tree if the file is not under current
@ -75,7 +76,7 @@ in {
};
ignoreList = mkOption {
type = with types; listOf str;
type = listOf str;
default = [];
description = ''
List of buffer names and filetypes that will not update the root dir
@ -93,26 +94,26 @@ in {
sorter = mkOption {
default = "name";
description = "How files within the same directory are sorted.";
type = types.enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"];
type = enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"];
};
foldersFirst = mkOption {
default = true;
description = "Sort folders before files. Has no effect when `sort.sorter` is a function.";
type = types.bool;
type = bool;
};
};
hijackCursor = mkOption {
default = false;
description = "Hijack the cursor in the tree to put it at the start of the filename";
type = types.bool;
type = bool;
};
hijackUnnamedBufferWhenOpening = mkOption {
default = false;
description = "Open nvimtree in place of the unnamed buffer if it's empty.";
type = types.bool;
type = bool;
};
rootDirs = mkOption {
@ -120,7 +121,7 @@ in {
description = ''
Preferred root directories. Only relevant when `updateFocusedFile.updateRoot` is `true`
'';
type = with types; listOf str;
type = listOf str;
};
preferStartupRoot = mkOption {
@ -129,11 +130,11 @@ in {
Prefer startup root directory when updating root directory of the tree.
Only relevant when `update_focused_file.update_root` is `true`
'';
type = types.bool;
type = bool;
};
syncRootWithCwd = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Changes the tree root directory on `DirChanged` and refreshes the tree.
@ -145,13 +146,13 @@ in {
reloadOnBufEnter = mkOption {
default = false;
type = types.bool;
type = bool;
description = "Automatically reloads the tree on `BufEnter` nvim-tree.";
};
respectBufCwd = mkOption {
default = false;
type = types.bool;
type = bool;
description = "Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.";
};
@ -163,10 +164,10 @@ in {
autoOpen = false;
};
type = types.submodule {
type = submodule {
options = {
enable = mkOption {
type = types.bool;
type = bool;
description = ''
Enable the `hijack_directories` feature. Disable this option if you use vim-dirvish or dirbuf.nvim.
If `hijack_netrw` and `disable_netrw` are `false`, this feature will be disabled.
@ -174,7 +175,7 @@ in {
};
autoOpen = mkOption {
type = types.bool;
type = bool;
description = ''
Opens the tree if the tree was previously closed.
'';
@ -187,7 +188,7 @@ in {
args = mkOption {
default = [];
description = "Optional argument list.";
type = with types; listOf str;
type = listOf str;
};
cmd = mkOption {
@ -198,7 +199,7 @@ in {
then "${pkgs.xdg-utils}/bin/xdg-open"
else throw "NvimTree: No default system open command for this platform, please set `vim.filetree.nvimTree.systemOpen.cmd`";
description = "The open command itself";
type = types.str;
type = str;
};
};
@ -210,13 +211,13 @@ in {
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkEnableOption "diagnostics view in the signcolumn.";
debounceDelay = mkOption {
description = "Idle milliseconds between diagnostic event and update.";
type = types.int;
type = int;
default = 50;
};
@ -226,7 +227,7 @@ in {
};
showOnOpenDirs = mkOption {
type = types.bool;
type = bool;
default = true;
description = ''
Show diagnostics icons on directories that are open.
@ -237,26 +238,26 @@ in {
icons = mkOption {
description = "Icons for diagnostic severity.";
default = {};
type = types.submodule {
type = submodule {
options = {
hint = mkOption {
description = "Icon used for `hint` diagnostic.";
type = types.str;
type = str;
default = "";
};
info = mkOption {
description = "Icon used for `info` diagnostic.";
type = types.str;
type = str;
default = "";
};
warning = mkOption {
description = "Icon used for `warning` diagnostic.";
type = types.str;
type = str;
default = "";
};
error = mkOption {
description = "Icon used for `error` diagnostic.";
type = types.str;
type = str;
default = "";
};
};
@ -266,17 +267,17 @@ in {
severity = mkOption {
description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`";
default = {};
type = types.submodule {
type = submodule {
options = {
min = mkOption {
description = "Minimum severity.";
type = types.enum ["HINT" "INFO" "WARNING" "ERROR"];
type = enum ["HINT" "INFO" "WARNING" "ERROR"];
default = "HINT";
};
max = mkOption {
description = "Maximum severity.";
type = types.enum ["HINT" "INFO" "WARNING" "ERROR"];
type = enum ["HINT" "INFO" "WARNING" "ERROR"];
default = "ERROR";
};
};
@ -290,19 +291,19 @@ in {
enable = mkEnableOption "Git integration with icons and colors.";
showOnDirs = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Show git icons on parent directories.";
};
showOnOpenDirs = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Show git icons on directories that are open.";
};
disableForDirs = mkOption {
type = with types; listOf str;
type = listOf str;
default = [];
description = ''
Disable git integration when git top-level matches these paths.
@ -311,7 +312,7 @@ in {
};
timeout = mkOption {
type = types.int;
type = int;
default = 400;
description = ''
Kills the git process after some time if it takes too long.
@ -323,18 +324,18 @@ in {
modified = mkOption {
description = "Indicate which file have unsaved modification.";
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkEnableOption "Modified files with icons and color highlight.";
showOnDirs = mkOption {
type = types.bool;
type = bool;
description = "Show modified icons on parent directories.";
default = true;
};
showOnOpenDirs = mkOption {
type = types.bool;
type = bool;
description = "Show modified icons on directories that are open.";
default = true;
};
@ -351,22 +352,22 @@ in {
performance.
'';
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkOption {
description = "Enable filesystem watchers.";
type = types.bool;
type = bool;
default = true;
};
debounceDelay = mkOption {
description = "Idle milliseconds between filesystem change and action.";
type = types.int;
type = int;
default = 50;
};
ignoreDirs = mkOption {
type = with types; listOf str;
type = listOf str;
default = [];
description = ''
List of vim regex for absolute directory paths that will not be watched.
@ -385,22 +386,22 @@ in {
view = mkOption {
description = "Window / buffer setup.";
default = {};
type = types.submodule {
type = submodule {
options = {
centralizeSelection = mkOption {
description = "If true, reposition the view so that the current node is initially centralized when entering nvim-tree.";
type = types.bool;
type = bool;
default = false;
};
cursorline = mkOption {
description = "Enable cursorline in nvim-tree window.";
type = types.bool;
type = bool;
default = true;
};
debounceDelay = mkOption {
type = types.int;
type = int;
default = 15;
description = ''
Idle milliseconds before some reload / refresh operations.
@ -416,7 +417,7 @@ in {
A table (an attribute set in our case, see example) indicates that the view should be dynamically sized based on the
longest line.
'';
type = with types; oneOf [int attrs];
type = oneOf [int attrs];
default = 30;
example = literalExpression ''
{
@ -429,7 +430,7 @@ in {
side = mkOption {
description = "Side of the tree.";
type = types.enum ["left" "right"];
type = enum ["left" "right"];
default = "left";
};
@ -438,13 +439,13 @@ in {
Preserves window proportions when opening a file.
If `false`, the height and width of windows other than nvim-tree will be equalized.
'';
type = types.bool;
type = bool;
default = false;
};
number = mkOption {
description = "Print the line number in front of each line.";
type = types.bool;
type = bool;
default = false;
};
@ -454,13 +455,13 @@ in {
If the option `view.number` is also `true`, the number on the cursor line
will be the line number instead of `0`.
'';
type = types.bool;
type = bool;
default = false;
};
signcolumn = mkOption {
description = ''Show diagnostic sign column. Value can be `"yes"`, `"auto"` or`"no"`.'';
type = types.enum ["yes" "auto" "no"];
type = enum ["yes" "auto" "no"];
default = "yes";
};
@ -468,23 +469,23 @@ in {
description = "Configuration options for floating window.";
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkOption {
description = "If true, tree window will be floating.";
type = types.bool;
type = bool;
default = false;
};
quitOnFocusLoss = mkOption {
description = "Close the floating tree window when it loses focus.";
type = types.bool;
type = bool;
default = true;
};
openWinConfig = mkOption {
description = "Floating window config. See `:h nvim_open_win()` for more details.";
type = types.attrs;
type = attrs;
default = {
relative = "editor";
border = "rounded";
@ -505,23 +506,23 @@ in {
addTrailing = mkOption {
default = false;
description = "Appends a trailing slash to folder names.";
type = types.bool;
type = bool;
};
groupEmpty = mkOption {
default = false;
description = "Compact folders that only contain a single folder into one node in the file tree.";
type = types.bool;
type = bool;
};
fullName = mkOption {
default = false;
description = "Display node whose name length is wider than the width of nvim-tree window in floating window.";
type = types.bool;
type = bool;
};
highlightGit = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Enable file highlight for git attributes using `NvimTreeGit` highlight groups.
@ -531,7 +532,7 @@ in {
};
highlightOpenedFiles = mkOption {
type = types.enum ["none" "icon" "name" "all"];
type = enum ["none" "icon" "name" "all"];
default = "none";
description = ''
Highlight icons and/or names for bufloaded() files using the
@ -540,7 +541,7 @@ in {
};
highlightModified = mkOption {
type = types.enum ["none" "icon" "name" "all"];
type = enum ["none" "icon" "name" "all"];
default = "none";
description = ''
Highlight modified files in the tree using `NvimTreeNormal` highlight group.
@ -549,7 +550,7 @@ in {
};
rootFolderLabel = mkOption {
type = with types; oneOf [str bool];
type = oneOf [str bool];
default = false;
example = ''"":~:s?$?/..?"'';
description = ''
@ -566,7 +567,7 @@ in {
};
indentWidth = mkOption {
type = with types; addCheck int (x: x >= 1);
type = addCheck int (x: x >= 1);
default = 2;
description = "Number of spaces for an each tree nesting level. Minimum 1.";
};
@ -574,17 +575,17 @@ in {
indentMarkers = mkOption {
description = "Configuration options for tree indent markers.";
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkEnableOption "Display indent markers when folders are open.";
inlineArrows = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Display folder arrows in the same column as indent marker when using `renderer.icons.show.folder_arrow`";
};
icons = mkOption {
type = types.attrs;
type = attrs;
description = "Individual elements of the indent markers";
default = {
corner = "";
@ -599,13 +600,13 @@ in {
};
specialFiles = mkOption {
type = with types; listOf str;
type = listOf str;
default = ["Cargo.toml" "README.md" "readme.md" "Makefile" "MAKEFILE" "flake.nix"]; # ;)
description = "A list of filenames that gets highlighted with `NvimTreeSpecialFile";
};
symlinkDestination = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Whether to show the destination of the symlink.";
};
@ -613,53 +614,53 @@ in {
icons = mkOption {
description = "Configuration options for icons.";
default = {};
type = types.submodule {
type = submodule {
options = {
webdevColors = mkOption {
type = types.bool;
type = bool;
description = " Use the webdev icon colors, otherwise `NvimTreeFileIcon`";
default = true;
};
gitPlacement = mkOption {
type = types.enum ["before" "after" "signcolumn"];
type = enum ["before" "after" "signcolumn"];
description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
default = "before";
};
modifiedPlacement = mkOption {
type = types.enum ["before" "after" "signcolumn"];
type = enum ["before" "after" "signcolumn"];
description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
default = "after";
};
padding = mkOption {
type = types.str;
type = str;
description = "Inserted between icon and filename";
default = " ";
};
symlinkArrow = mkOption {
type = types.str;
type = str;
description = "Used as a separator between symlinks' source and target.";
default = " ";
};
show = {
file = mkOption {
type = types.bool;
type = bool;
description = "Show an icon before the file name. `nvim-web-devicons` will be used if available.";
default = true;
};
folder = mkOption {
type = types.bool;
type = bool;
description = "Show an icon before the folder name.";
default = true;
};
folderArrow = mkOption {
type = types.bool;
type = bool;
default = true;
description = ''
Show a small arrow before the folder node. Arrow will be a part of the
@ -668,7 +669,7 @@ in {
};
git = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Show a git status icon, see `renderer.icons.gitPlacement`
@ -677,7 +678,7 @@ in {
};
modified = mkOption {
type = types.bool;
type = bool;
default = true;
description = ''
Show a modified icon, see `renderer.icons.modifiedPlacement`
@ -692,29 +693,29 @@ in {
to appear in the signcolumn.
'';
default = {};
type = types.submodule {
type = submodule {
options = {
default = mkOption {
type = types.str;
type = str;
description = "Glyph for files. Will be overridden by `nvim-web-devicons` if available.";
default = "";
};
symlink = mkOption {
type = types.str;
type = str;
description = "Glyph for symlinks.";
default = "";
};
modified = mkOption {
type = types.str;
type = str;
description = "Icon to display for modified files.";
default = "";
};
# TODO: hardcode each attribute
folder = mkOption {
type = types.attrs;
type = attrs;
description = "Glyphs for directories. Recommended to use the defaults unless you know what you are doing.";
default = {
default = "";
@ -729,7 +730,7 @@ in {
};
git = mkOption {
type = types.attrs;
type = attrs;
description = "Glyphs for git status.";
default = {
unstaged = "";
@ -759,22 +760,22 @@ in {
noBuffer = false;
exclude = [];
};
type = types.submodule {
type = submodule {
options = {
gitIgnored = mkOption {
type = types.bool;
type = bool;
description = "Ignore files based on `.gitignore`. Requires git.enable` to be `true`";
default = false;
};
dotfiles = mkOption {
type = types.bool;
type = bool;
description = "Do not show dotfiles: files starting with a `.`";
default = false;
};
gitClean = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
@ -784,13 +785,13 @@ in {
};
noBuffer = mkOption {
type = types.bool;
type = bool;
default = false;
description = "Do not show files that have no `buflisted()` buffer.";
};
exclude = mkOption {
type = with types; listOf str;
type = listOf str;
default = [];
description = "List of directories or files to exclude from filtering: always show them.";
};
@ -804,10 +805,10 @@ in {
cmd = "${pkgs.glib}/bin/gio trash";
};
type = types.submodule {
type = submodule {
options = {
cmd = mkOption {
type = types.str;
type = str;
description = "The command used to trash items";
};
};
@ -817,10 +818,10 @@ in {
actions = mkOption {
description = "Configuration for various actions.";
default = {};
type = types.submodule {
type = submodule {
options = {
useSystemClipboard = mkOption {
type = types.bool;
type = bool;
default = true;
description = ''
A boolean value that toggle the use of system clipboard when copy/paste
@ -833,16 +834,16 @@ in {
changeDir = mkOption {
description = "vim `change-directory` behaviour";
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Change the working directory when changing directories in the tree.";
};
global = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Use `:cd` instead of `:lcd` when changing directories.
@ -851,7 +852,7 @@ in {
};
restrictAboveCwd = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Restrict changing to a directory above the global current working directory.
@ -865,10 +866,10 @@ in {
expandAll = mkOption {
description = "Configuration for expand_all behaviour.";
default = {};
type = types.submodule {
type = submodule {
options = {
maxFolderDiscovery = mkOption {
type = types.int;
type = int;
default = 300;
description = ''
Limit the number of folders being explored when expanding every folders.
@ -876,7 +877,7 @@ in {
'';
};
exclude = mkOption {
type = with types; listOf str;
type = listOf str;
description = "A list of directories that should not be expanded automatically.";
default = [".git" "target" "build" "result"];
};
@ -888,10 +889,10 @@ in {
filePopup = mkOption {
description = "Configuration for file_popup behaviour.";
default = {};
type = types.submodule {
type = submodule {
options = {
openWinConfig = mkOption {
type = types.attrs;
type = attrs;
default = {
col = 1;
row = 1;
@ -909,22 +910,22 @@ in {
openFile = mkOption {
description = "Configuration options for opening a file from nvim-tree.";
default = {};
type = types.submodule {
type = submodule {
options = {
quitOnOpen = mkOption {
type = types.bool;
type = bool;
description = "Closes the explorer when opening a file.";
default = false;
};
eject = mkOption {
type = types.bool;
type = bool;
description = "Prevent new opened file from opening in the same window as the tree.";
default = false;
};
resizeWindow = mkOption {
type = types.bool;
type = bool;
default = false;
description = "Resizes the tree when opening a file. Previously `view.auto_resize`";
@ -933,16 +934,16 @@ in {
windowPicker = mkOption {
description = "window_picker";
default = {};
type = types.submodule {
type = submodule {
options = {
enable = mkOption {
type = types.bool;
type = bool;
description = "Enable the window picker. If this feature is not enabled, files will open in window from which you last opened the tree.";
default = false;
};
picker = mkOption {
type = types.str;
type = str;
default = "default";
description = ''
Change the default window picker, can be a string `"default"` or a function.
@ -959,20 +960,20 @@ in {
};
chars = mkOption {
type = types.str;
type = str;
description = "A string of chars used as identifiers by the window picker.";
default = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
};
exclude = {
filetype = mkOption {
type = with types; listOf str;
type = listOf str;
description = "A list of filetypes to exclude from the window picker.";
default = ["notify" "packer" "qf" "diff" "fugitive" "fugitiveblame"];
};
buftype = mkOption {
type = with types; listOf str;
type = listOf str;
description = "A list of buftypes to exclude from the window picker.";
default = ["nofile" "terminal" "help"];
};
@ -986,7 +987,7 @@ in {
removeFile = {
closeWindow = mkOption {
type = types.bool;
type = bool;
default = true;
description = "Close any window displaying a file when removing the file from the tree";
};
@ -1004,16 +1005,16 @@ in {
The filter can be cleared with the `F` key by default.
'';
default = {};
type = types.submodule {
type = submodule {
options = {
prefix = mkOption {
type = types.str;
type = str;
description = "Prefix of the filter displayed in the buffer.";
default = "[FILTER]: ";
};
alwaysShowFolders = mkOption {
type = types.bool;
type = bool;
description = "Whether to filter folders or not.";
default = true;
};
@ -1024,15 +1025,15 @@ in {
tab = mkOption {
description = "Configuration for tab behaviour.";
default = {};
type = types.submodule {
type = submodule {
options = {
sync = mkOption {
description = "Configuration for syncing nvim-tree across tabs.";
default = {};
type = types.submodule {
type = submodule {
options = {
open = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Opens the tree automatically when switching tabpage or opening a new
@ -1041,7 +1042,7 @@ in {
};
close = mkOption {
type = types.bool;
type = bool;
default = false;
description = ''
Closes the tree across all tabpages when the tree is closed.
@ -1049,7 +1050,7 @@ in {
};
ignore = mkOption {
type = with types; listOf str;
type = listOf str;
default = [];
description = ''
List of filetypes or buffer names on new tab that will prevent
@ -1066,16 +1067,16 @@ in {
notify = mkOption {
description = "Configuration for notifications.";
default = {};
type = types.submodule {
type = submodule {
options = {
threshold = mkOption {
type = types.enum ["ERROR" "WARNING" "INFO" "DEBUG"];
type = enum ["ERROR" "WARNING" "INFO" "DEBUG"];
description = "Specify minimum notification level, uses the values from `vim.log.levels`";
default = "INFO";
};
absolutePath = mkOption {
type = types.bool;
type = bool;
description = "Whether to use absolute paths or item names in fs action notifications.";
default = true;
};
@ -1086,17 +1087,17 @@ in {
ui = mkOption {
description = "General UI configuration.";
default = {};
type = types.submodule {
type = submodule {
options = {
confirm = {
remove = mkOption {
type = types.bool;
type = bool;
description = "Prompt before removing.";
default = true;
};
trash = mkOption {
type = types.bool;
type = bool;
description = "Prompt before trash.";
default = true;
};
@ -1109,7 +1110,7 @@ in {
openOnSetup = mkOption {
default = true;
description = "Open when vim is started on a directory";
type = types.bool;
type = bool;
};
};
}