mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-19 09:49:48 +01:00
Merge pull request #254 from horriblename/fix-bad-import
Add rename warnings for nvimTree.setupOpts.*
This commit is contained in:
commit
f3817fb4b2
2 changed files with 124 additions and 6 deletions
|
@ -1,6 +1,9 @@
|
||||||
{lib}: let
|
{lib}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.types) bool;
|
inherit (lib.types) bool;
|
||||||
|
inherit (lib.modules) mkRenamedOptionModule;
|
||||||
|
inherit (lib.attrsets) mapAttrsToList;
|
||||||
|
inherit (lib.lists) flatten;
|
||||||
in {
|
in {
|
||||||
mkBool = value: description:
|
mkBool = value: description:
|
||||||
mkOption {
|
mkOption {
|
||||||
|
@ -8,4 +11,55 @@ in {
|
||||||
default = value;
|
default = value;
|
||||||
inherit description;
|
inherit description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Generates a list of mkRenamedOptionModule, from a mapping of the old name to
|
||||||
|
the new name. Nested options can optionally supply a "_name" to indicate its
|
||||||
|
new name.
|
||||||
|
|
||||||
|
# Example
|
||||||
|
|
||||||
|
```nix
|
||||||
|
batchRenameOptions ["nvimTree"] ["nvimTree" "setupOpts"] {
|
||||||
|
disableNetrw = "disable_netrw";
|
||||||
|
nestedOption = {
|
||||||
|
_name = "nested_option";
|
||||||
|
somethingElse = "something_else";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The above code is equivalent to this:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
[
|
||||||
|
(
|
||||||
|
mkRenamedOptionModule
|
||||||
|
["nvimTree" "disableNetrw"]
|
||||||
|
["nvimTree" "setupOpts" "disable_netrw"]
|
||||||
|
)
|
||||||
|
(
|
||||||
|
mkRenamedOptionModule
|
||||||
|
["nvimTree" "nestedOption" "somethingElse"]
|
||||||
|
["nvimTree" "setupOpts" "nested_option" "something_else"]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
batchRenameOptions = oldBasePath: newBasePath: mappings: let
|
||||||
|
genSetupOptRenames = oldSubpath: newSubpath: table:
|
||||||
|
mapAttrsToList (
|
||||||
|
oldName: newNameOrNestedOpts:
|
||||||
|
if builtins.isAttrs newNameOrNestedOpts
|
||||||
|
then
|
||||||
|
genSetupOptRenames (oldSubpath ++ [oldName]) (newSubpath ++ [newNameOrNestedOpts._name or oldName])
|
||||||
|
(builtins.removeAttrs newNameOrNestedOpts ["_name"])
|
||||||
|
else
|
||||||
|
mkRenamedOptionModule
|
||||||
|
(oldBasePath ++ oldSubpath ++ [oldName])
|
||||||
|
(newBasePath ++ newSubpath ++ [newNameOrNestedOpts])
|
||||||
|
)
|
||||||
|
table;
|
||||||
|
in
|
||||||
|
flatten (genSetupOptRenames [] [] mappings);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,71 @@
|
||||||
inherit (lib.generators) mkLuaInline;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.types) nullOr str bool int submodule listOf enum oneOf attrs addCheck;
|
inherit (lib.types) nullOr str bool int submodule listOf enum oneOf attrs addCheck;
|
||||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||||
|
inherit (lib.nvim.config) batchRenameOptions;
|
||||||
|
|
||||||
|
migrationTable = {
|
||||||
|
disableNetrw = "disable_netrw";
|
||||||
|
hijackNetrw = "hijack_netrw";
|
||||||
|
autoreloadOnWrite = "autoreload_on_write";
|
||||||
|
updateFocusedFile = "update_focused_file";
|
||||||
|
sort = {
|
||||||
|
sorter = "sorter";
|
||||||
|
foldersFirst = "folders_first";
|
||||||
|
};
|
||||||
|
hijackCursor = "hijack_cursor";
|
||||||
|
hijackUnnamedBufferWhenOpening = "hijack_unnamed_buffer_when_opening";
|
||||||
|
rootDirs = "root_dirs";
|
||||||
|
preferStartupRoot = "prefer_startup_root";
|
||||||
|
syncRootWithCwd = "sync_root_with_cwd";
|
||||||
|
reloadOnBufEnter = "reload_on_buf_enter";
|
||||||
|
respectBufCwd = "respect_buf_cwd";
|
||||||
|
hijackDirectories = "hijack_directories";
|
||||||
|
systemOpen = {
|
||||||
|
args = "args";
|
||||||
|
cmd = "cmd";
|
||||||
|
};
|
||||||
|
diagnostics = "diagnostics";
|
||||||
|
git = {
|
||||||
|
enable = "enable";
|
||||||
|
showOnDirs = "show_on_dirs";
|
||||||
|
showOnOpenDirs = "show_on_open_dirs";
|
||||||
|
disableForDirs = "disable_for_dirs";
|
||||||
|
timeout = "timeout";
|
||||||
|
};
|
||||||
|
modified = "modified";
|
||||||
|
filesystemWatchers = "filesystem_watchers";
|
||||||
|
selectPrompts = "select_prompts";
|
||||||
|
view = "view";
|
||||||
|
renderer = {
|
||||||
|
addTrailing = "add_trailing";
|
||||||
|
groupEmpty = "group_empty";
|
||||||
|
fullName = "full_name";
|
||||||
|
highlightGit = "highlight_git";
|
||||||
|
highlightOpenedFiles = "highlight_opened_files";
|
||||||
|
highlightModified = "highlight_modified";
|
||||||
|
rootFolderLabel = "root_folder_label";
|
||||||
|
indentWidth = "indent_width";
|
||||||
|
indentMarkers = "indent_markers";
|
||||||
|
specialFiles = "special_files";
|
||||||
|
symlinkDestination = "symlink_destination";
|
||||||
|
icons = "icons";
|
||||||
|
};
|
||||||
|
filters = "filters";
|
||||||
|
trash = "trash";
|
||||||
|
actions = "actions";
|
||||||
|
liveFilter = "live_filter";
|
||||||
|
tab = "tab";
|
||||||
|
notify = "notify";
|
||||||
|
ui = "ui";
|
||||||
|
};
|
||||||
|
|
||||||
|
renamedSetupOpts =
|
||||||
|
batchRenameOptions
|
||||||
|
["vim" "filetree" "nvimTree"]
|
||||||
|
["vim" "filetree" "nvimTree" "setupOpts"]
|
||||||
|
migrationTable;
|
||||||
in {
|
in {
|
||||||
|
imports = renamedSetupOpts;
|
||||||
options.vim.filetree.nvimTree = {
|
options.vim.filetree.nvimTree = {
|
||||||
enable = mkEnableOption "filetree via nvim-tree.lua";
|
enable = mkEnableOption "filetree via nvim-tree.lua";
|
||||||
|
|
||||||
|
@ -34,12 +98,6 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
disableNetrw = mkOption {
|
|
||||||
default = false;
|
|
||||||
description = "Disables netrw and replaces it with tree";
|
|
||||||
type = bool;
|
|
||||||
};
|
|
||||||
|
|
||||||
setupOpts = mkPluginSetupOption "Nvim Tree" {
|
setupOpts = mkPluginSetupOption "Nvim Tree" {
|
||||||
hijack_netrw = mkOption {
|
hijack_netrw = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -47,6 +105,12 @@ in {
|
||||||
type = bool;
|
type = bool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
disable_netrw = mkOption {
|
||||||
|
default = false;
|
||||||
|
description = "Disables netrw and replaces it with tree";
|
||||||
|
type = bool;
|
||||||
|
};
|
||||||
|
|
||||||
auto_reload_on_write = mkOption {
|
auto_reload_on_write = mkOption {
|
||||||
default = true;
|
default = true;
|
||||||
description = "Auto reload tree on write";
|
description = "Auto reload tree on write";
|
||||||
|
|
Loading…
Reference in a new issue