mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/barbar: switch to mkNeovimPlugin + update options
This commit is contained in:
parent
513b3c76e2
commit
1c270521ad
2 changed files with 733 additions and 281 deletions
|
@ -7,54 +7,6 @@
|
|||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.plugins.barbar;
|
||||
|
||||
bufferOptions = {
|
||||
bufferIndex = helpers.mkNullOrOption types.bool ''
|
||||
Whether to show the index of the associated buffer with respect to the ordering of the
|
||||
buffers in the tabline.
|
||||
'';
|
||||
|
||||
bufferNumber = helpers.mkNullOrOption types.bool "Whether to show the `bufnr` for the associated buffer.";
|
||||
|
||||
button = helpers.mkNullOrOption (
|
||||
with types; either str (enum [ false ])
|
||||
) "the button which is clicked to close / save a buffer, or indicate that it is pinned.";
|
||||
|
||||
diagnostics =
|
||||
genAttrs
|
||||
[
|
||||
"error"
|
||||
"warn"
|
||||
"info"
|
||||
"hint"
|
||||
]
|
||||
(
|
||||
name:
|
||||
helpers.mkCompositeOption "${name} diagnostic icon." {
|
||||
enable = helpers.defaultNullOpts.mkBool false "Enable the ${name} diagnostic symbol";
|
||||
|
||||
icon = helpers.mkNullOrOption types.str "${name} diagnostic symbol";
|
||||
}
|
||||
);
|
||||
|
||||
filetype = {
|
||||
customColors = helpers.defaultNullOpts.mkBool false "Sets the icon's highlight group. If false, will use nvim-web-devicons colors";
|
||||
|
||||
enable = helpers.defaultNullOpts.mkBool true "Show the filetype icon.";
|
||||
};
|
||||
|
||||
separator = {
|
||||
left = helpers.defaultNullOpts.mkStr "▎" "Left separator";
|
||||
right = helpers.defaultNullOpts.mkStr "" "Right separator";
|
||||
};
|
||||
};
|
||||
|
||||
stateOptions = {
|
||||
modified = bufferOptions;
|
||||
pinned = bufferOptions;
|
||||
} // bufferOptions;
|
||||
|
||||
keymapsActions = {
|
||||
previous = "Previous";
|
||||
next = "Next";
|
||||
|
@ -79,239 +31,589 @@ let
|
|||
orderByWindowNumber = "OrderByWindowNumber";
|
||||
};
|
||||
in
|
||||
{
|
||||
options.plugins.barbar = helpers.neovim-plugin.extraOptionsOptions // {
|
||||
enable = mkEnableOption "barbar.nvim";
|
||||
helpers.neovim-plugin.mkNeovimPlugin config {
|
||||
name = "barbar";
|
||||
originalName = "barbar.nvim";
|
||||
defaultPackage = pkgs.vimPlugins.barbar-nvim;
|
||||
extraPlugins = [ pkgs.vimPlugins.nvim-web-devicons ];
|
||||
|
||||
package = helpers.mkPluginPackageOption "barbar" pkgs.vimPlugins.barbar-nvim;
|
||||
maintainers = [ maintainers.GaetanLepage ];
|
||||
|
||||
animation = helpers.defaultNullOpts.mkBool true "Enable/disable animations";
|
||||
# TODO: introduced 2024-05-30, remove on 2024-07-30
|
||||
deprecateExtraOptions = true;
|
||||
optionsRenamedToSettings = [
|
||||
"animation"
|
||||
"autoHide"
|
||||
"clickable"
|
||||
"focusOnClose"
|
||||
[
|
||||
"hide"
|
||||
"alternate"
|
||||
]
|
||||
[
|
||||
"hide"
|
||||
"current"
|
||||
]
|
||||
[
|
||||
"hide"
|
||||
"extensions"
|
||||
]
|
||||
[
|
||||
"hide"
|
||||
"inactive"
|
||||
]
|
||||
[
|
||||
"hide"
|
||||
"visible"
|
||||
]
|
||||
"highlightAlternate"
|
||||
"highlightInactiveFileIcons"
|
||||
"highlightVisible"
|
||||
[
|
||||
"icons"
|
||||
"bufferIndex"
|
||||
]
|
||||
[
|
||||
"icons"
|
||||
"bufferNumber"
|
||||
]
|
||||
[
|
||||
"icons"
|
||||
"button"
|
||||
]
|
||||
[
|
||||
"icons"
|
||||
"filetype"
|
||||
"customColors"
|
||||
]
|
||||
[
|
||||
"icons"
|
||||
"separator"
|
||||
"left"
|
||||
]
|
||||
[
|
||||
"icons"
|
||||
"separator"
|
||||
"right"
|
||||
]
|
||||
"insertAtStart"
|
||||
"insertAtEnd"
|
||||
"maximumPadding"
|
||||
"minimumPadding"
|
||||
"maximumLength"
|
||||
"semanticLetters"
|
||||
"letters"
|
||||
"sidebarFiletypes"
|
||||
"noNameTitle"
|
||||
"tabpages"
|
||||
];
|
||||
imports =
|
||||
let
|
||||
basePluginPath = [
|
||||
"plugins"
|
||||
"barbar"
|
||||
];
|
||||
settingsPath = basePluginPath ++ [ "settings" ];
|
||||
in
|
||||
[
|
||||
(mkRemovedOptionModule (
|
||||
basePluginPath
|
||||
++ [
|
||||
"keymaps"
|
||||
"silent"
|
||||
]
|
||||
) "Keymaps will be silent anyways. This option has always been useless.")
|
||||
(mkRenamedOptionModule (basePluginPath ++ [ "excludeFileTypes" ]) (
|
||||
settingsPath ++ [ "exclude_ft" ]
|
||||
))
|
||||
(mkRenamedOptionModule (basePluginPath ++ [ "excludeFileNames" ]) (
|
||||
settingsPath ++ [ "exclude_name" ]
|
||||
))
|
||||
(mkRemovedOptionModule (
|
||||
basePluginPath
|
||||
++ [
|
||||
"icons"
|
||||
"diagnostics"
|
||||
]
|
||||
) "Use `settings.icons.diagnostics` instead, but pay attention as the keys have changed.")
|
||||
(mkRenamedOptionModule
|
||||
(
|
||||
basePluginPath
|
||||
++ [
|
||||
"icons"
|
||||
"filetype"
|
||||
"enable"
|
||||
]
|
||||
)
|
||||
(
|
||||
settingsPath
|
||||
++ [
|
||||
"icons"
|
||||
"filetype"
|
||||
"enabled"
|
||||
]
|
||||
)
|
||||
)
|
||||
]
|
||||
++ (map
|
||||
(
|
||||
name:
|
||||
mkRemovedOptionModule (
|
||||
basePluginPath
|
||||
++ [
|
||||
"icons"
|
||||
name
|
||||
]
|
||||
) "Use `settings.icons.${name}` instead, but you should now use the real `snake_case` key names."
|
||||
)
|
||||
[
|
||||
"alternate"
|
||||
"current"
|
||||
"inactive"
|
||||
"modified"
|
||||
"pinned"
|
||||
"visible"
|
||||
]
|
||||
);
|
||||
|
||||
autoHide = helpers.defaultNullOpts.mkBool false "Enable/disable auto-hiding the tab bar when there is a single buffer.";
|
||||
extraOptions = {
|
||||
keymaps = mapAttrs (
|
||||
optionName: funcName:
|
||||
helpers.mkNullOrOption (helpers.keymaps.mkMapOptionSubmodule {
|
||||
defaults = {
|
||||
mode = "n";
|
||||
action = "<Cmd>Buffer${funcName}<CR>";
|
||||
};
|
||||
hasKey = true;
|
||||
hasAction = true;
|
||||
}) "Keymap for function Buffer${funcName}"
|
||||
) keymapsActions;
|
||||
};
|
||||
|
||||
tabpages = helpers.defaultNullOpts.mkBool true "Enable/disable current/total tabpages indicator (top right corner).";
|
||||
extraConfig = cfg: {
|
||||
keymaps = filter (keymap: keymap != null) (
|
||||
# TODO: switch to `attrValues cfg.keymaps` when removing the deprecation warnings above:
|
||||
attrValues (filterAttrs (n: v: n != "silent") cfg.keymaps)
|
||||
);
|
||||
};
|
||||
|
||||
settingsOptions = {
|
||||
animation = helpers.defaultNullOpts.mkBool true ''
|
||||
Enable/disable animations.
|
||||
'';
|
||||
|
||||
auto_hide =
|
||||
helpers.defaultNullOpts.mkNullableWithRaw (with types; either int (enum [ false ])) (-1)
|
||||
''
|
||||
Automatically hide the 'tabline' when there are this many buffers left.
|
||||
Set to any value less than `0` to disable.
|
||||
|
||||
For example: `auto_hide = 0` hides the 'tabline' when there would be zero buffers shown,
|
||||
`auto_hide = 1` hides the 'tabline' when there would only be one, etc.
|
||||
'';
|
||||
|
||||
clickable = helpers.defaultNullOpts.mkBool true ''
|
||||
Enable clickable tabs
|
||||
- left-click: go to buffer
|
||||
- middle-click: delete buffer
|
||||
If set, you can left-click on a tab to switch to that buffer, and middle-click to delete it.
|
||||
'';
|
||||
|
||||
excludeFileTypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Excludes buffers of certain filetypes from the tabline
|
||||
exclude_ft = helpers.defaultNullOpts.mkListOf types.str [ ] ''
|
||||
Excludes filetypes from appearing in the tabs.
|
||||
'';
|
||||
|
||||
excludeFileNames = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
|
||||
Excludes buffers with certain filenames from the tabline
|
||||
exclude_name = helpers.defaultNullOpts.mkListOf types.str [ ] ''
|
||||
Excludes buffers matching name from appearing in the tabs.
|
||||
'';
|
||||
|
||||
focusOnClose =
|
||||
focus_on_close =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"left"
|
||||
"previous"
|
||||
"right"
|
||||
]
|
||||
''
|
||||
A buffer to this direction will be focused (if it exists) when closing the current buffer.
|
||||
The algorithm to use for getting the next buffer after closing the current
|
||||
one:
|
||||
|
||||
- `'left'`: focus the buffer to the left of the current buffer.
|
||||
- `'previous'`: focus the previous buffer.
|
||||
- `'right'`: focus the buffer to the right of the current buffer.
|
||||
'';
|
||||
|
||||
highlightAlternate = helpers.defaultNullOpts.mkBool false "Highlight alternate buffers";
|
||||
|
||||
highlightInactiveFileIcons = helpers.defaultNullOpts.mkBool false "Highlight file icons in inactive buffers";
|
||||
|
||||
highlightVisible = helpers.defaultNullOpts.mkBool true "Highlight visible buffers";
|
||||
|
||||
icons =
|
||||
stateOptions
|
||||
// (mapAttrs
|
||||
(
|
||||
name: description:
|
||||
mkOption {
|
||||
type = types.submodule { options = stateOptions; };
|
||||
default = { };
|
||||
inherit description;
|
||||
}
|
||||
)
|
||||
{
|
||||
alternate = "The icons used for an alternate buffer.";
|
||||
current = "The icons for the current buffer.";
|
||||
inactive = "The icons for inactive buffers.";
|
||||
visible = "The icons for visible buffers.";
|
||||
}
|
||||
);
|
||||
|
||||
hide = {
|
||||
alternate = helpers.mkNullOrOption types.bool "Hide alternate buffers";
|
||||
current = helpers.mkNullOrOption types.bool "Hide current buffer";
|
||||
extensions = helpers.mkNullOrOption types.bool "Hide file extensions";
|
||||
inactive = helpers.mkNullOrOption types.bool "Hide inactive buffers";
|
||||
visible = helpers.mkNullOrOption types.bool "Hide visible buffers";
|
||||
alternate = helpers.defaultNullOpts.mkBool false ''
|
||||
Controls the visibility of the `|alternate-file|`.
|
||||
`highlight_alternate` must be `true`.
|
||||
'';
|
||||
|
||||
current = helpers.defaultNullOpts.mkBool false ''
|
||||
Controls the visibility of the current buffer.
|
||||
'';
|
||||
|
||||
extensions = helpers.defaultNullOpts.mkBool false ''
|
||||
Controls the visibility of file extensions.
|
||||
'';
|
||||
|
||||
inactive = helpers.defaultNullOpts.mkBool false ''
|
||||
Controls visibility of `|hidden-buffer|`s and `|inactive-buffer|`s.
|
||||
'';
|
||||
|
||||
visible = helpers.defaultNullOpts.mkBool false ''
|
||||
Controls visibility of `|active-buffer|`s.
|
||||
`highlight_visible` must be `true`.
|
||||
'';
|
||||
};
|
||||
|
||||
insertAtEnd = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, new buffers will be inserted at the end of the list.
|
||||
Default is to insert after current buffer.
|
||||
highlight_alternate = helpers.defaultNullOpts.mkBool false ''
|
||||
Enables highlighting of alternate buffers.
|
||||
'';
|
||||
|
||||
insertAtStart = helpers.defaultNullOpts.mkBool false ''
|
||||
If true, new buffers will be inserted at the start of the list.
|
||||
Default is to insert after current buffer.
|
||||
highlight_inactive_file_icons = helpers.defaultNullOpts.mkBool false ''
|
||||
Enables highlighting the file icons of inactive buffers.
|
||||
'';
|
||||
|
||||
maximumPadding =
|
||||
helpers.defaultNullOpts.mkInt 4
|
||||
"Sets the maximum padding width with which to surround each tab";
|
||||
highlight_visible = helpers.defaultNullOpts.mkBool true ''
|
||||
Enables highlighting of visible buffers.
|
||||
'';
|
||||
|
||||
minimumPadding =
|
||||
helpers.defaultNullOpts.mkInt 1
|
||||
"Sets the minimum padding width with which to surround each tab";
|
||||
icons = {
|
||||
buffer_index =
|
||||
helpers.defaultNullOpts.mkNullableWithRaw
|
||||
(
|
||||
with types;
|
||||
either bool (enum [
|
||||
"superscript"
|
||||
"subscript"
|
||||
])
|
||||
)
|
||||
false
|
||||
"If `true`, show the index of the buffer with respect to the ordering of the buffers in the tabline.";
|
||||
|
||||
maximumLength = helpers.defaultNullOpts.mkInt 30 "Sets the maximum buffer name length.";
|
||||
buffer_number = helpers.defaultNullOpts.mkNullableWithRaw (
|
||||
with types;
|
||||
either bool (enum [
|
||||
"superscript"
|
||||
"subscript"
|
||||
])
|
||||
) false "If `true`, show the `bufnr` for the associated buffer.";
|
||||
|
||||
semanticLetters = helpers.defaultNullOpts.mkBool true ''
|
||||
If set, the letters for each buffer in buffer-pick mode will be assigned based on their
|
||||
name.
|
||||
Otherwise or in case all letters are already assigned, the behavior is to assign letters in
|
||||
order of usability (see `letters` option)
|
||||
button = helpers.defaultNullOpts.mkNullableWithRaw (with types; either str (enum [ false ])) "" ''
|
||||
The button which is clicked to close / save a buffer, or indicate that it is pinned.
|
||||
Use `false` to disable it.
|
||||
'';
|
||||
|
||||
diagnostics = mkOption {
|
||||
type = types.submodule {
|
||||
freeformType = with types; attrsOf anything;
|
||||
options =
|
||||
let
|
||||
mkDiagnosticIconOptions = iconDefault: {
|
||||
enabled = helpers.defaultNullOpts.mkBool false ''
|
||||
Enable showing diagnostics of this `|diagnostic-severity|` in the 'tabline'.
|
||||
'';
|
||||
|
||||
icon = helpers.defaultNullOpts.mkStr iconDefault ''
|
||||
The icon which accompanies the number of diagnostics.
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
"vim.diagnostic.severity.ERROR" = mkDiagnosticIconOptions " ";
|
||||
"vim.diagnostic.severity.HINT" = mkDiagnosticIconOptions " ";
|
||||
"vim.diagnostic.severity.INFO" = mkDiagnosticIconOptions " ";
|
||||
"vim.diagnostic.severity.WARN" = mkDiagnosticIconOptions " ";
|
||||
};
|
||||
};
|
||||
apply = helpers.toRawKeys;
|
||||
default = { };
|
||||
description =
|
||||
helpers.defaultNullOpts.mkDesc
|
||||
{
|
||||
"vim.diagnostic.severity.ERROR" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
"vim.diagnostic.severity.HINT" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
"vim.diagnostic.severity.INFO" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
"vim.diagnostic.severity.WARN" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
}
|
||||
''
|
||||
Set the icon for each diagnostic level.
|
||||
|
||||
The keys will be automatically translated to raw lua:
|
||||
```nix
|
||||
{
|
||||
"vim.diagnostic.severity.INFO".enabled = true;
|
||||
"vim.diagnostic.severity.WARN".enabled = true;
|
||||
}
|
||||
```
|
||||
will result in the following lua:
|
||||
```lua
|
||||
{
|
||||
-- Note the table keys are not string literals:
|
||||
[vim.diagnostic.severity.INFO] = { ['enabled'] = true },
|
||||
[vim.diagnostic.severity.WARN] = { ['enabled'] = true },
|
||||
}
|
||||
```
|
||||
'';
|
||||
};
|
||||
|
||||
gitsigns =
|
||||
helpers.defaultNullOpts.mkAttrsOf
|
||||
(
|
||||
with types;
|
||||
submodule {
|
||||
freeformType = with types; attrsOf anything;
|
||||
options = {
|
||||
enabled = helpers.defaultNullOpts.mkBool true ''
|
||||
Enables showing git changes of this type.
|
||||
Requires `|gitsigns.nvim|`.
|
||||
'';
|
||||
|
||||
icon = helpers.mkNullOrStr ''
|
||||
The icon which accompanies the number of git status.
|
||||
|
||||
To disable the icon but still show the count, set to an empty string.
|
||||
'';
|
||||
};
|
||||
}
|
||||
)
|
||||
{
|
||||
added = {
|
||||
enabled = true;
|
||||
icon = "+";
|
||||
};
|
||||
changed = {
|
||||
enabled = true;
|
||||
icon = "~";
|
||||
};
|
||||
deleted = {
|
||||
enabled = true;
|
||||
icon = "-";
|
||||
};
|
||||
}
|
||||
"Gitsigns icons.";
|
||||
|
||||
filename = helpers.defaultNullOpts.mkBool true ''
|
||||
If `true`, show the name of the file.
|
||||
'';
|
||||
|
||||
filetype = {
|
||||
custom_colors = helpers.defaultNullOpts.mkBool false ''
|
||||
If `true`, the `Buffer<status>Icon` color will be used for icon colors.
|
||||
'';
|
||||
|
||||
enabled = helpers.defaultNullOpts.mkBool true ''
|
||||
Filetype `true`, show the `devicons` for the associated buffer's `filetype`.
|
||||
'';
|
||||
};
|
||||
|
||||
separator = {
|
||||
left = helpers.defaultNullOpts.mkStr "▎" ''
|
||||
The left separator between buffers in the tabline.
|
||||
'';
|
||||
|
||||
right = helpers.defaultNullOpts.mkStr "" ''
|
||||
The right separator between buffers in the tabline.
|
||||
'';
|
||||
|
||||
separator_at_end = helpers.defaultNullOpts.mkBool true ''
|
||||
If true, add an additional separator at the end of the buffer list.
|
||||
Can be used to create a visual separation when the inactive buffer background color is the
|
||||
same as the fill region background color.
|
||||
'';
|
||||
};
|
||||
|
||||
# Knowingly not bothering declaring all sub-options:
|
||||
# - It would make the module way more complex
|
||||
# - Most users will not be setting a lot of options under this category
|
||||
# -> `attrsOf anything`
|
||||
modified = helpers.defaultNullOpts.mkAttrsOf types.anything { button = "●"; } ''
|
||||
The icons which should be used for a 'modified' buffer.
|
||||
Supports all the base options (e.g. `buffer_index`, `filetype.enabled`, etc).
|
||||
'';
|
||||
|
||||
# Knowingly not bothering declaring all sub-options:
|
||||
# - It would make the module way more complex
|
||||
# - Most users will not be setting a lot of options under this category
|
||||
# -> `attrsOf anything`
|
||||
pinned =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.anything
|
||||
{
|
||||
button = false;
|
||||
filename = false;
|
||||
separator.right = " ";
|
||||
}
|
||||
''
|
||||
The icons which should be used for a pinned buffer.
|
||||
Supports all the base options (e.g. `buffer_index`, `filetype.enabled`, etc).
|
||||
'';
|
||||
|
||||
# Knowingly not bothering declaring all sub-options:
|
||||
# - It would make the module way more complex
|
||||
# - Most users will not be setting a lot of options under this category
|
||||
# -> `attrsOf anything`
|
||||
alternate = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (attrsOf anything)) ''
|
||||
The icons which should be used for the `|alternate-file|`.
|
||||
Supports all the base options (e.g. `buffer_index`, `filetype.enabled`, etc) as well as
|
||||
`modified` and `pinned`.
|
||||
'';
|
||||
|
||||
# Knowingly not bothering declaring all sub-options:
|
||||
# - It would make the module way more complex
|
||||
# - Most users will not be setting a lot of options under this category
|
||||
# -> `attrsOf anything`
|
||||
current = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (attrsOf anything)) ''
|
||||
The icons which should be used for current buffer.
|
||||
Supports all the base options (e.g. `buffer_index`, `filetype.enabled`, etc) as well as
|
||||
`modified` and `pinned`.
|
||||
'';
|
||||
|
||||
# Knowingly not bothering declaring all sub-options:
|
||||
# - It would make the module way more complex
|
||||
# - Most users will not be setting a lot of options under this category
|
||||
# -> `attrsOf anything`
|
||||
inactive =
|
||||
helpers.defaultNullOpts.mkAttrsOf types.anything
|
||||
{
|
||||
separator = {
|
||||
left = "▎";
|
||||
right = "";
|
||||
};
|
||||
}
|
||||
''
|
||||
The icons which should be used for `|hidden-buffer|`s and `|inactive-buffer|`s.
|
||||
Supports all the base options (e.g. `buffer_index`, `filetype.enabled`, etc) as well as
|
||||
`modified` and `pinned`.
|
||||
'';
|
||||
|
||||
# Knowingly not bothering declaring all sub-options:
|
||||
# - It would make the module way more complex
|
||||
# - Most users will not be setting a lot of options under this category
|
||||
# -> `attrsOf anything`
|
||||
visible = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (attrsOf anything)) ''
|
||||
The icons which should be used for `|active-buffer|`s.
|
||||
Supports all the base options (e.g. `buffer_index`, `filetype.enabled`, etc) as well as
|
||||
`modified` and `pinned`.
|
||||
'';
|
||||
|
||||
preset =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"default"
|
||||
"powerline"
|
||||
"slanted"
|
||||
]
|
||||
''
|
||||
Base all `|barbar-setup.icons|` configuration off of this set of defaults.
|
||||
|
||||
- `'default'`: the classic `|barbar.nvim|` look.
|
||||
- `'powerline'`: like (https://github.com/powerline/powerline)
|
||||
- `'slanted'`: like old Google Chrome tabs
|
||||
'';
|
||||
};
|
||||
|
||||
insert_at_start = helpers.defaultNullOpts.mkBool false ''
|
||||
If `true`, new buffers appear at the start of the list.
|
||||
Default is to open after the current buffer.
|
||||
|
||||
Has priority over `insert_at_end`.
|
||||
'';
|
||||
|
||||
insert_at_end = helpers.defaultNullOpts.mkBool false ''
|
||||
If `true`, new buffers appear at the end of the list.
|
||||
Default is to open after the current buffer.
|
||||
'';
|
||||
|
||||
letters = helpers.defaultNullOpts.mkStr "asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP" ''
|
||||
New buffer letters are assigned in this order.
|
||||
This order is optimal for the qwerty keyboard layout but might need adjustment for other layouts.
|
||||
This order is optimal for the QWERTY keyboard layout but might need adjustment for other layouts.
|
||||
'';
|
||||
|
||||
sidebarFiletypes = helpers.mkNullOrOption (
|
||||
with types;
|
||||
attrsOf (
|
||||
either (enum [ true ]) (
|
||||
types.submodule {
|
||||
options = {
|
||||
text = helpers.mkNullOrOption types.str "The text used for the offset";
|
||||
maximum_padding = helpers.defaultNullOpts.mkUnsignedInt 4 ''
|
||||
Sets the maximum padding width with which to surround each tab.
|
||||
'';
|
||||
|
||||
event = helpers.mkNullOrOption types.str "The event which the sidebar executes when leaving.";
|
||||
};
|
||||
}
|
||||
)
|
||||
)
|
||||
) "Set the filetypes which barbar will offset itself for";
|
||||
maximum_length = helpers.defaultNullOpts.mkUnsignedInt 30 ''
|
||||
Sets the maximum buffer name length.
|
||||
'';
|
||||
|
||||
noNameTitle = helpers.mkNullOrOption types.str ''
|
||||
minimum_length = helpers.defaultNullOpts.mkUnsignedInt 0 ''
|
||||
Sets the minimum buffer name length.
|
||||
'';
|
||||
|
||||
minimum_padding = helpers.defaultNullOpts.mkUnsignedInt 1 ''
|
||||
Sets the minimum padding width with which to surround each tab.
|
||||
'';
|
||||
|
||||
no_name_title = helpers.defaultNullOpts.mkStr null ''
|
||||
Sets the name of unnamed buffers.
|
||||
By default format is "[Buffer X]" where X is the buffer number.
|
||||
But only a static string is accepted here.
|
||||
|
||||
By default format is `'[Buffer X]'` where `X` is the buffer number.
|
||||
However, only a static string is accepted here.
|
||||
'';
|
||||
|
||||
keymaps =
|
||||
{
|
||||
silent = mkEnableOption "silent keymaps for barbar";
|
||||
}
|
||||
// (mapAttrs (
|
||||
optionName: funcName: helpers.mkNullOrOption types.str "Keymap for function Buffer${funcName}"
|
||||
) keymapsActions);
|
||||
semantic_letters = helpers.defaultNullOpts.mkBool true ''
|
||||
If `true`, the letters for each buffer in buffer-pick mode will be assigned based on their name.
|
||||
|
||||
Otherwise (or in case all letters are already assigned), the behavior is to assign letters in
|
||||
the order of provided to `letters`.
|
||||
'';
|
||||
|
||||
sidebar_filetypes = helpers.defaultNullOpts.mkAttrsOf (
|
||||
with types;
|
||||
either (enum [ true ]) (submodule {
|
||||
freeformType = with types; attrsOf anything;
|
||||
options = {
|
||||
align =
|
||||
helpers.defaultNullOpts.mkEnumFirstDefault
|
||||
[
|
||||
"left"
|
||||
"center"
|
||||
"right"
|
||||
]
|
||||
''
|
||||
Aligns the `sidebar_filetypes.<name>.text`.
|
||||
'';
|
||||
|
||||
event = helpers.defaultNullOpts.mkStr "BufWinLeave" ''
|
||||
The event which the sidebar executes when leaving.
|
||||
The `event` which is `|autocmd-execute|`d when the sidebar closes.
|
||||
'';
|
||||
|
||||
text = helpers.defaultNullOpts.mkStr null ''
|
||||
The text which will fill the offset.
|
||||
'';
|
||||
};
|
||||
})
|
||||
) { } "Control which filetypes will cause barbar to add an offset.";
|
||||
|
||||
tabpages = helpers.defaultNullOpts.mkBool true ''
|
||||
Enable/disable current/total tabpages indicator (top right corner).
|
||||
'';
|
||||
};
|
||||
|
||||
config =
|
||||
let
|
||||
setupOptions = {
|
||||
inherit (cfg) animation;
|
||||
auto_hide = cfg.autoHide;
|
||||
inherit (cfg) tabpages;
|
||||
inherit (cfg) clickable;
|
||||
exclude_ft = cfg.excludeFileTypes;
|
||||
exclude_name = cfg.excludeFileNames;
|
||||
focus_on_close = cfg.focusOnClose;
|
||||
highlight_alternate = cfg.highlightAlternate;
|
||||
highlight_inactive_file_icons = cfg.highlightInactiveFileIcons;
|
||||
highlight_visible = cfg.highlightVisible;
|
||||
icons =
|
||||
let
|
||||
handleBufferOption =
|
||||
bufferOption: with bufferOption; {
|
||||
buffer_index = bufferIndex;
|
||||
buffer_number = bufferNumber;
|
||||
inherit button;
|
||||
diagnostics =
|
||||
/*
|
||||
Because the keys of this lua table are not strings (but
|
||||
`vim.diagnostic.severity.XXXX`), we have to manually build a raw lua string here.
|
||||
*/
|
||||
let
|
||||
setIcons = filterAttrs (n: v: v != null) cfg.icons.diagnostics;
|
||||
setIconsList = mapAttrsToList (name: value: {
|
||||
key = "vim.diagnostic.severity.${strings.toUpper name}";
|
||||
value = helpers.ifNonNull' value (
|
||||
helpers.toLuaObject {
|
||||
enabled = value.enable;
|
||||
inherit (value) icon;
|
||||
}
|
||||
);
|
||||
}) setIcons;
|
||||
in
|
||||
helpers.mkRaw (
|
||||
"{"
|
||||
+ concatStringsSep "," (map (iconOption: "[${iconOption.key}] = ${iconOption.value}") setIconsList)
|
||||
+ "}"
|
||||
);
|
||||
filetype = with filetype; {
|
||||
custom_color = customColors;
|
||||
enabled = enable;
|
||||
};
|
||||
inherit separator;
|
||||
};
|
||||
|
||||
handleStateOption =
|
||||
stateOption:
|
||||
with stateOption;
|
||||
{
|
||||
modified = handleBufferOption modified;
|
||||
pinned = handleBufferOption pinned;
|
||||
}
|
||||
// (handleBufferOption (getAttrs (attrNames stateOption) stateOption));
|
||||
in
|
||||
(handleStateOption (getAttrs (attrNames stateOptions) cfg.icons))
|
||||
// (genAttrs [
|
||||
"alternate"
|
||||
"current"
|
||||
"inactive"
|
||||
"visible"
|
||||
] (optionName: handleStateOption cfg.icons.${optionName}));
|
||||
inherit (cfg) hide;
|
||||
insert_at_end = cfg.insertAtEnd;
|
||||
insert_at_start = cfg.insertAtStart;
|
||||
maximum_padding = cfg.maximumPadding;
|
||||
minimum_padding = cfg.minimumPadding;
|
||||
maximum_length = cfg.maximumLength;
|
||||
semantic_letters = cfg.semanticLetters;
|
||||
inherit (cfg) letters;
|
||||
no_name_title = cfg.noNameTitle;
|
||||
sidebar_filetypes = cfg.sidebarFiletypes;
|
||||
} // cfg.extraOptions;
|
||||
|
||||
keymaps = flatten (
|
||||
mapAttrsToList (
|
||||
optionName: funcName:
|
||||
let
|
||||
key = cfg.keymaps.${optionName};
|
||||
in
|
||||
optional (key != null) {
|
||||
mode = "n";
|
||||
inherit key;
|
||||
action = "<Cmd>Buffer${funcName}<CR>";
|
||||
options.silent = cfg.keymaps.silent;
|
||||
}
|
||||
) keymapsActions
|
||||
);
|
||||
in
|
||||
mkIf cfg.enable {
|
||||
extraPlugins = with pkgs.vimPlugins; [
|
||||
cfg.package
|
||||
nvim-web-devicons
|
||||
];
|
||||
|
||||
inherit keymaps;
|
||||
|
||||
extraConfigLua = ''
|
||||
require('barbar').setup(${helpers.toLuaObject setupOptions})
|
||||
'';
|
||||
settingsExample = {
|
||||
animation = false;
|
||||
exclude_ft = [
|
||||
"oil"
|
||||
"qf"
|
||||
"fugitive"
|
||||
];
|
||||
exclude_name = [ "UnicodeTable.txt" ];
|
||||
icons = {
|
||||
button = false;
|
||||
separator_at_end = false;
|
||||
};
|
||||
highlight_alternate = true;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -8,11 +8,12 @@
|
|||
enable = true;
|
||||
|
||||
keymaps = {
|
||||
silent = true;
|
||||
|
||||
next = "<TAB>";
|
||||
previous = "<S-TAB>";
|
||||
close = "<C-w>";
|
||||
next.key = "<TAB>";
|
||||
previous.key = "<S-TAB>";
|
||||
close = {
|
||||
key = "<C-w>";
|
||||
options.desc = "Barbar close tab";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -21,51 +22,200 @@
|
|||
plugins.barbar = {
|
||||
enable = true;
|
||||
|
||||
animation = true;
|
||||
autoHide = false;
|
||||
clickable = true;
|
||||
excludeFileTypes = [ ];
|
||||
excludeFileNames = [ ];
|
||||
focusOnClose = "left";
|
||||
hide = { };
|
||||
highlightAlternate = false;
|
||||
highlightInactiveFileIcons = false;
|
||||
highlightVisible = true;
|
||||
icons = {
|
||||
bufferIndex = false;
|
||||
bufferNumber = false;
|
||||
button = "";
|
||||
diagnostics = { };
|
||||
filetype = {
|
||||
enable = true;
|
||||
settings = {
|
||||
animation = true;
|
||||
auto_hide = -1;
|
||||
clickable = true;
|
||||
exclude_ft = [ ];
|
||||
exclude_name = [ ];
|
||||
focus_on_close = "left";
|
||||
hide = {
|
||||
alternate = false;
|
||||
current = false;
|
||||
extensions = false;
|
||||
inactive = false;
|
||||
visible = false;
|
||||
};
|
||||
inactive = {
|
||||
highlight_alternate = false;
|
||||
highlight_inactive_file_icons = false;
|
||||
highlight_visible = true;
|
||||
icons = {
|
||||
buffer_index = false;
|
||||
buffer_number = false;
|
||||
button = "";
|
||||
diagnostics = {
|
||||
"vim.diagnostic.severity.ERROR" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
"vim.diagnostic.severity.HINT" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
"vim.diagnostic.severity.INFO" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
"vim.diagnostic.severity.WARN" = {
|
||||
enabled = false;
|
||||
icon = " ";
|
||||
};
|
||||
};
|
||||
gitsigns = {
|
||||
added = {
|
||||
enabled = true;
|
||||
icon = "+";
|
||||
};
|
||||
changed = {
|
||||
enabled = true;
|
||||
icon = "~";
|
||||
};
|
||||
deleted = {
|
||||
enabled = true;
|
||||
icon = "-";
|
||||
};
|
||||
};
|
||||
filename = true;
|
||||
filetype = {
|
||||
custom_colors = false;
|
||||
enabled = true;
|
||||
};
|
||||
separator = {
|
||||
left = "▎";
|
||||
right = "";
|
||||
separator_at_end = true;
|
||||
};
|
||||
pinned = {
|
||||
button = false;
|
||||
filename = false;
|
||||
separator.right = " ";
|
||||
};
|
||||
alternate = { };
|
||||
current = { };
|
||||
inactive = { };
|
||||
visible = { };
|
||||
preset = "default";
|
||||
};
|
||||
insert_at_start = false;
|
||||
insert_at_end = false;
|
||||
letters = "asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP";
|
||||
maximum_padding = 4;
|
||||
maximum_length = 30;
|
||||
minimum_length = 0;
|
||||
minimum_padding = 1;
|
||||
no_name_title = null;
|
||||
semantic_letters = true;
|
||||
sidebar_filetypes = { };
|
||||
tabpages = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
readme-example = {
|
||||
plugins.barbar = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
animation = true;
|
||||
auto_hide = false;
|
||||
tabpages = true;
|
||||
clickable = true;
|
||||
exclude_ft = [ "javascript" ];
|
||||
exclude_name = [ "package.json" ];
|
||||
focus_on_close = "left";
|
||||
hide = {
|
||||
extensions = true;
|
||||
inactive = true;
|
||||
};
|
||||
highlight_alternate = false;
|
||||
highlight_inactive_file_icons = false;
|
||||
highlight_visible = true;
|
||||
icons = {
|
||||
buffer_index = false;
|
||||
buffer_number = false;
|
||||
button = "";
|
||||
diagnostics = {
|
||||
"vim.diagnostic.severity.ERROR" = {
|
||||
enabled = true;
|
||||
icon = "ff";
|
||||
};
|
||||
"vim.diagnostic.severity.WARN".enabled = false;
|
||||
"vim.diagnostic.severity.INFO".enabled = false;
|
||||
"vim.diagnostic.severity.HINT".enabled = true;
|
||||
};
|
||||
gitsigns = {
|
||||
added = {
|
||||
enabled = true;
|
||||
icon = "+";
|
||||
};
|
||||
changed = {
|
||||
enabled = true;
|
||||
icon = "~";
|
||||
};
|
||||
deleted = {
|
||||
enabled = true;
|
||||
icon = "-";
|
||||
};
|
||||
};
|
||||
filetype = {
|
||||
custom_colors = false;
|
||||
enabled = true;
|
||||
};
|
||||
separator = {
|
||||
left = "▎";
|
||||
right = "";
|
||||
};
|
||||
separator_at_end = true;
|
||||
modified = {
|
||||
button = "●";
|
||||
};
|
||||
pinned = {
|
||||
button = "";
|
||||
filename = true;
|
||||
};
|
||||
preset = "default";
|
||||
alternate = {
|
||||
filetype = {
|
||||
enabled = false;
|
||||
};
|
||||
};
|
||||
current = {
|
||||
buffer_index = true;
|
||||
};
|
||||
inactive = {
|
||||
button = "×";
|
||||
};
|
||||
visible = {
|
||||
modified = {
|
||||
buffer_number = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
modified = {
|
||||
button = "●";
|
||||
};
|
||||
pinned = {
|
||||
button = "";
|
||||
};
|
||||
separator = {
|
||||
left = "▎";
|
||||
right = "";
|
||||
insert_at_end = false;
|
||||
insert_at_start = false;
|
||||
maximum_padding = 1;
|
||||
minimum_padding = 1;
|
||||
maximum_length = 30;
|
||||
minimum_length = 0;
|
||||
semantic_letters = true;
|
||||
sidebar_filetypes = {
|
||||
NvimTree = true;
|
||||
undotree = {
|
||||
text = "undotree";
|
||||
align = "center";
|
||||
};
|
||||
neo-tree = {
|
||||
event = "BufWipeout";
|
||||
};
|
||||
Outline = {
|
||||
event = "BufWinLeave";
|
||||
text = "symbols-outline";
|
||||
align = "right";
|
||||
};
|
||||
};
|
||||
letters = "asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP";
|
||||
no_name_title = null;
|
||||
};
|
||||
insertAtEnd = false;
|
||||
insertAtStart = false;
|
||||
letters = "asdfjkl;ghnmxcvbziowerutyqpASDFJKLGHNMXCVBZIOWERUTYQP";
|
||||
maximumLength = 30;
|
||||
maximumPadding = 4;
|
||||
minimumPadding = 1;
|
||||
noNameTitle = null;
|
||||
semanticLetters = true;
|
||||
sidebarFiletypes = { };
|
||||
tabpages = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue