plugins/neo-tree: rename tabLabels option to reflect upstream change

This commit is contained in:
Gaetan Lepage 2023-05-12 14:13:26 +02:00 committed by Gaétan Lepage
parent 2057828096
commit cc21669583
2 changed files with 178 additions and 151 deletions

View file

@ -7,7 +7,16 @@
with lib; let with lib; let
cfg = config.plugins.neo-tree; cfg = config.plugins.neo-tree;
helpers = import ../helpers.nix {inherit lib;}; helpers = import ../helpers.nix {inherit lib;};
basePluginPath = ["plugins" "neo-tree"];
in { in {
imports = [
(
mkRemovedOptionModule
(basePluginPath ++ ["sourceSelector" "tabLabels"])
"Use `plugins.neo-tree.sourceSelector.sources` to achieve the same functionnality."
)
];
options.plugins.neo-tree = let options.plugins.neo-tree = let
listOfRendererComponents = with types; listOf (either str attrs); listOfRendererComponents = with types; listOf (either str attrs);
@ -143,147 +152,147 @@ in {
useDefaultMappings = helpers.defaultNullOpts.mkBool true ""; useDefaultMappings = helpers.defaultNullOpts.mkBool true "";
sourceSelector = # sourceSelector provides clickable tabs to switch between sources."
helpers.mkCompositeOption sourceSelector = {
"sourceSelector provides clickable tabs to switch between sources." winbar =
{ helpers.defaultNullOpts.mkBool false
winbar = "toggle to show selector on winbar";
helpers.defaultNullOpts.mkBool false
"toggle to show selector on winbar";
statusline = statusline =
helpers.defaultNullOpts.mkBool false helpers.defaultNullOpts.mkBool false
"toggle to show selector on statusline"; "toggle to show selector on statusline";
showScrolledOffParentNode = helpers.defaultNullOpts.mkBool false '' showScrolledOffParentNode = helpers.defaultNullOpts.mkBool false ''
If `true`, tabs are replaced with the parent path of the top visible node when If `true`, tabs are replaced with the parent path of the top visible node when
scrolled down. scrolled down.
'';
sources =
helpers.mkNullOrOption
(
with types;
listOf
(submodule {
options = {
source = mkOption {
type = str;
description = "Name of the source to add to the bar.";
};
displayName = helpers.mkNullOrOption str "How that source to appear in the bar.";
};
})
)
"Configure the characters shown on each tab.";
contentLayout =
helpers.defaultNullOpts.mkEnumFirstDefault ["start" "end" "focus"]
''
Defines how the labels are placed inside a tab.
This only takes effect when the tab width is greater than the length of label i.e.
`tabsLayout = "equal", "focus"` or when `tabsMinWidth` is large enough.
Following options are available.
"start" : left aligned / bufname \/..
"end" : right aligned / bufname \/...
"center" : centered with equal padding / bufname \/...
''; '';
tabLabels = tabsLayout =
helpers.mkCompositeOption helpers.defaultNullOpts.mkEnum
'' ["start" "end" "center" "equal" "focus"]
Configure the characters shown on each tab. "equal"
Keys of the table should match the source names defined in `sources`. ''
Value is what is printed inside the tab. Defines how the tabs are aligned inside the window when there is more than enough
If value is `nil` or not set, the source name is used instead. space.
'' { The following options are available.
filesystem = helpers.defaultNullOpts.mkStr " Files " "tab label for files"; `active` will expand the focused tab as much as possible. Bars denote the edge of window.
buffers = helpers.defaultNullOpts.mkStr " Buffers " "tab label for buffers";
gitStatus = helpers.defaultNullOpts.mkStr " Git " "tab label for git status";
diagnostics =
helpers.defaultNullOpts.mkStr " Diagnostics "
"tab label for diagnostics";
};
contentLayout = "start" : left aligned / ~ \/ ~ \/ ~ \
helpers.defaultNullOpts.mkEnumFirstDefault ["start" "end" "focus"] "end" : right aligned / ~ \/ ~ \/ ~ \
'' "center" : centered with equal padding / ~ \/ ~ \/ ~ \
Defines how the labels are placed inside a tab. "equal" : expand all tabs equally to fit the window width / ~ \/ ~ \/ ~ \
This only takes effect when the tab width is greater than the length of label i.e. "active" : expand the focused tab to fit the window width / focused tab \/ ~ \/ ~ \
`tabsLayout = "equal", "focus"` or when `tabsMinWidth` is large enough. '';
Following options are available. truncationCharacter =
"start" : left aligned / bufname \/.. helpers.defaultNullOpts.mkStr ""
"end" : right aligned / bufname \/... "Character to use when truncating the tab label";
"center" : centered with equal padding / bufname \/...
'';
tabsLayout = tabsMinWidth =
helpers.defaultNullOpts.mkEnum helpers.defaultNullOpts.mkNullable types.int "null"
["start" "end" "center" "equal" "focus"] "If int padding is added based on `contentLayout`";
"equal"
''
Defines how the tabs are aligned inside the window when there is more than enough
space.
The following options are available.
`active` will expand the focused tab as much as possible. Bars denote the edge of window.
"start" : left aligned / ~ \/ ~ \/ ~ \ tabsMaxWidth =
"end" : right aligned / ~ \/ ~ \/ ~ \ helpers.defaultNullOpts.mkNullable types.int "null"
"center" : centered with equal padding / ~ \/ ~ \/ ~ \ "This will truncate text even if `textTruncToFit = false`";
"equal" : expand all tabs equally to fit the window width / ~ \/ ~ \/ ~ \
"active" : expand the focused tab to fit the window width / focused tab \/ ~ \/ ~ \
'';
truncationCharacter = padding =
helpers.defaultNullOpts.mkStr "" helpers.defaultNullOpts.mkNullable
"Character to use when truncating the tab label"; (with types; either int (attrsOf int))
"0"
''
Defines the global padding of the source selector.
It can be an integer or an attrs with keys `left` and `right`.
Setting `padding = 2` is exactly the same as `{ left = 2; right = 2; }`.
tabsMinWidth = Example: `{ left = 2; right = 0; }`
helpers.defaultNullOpts.mkNullable types.int "null" '';
"If int padding is added based on `contentLayout`";
tabsMaxWidth = separator =
helpers.defaultNullOpts.mkNullable types.int "null" helpers.defaultNullOpts.mkNullable
"This will truncate text even if `textTruncToFit = false`"; (
with types;
either str (submodule {
options = {
left = helpers.defaultNullOpts.mkStr "" "";
right = helpers.defaultNullOpts.mkStr "\\" "";
override = helpers.defaultNullOpts.mkStr null "";
};
})
)
"Can be a string or a table"
''{ left = ""; right= ""; }'';
padding = separatorActive =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
(with types; either int (attrsOf int)) (
"0" with types;
'' either str (submodule {
Defines the global padding of the source selector. options = {
It can be an integer or an attrs with keys `left` and `right`. left = helpers.mkNullOrOption types.str "";
Setting `padding = 2` is exactly the same as `{ left = 2; right = 2; }`. right = helpers.mkNullOrOption types.str "";
override = helpers.mkNullOrOption types.str "";
};
})
)
''
Set separators around the active tab.
null falls back to `sourceSelector.separator`.
''
"null";
Example: `{ left = 2; right = 0; }` showSeparatorOnEdge =
''; helpers.defaultNullOpts.mkBool false
''
Takes a boolean value where `false` (default) hides the separators on the far
left / right.
Especially useful when left and right separator are the same.
separator = 'true' : / ~ \/ ~ \/ ~ \
helpers.defaultNullOpts.mkNullable 'false' : ~ \/ ~ \/ ~
( '';
with types;
either str (submodule {
options = {
left = helpers.defaultNullOpts.mkStr "" "";
right = helpers.defaultNullOpts.mkStr "\\" "";
override = helpers.defaultNullOpts.mkStr null "";
};
})
)
"Can be a string or a table"
''{ left = ""; right= ""; }'';
separatorActive = highlightTab = helpers.defaultNullOpts.mkStr "NeoTreeTabInactive" "";
helpers.defaultNullOpts.mkNullable
(
with types;
either str (submodule {
options = {
left = helpers.mkNullOrOption types.str "";
right = helpers.mkNullOrOption types.str "";
override = helpers.mkNullOrOption types.str "";
};
})
)
''
Set separators around the active tab.
null falls back to `sourceSelector.separator`.
''
"null";
showSeparatorOnEdge = highlightTabActive = helpers.defaultNullOpts.mkStr "NeoTreeTabActive" "";
helpers.defaultNullOpts.mkBool false
''
Takes a boolean value where `false` (default) hides the separators on the far
left / right.
Especially useful when left and right separator are the same.
'true' : / ~ \/ ~ \/ ~ \ highlightBackground = helpers.defaultNullOpts.mkStr "NeoTreeTabInactive" "";
'false' : ~ \/ ~ \/ ~
'';
highlightTab = helpers.defaultNullOpts.mkStr "NeoTreeTabInactive" ""; highlightSeparator = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorInactive" "";
highlightTabActive = helpers.defaultNullOpts.mkStr "NeoTreeTabActive" ""; highlightSeparatorActive = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorActive" "";
};
highlightBackground = helpers.defaultNullOpts.mkStr "NeoTreeTabInactive" "";
highlightSeparator = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorInactive" "";
highlightSeparatorActive = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorActive" "";
};
eventHandlers = eventHandlers =
helpers.mkNullOrOption helpers.mkNullOrOption
(types.attrsOf types.str) (types.attrsOf types.str)
@ -1005,29 +1014,35 @@ in {
(mkRaw cfg.sortFunction); (mkRaw cfg.sortFunction);
use_popups_for_input = cfg.usePopupsForInput; use_popups_for_input = cfg.usePopupsForInput;
use_default_mappings = cfg.useDefaultMappings; use_default_mappings = cfg.useDefaultMappings;
source_selector = with cfg.sourceSelector; source_selector = with cfg.sourceSelector; {
ifNonNull' cfg.sourceSelector { inherit winbar statusline;
inherit winbar statusline; show_scrolled_off_parent_node = showScrolledOffParentNode;
show_scrolled_off_parent_node = showScrolledOffParentNode; sources =
tab_labels = with tabLabels; ifNonNull' cfg.sourceSelector.sources
ifNonNull' cfg.sourceSelector.tabLabels { (
inherit filesystem buffers diagnostics; map
git_status = gitStatus; (
}; source: {
content_layout = contentLayout; inherit (source) source;
tabs_layout = tabsLayout; display_name = source.displayName;
truncation_character = truncationCharacter; }
tabs_min_width = tabsMinWidth; )
tabs_max_width = tabsMaxWidth; cfg.sourceSelector.sources
inherit padding separator; );
separator_active = separatorActive; content_layout = contentLayout;
show_separator_on_edge = showSeparatorOnEdge; tabs_layout = tabsLayout;
highlight_tab = highlightTab; truncation_character = truncationCharacter;
highlight_tab_active = highlightTabActive; tabs_min_width = tabsMinWidth;
highlight_background = highlightBackground; tabs_max_width = tabsMaxWidth;
highlight_separator = highlightSeparator; inherit padding separator;
highlight_separator_active = highlightSeparatorActive; separator_active = separatorActive;
}; show_separator_on_edge = showSeparatorOnEdge;
highlight_tab = highlightTab;
highlight_tab_active = highlightTabActive;
highlight_background = highlightBackground;
highlight_separator = highlightSeparator;
highlight_separator_active = highlightSeparatorActive;
};
event_handlers = event_handlers =
ifNonNull' cfg.eventHandlers ifNonNull' cfg.eventHandlers
( (

View file

@ -41,12 +41,24 @@
winbar = false; winbar = false;
statusline = false; statusline = false;
showScrolledOffParentNode = false; showScrolledOffParentNode = false;
tabLabels = { sources = [
filesystem = " Files "; {
buffers = " Buffers "; source = "filesystem";
gitStatus = " Git "; displayName = " Files ";
diagnostics = " Diagnostics "; }
}; {
source = "buffers";
displayName = " Buffers ";
}
{
source = "gitStatus";
displayName = " Git ";
}
{
source = "diagnostics";
displayName = " Diagnostics ";
}
];
contentLayout = "start"; contentLayout = "start";
tabsLayout = "equal"; tabsLayout = "equal";
truncationCharacter = ""; truncationCharacter = "";