plugins/bufferlines: move to by-name

This commit is contained in:
Matt Sturgeon 2024-09-05 02:28:48 +01:00
parent 4491ce4db2
commit 3211a63306
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,646 @@
{
lib,
pkgs,
...
}:
with lib;
let
inherit (lib.nixvim)
defaultNullOpts
keymaps
mkNullOrOption
mkNullOrOption'
mkNullOrStr
;
keymapsActions = {
previous = "Previous";
next = "Next";
movePrevious = "MovePrevious";
moveNext = "MoveNext";
moveStart = "MoveStart";
scrollLeft = "ScrollLeft";
scrollRight = "ScrollRight";
goTo1 = "Goto 1";
goTo2 = "Goto 2";
goTo3 = "Goto 3";
goTo4 = "Goto 4";
goTo5 = "Goto 5";
goTo6 = "Goto 6";
goTo7 = "Goto 7";
goTo8 = "Goto 8";
goTo9 = "Goto 9";
first = "First";
last = "Last";
pin = "Pin";
restore = "Restore";
close = "Close";
closeAllButCurrent = "CloseAllButCurrent";
closeAllButVisible = "CloseAllButVisible";
closeAllButPinned = "CloseAllButPinned";
closeAllButCurrentOrPinned = "CloseAllButCurrentOrPinned";
closeBuffersLeft = "CloseBuffersLeft";
closeBuffersRight = "CloseBuffersRight";
wipeout = "Wipeout";
pick = "Pick";
pickDelete = "PickDelete";
orderByBufferNumber = "OrderByBufferNumber";
orderByName = "OrderByName";
orderByDirectory = "OrderByDirectory";
orderByLanguage = "OrderByLanguage";
orderByWindowNumber = "OrderByWindowNumber";
};
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "barbar";
originalName = "barbar.nvim";
package = "barbar-nvim";
maintainers = [ maintainers.GaetanLepage ];
# 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"
]
);
extraOptions = {
iconsPackage = lib.mkPackageOption pkgs [
"vimPlugins"
"nvim-web-devicons"
] { nullable = true; };
keymaps = mapAttrs (
optionName: funcName:
mkNullOrOption' {
type = keymaps.mkMapOptionSubmodule {
defaults = {
mode = "n";
action = "<Cmd>Buffer${funcName}<CR>";
};
lua = true;
};
apply = v: if v == null then null else keymaps.removeDeprecatedMapAttrs v;
description = "Keymap for function Buffer${funcName}";
}
) keymapsActions;
};
extraConfig = cfg: {
extraPlugins = mkIf (cfg.iconsPackage != null) [ cfg.iconsPackage ];
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 = defaultNullOpts.mkBool true ''
Enable/disable animations.
'';
auto_hide = 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 = defaultNullOpts.mkBool true ''
If set, you can left-click on a tab to switch to that buffer, and middle-click to delete it.
'';
exclude_ft = defaultNullOpts.mkListOf types.str [ ] ''
Excludes filetypes from appearing in the tabs.
'';
exclude_name = defaultNullOpts.mkListOf types.str [ ] ''
Excludes buffers matching name from appearing in the tabs.
'';
focus_on_close =
defaultNullOpts.mkEnumFirstDefault
[
"left"
"previous"
"right"
]
''
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.
'';
hide = {
alternate = defaultNullOpts.mkBool false ''
Controls the visibility of the `|alternate-file|`.
`highlight_alternate` must be `true`.
'';
current = defaultNullOpts.mkBool false ''
Controls the visibility of the current buffer.
'';
extensions = defaultNullOpts.mkBool false ''
Controls the visibility of file extensions.
'';
inactive = defaultNullOpts.mkBool false ''
Controls visibility of `|hidden-buffer|`s and `|inactive-buffer|`s.
'';
visible = defaultNullOpts.mkBool false ''
Controls visibility of `|active-buffer|`s.
`highlight_visible` must be `true`.
'';
};
highlight_alternate = defaultNullOpts.mkBool false ''
Enables highlighting of alternate buffers.
'';
highlight_inactive_file_icons = defaultNullOpts.mkBool false ''
Enables highlighting the file icons of inactive buffers.
'';
highlight_visible = defaultNullOpts.mkBool true ''
Enables highlighting of visible buffers.
'';
icons = {
buffer_index =
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.";
buffer_number = defaultNullOpts.mkNullableWithRaw (
with types;
either bool (enum [
"superscript"
"subscript"
])
) false "If `true`, show the `bufnr` for the associated buffer.";
button = 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 rec {
type = types.submodule {
freeformType = with types; attrsOf anything;
options =
let
mkDiagnosticIconOptions = iconDefault: {
enabled = defaultNullOpts.mkBool false ''
Enable showing diagnostics of this `|diagnostic-severity|` in the 'tabline'.
'';
icon = 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 = lib.nixvim.toRawKeys;
default = { };
defaultText = lib.nixvim.pluginDefaultText {
inherit default;
pluginDefault = {
"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 = " ";
};
};
};
description = ''
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 =
defaultNullOpts.mkAttrsOf
(
with types;
submodule {
freeformType = with types; attrsOf anything;
options = {
enabled = defaultNullOpts.mkBool true ''
Enables showing git changes of this type.
Requires `|gitsigns.nvim|`.
'';
icon = 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 = defaultNullOpts.mkBool true ''
If `true`, show the name of the file.
'';
filetype = {
custom_colors = defaultNullOpts.mkBool false ''
If `true`, the `Buffer<status>Icon` color will be used for icon colors.
'';
enabled = defaultNullOpts.mkBool true ''
Filetype `true`, show the `devicons` for the associated buffer's `filetype`.
'';
};
separator = {
left = defaultNullOpts.mkStr "" ''
The left separator between buffers in the tabline.
'';
right = defaultNullOpts.mkStr "" ''
The right separator between buffers in the tabline.
'';
separator_at_end = 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 = 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 =
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 = mkNullOrOption (with types; 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 = mkNullOrOption (with types; 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 =
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 = mkNullOrOption (with types; 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 =
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 = 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 = defaultNullOpts.mkBool false ''
If `true`, new buffers appear at the end of the list.
Default is to open after the current buffer.
'';
letters = 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.
'';
maximum_padding = defaultNullOpts.mkUnsignedInt 4 ''
Sets the maximum padding width with which to surround each tab.
'';
maximum_length = defaultNullOpts.mkUnsignedInt 30 ''
Sets the maximum buffer name length.
'';
minimum_length = defaultNullOpts.mkUnsignedInt 0 ''
Sets the minimum buffer name length.
'';
minimum_padding = defaultNullOpts.mkUnsignedInt 1 ''
Sets the minimum padding width with which to surround each tab.
'';
no_name_title = defaultNullOpts.mkStr null ''
Sets the name of unnamed buffers.
By default format is `'[Buffer X]'` where `X` is the buffer number.
However, only a static string is accepted here.
'';
semantic_letters = 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 = defaultNullOpts.mkAttrsOf (
with types;
either (enum [ true ]) (submodule {
freeformType = with types; attrsOf anything;
options = {
align =
defaultNullOpts.mkEnumFirstDefault
[
"left"
"center"
"right"
]
''
Aligns the `sidebar_filetypes.<name>.text`.
'';
event = defaultNullOpts.mkStr "BufWinLeave" ''
The event which the sidebar executes when leaving.
The `event` which is `|autocmd-execute|`d when the sidebar closes.
'';
text = defaultNullOpts.mkStr null ''
The text which will fill the offset.
'';
};
})
) { } "Control which filetypes will cause barbar to add an offset.";
tabpages = defaultNullOpts.mkBool true ''
Enable/disable current/total tabpages indicator (top right corner).
'';
};
settingsExample = {
animation = false;
exclude_ft = [
"oil"
"qf"
"fugitive"
];
exclude_name = [ "UnicodeTable.txt" ];
icons = {
button = false;
separator_at_end = false;
};
highlight_alternate = true;
};
}

View file

@ -0,0 +1,190 @@
{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "barbecue";
originalName = "barbecue.nvim";
package = "barbecue-nvim";
maintainers = [ lib.maintainers.khaneliman ];
# TODO: added 2024-09-03 remove after 24.11
optionsRenamedToSettings = [
"attachNavic"
"createAutocmd"
"includeBuftypes"
"excludeFiletypes"
[
"modifiers"
"dirname"
]
[
"modifiers"
"basename"
]
"showDirname"
"showBasename"
"showModified"
"modified"
"showNavic"
"leadCustomSection"
"customSection"
"theme"
"contextFollowIconColor"
[
"symbols"
"modified"
]
[
"symbols"
"ellipsis"
]
[
"symbols"
"separator"
]
"kinds"
];
settingsOptions = {
attach_navic = defaultNullOpts.mkBool true ''
Whether to attach navic to language servers automatically.
'';
create_autocmd = defaultNullOpts.mkBool true ''
Whether to create winbar updater autocmd.
'';
include_buftypes = defaultNullOpts.mkListOf lib.types.str [ "" ] ''
Buftypes to enable winbar in.
'';
exclude_filetypes =
defaultNullOpts.mkListOf lib.types.str
[
"netrw"
"toggleterm"
]
''
Filetypes not to enable winbar in.
'';
modifiers = {
dirname = defaultNullOpts.mkStr ":~:." ''
Filename modifiers applied to dirname.
See: `:help filename-modifiers`
'';
basename = defaultNullOpts.mkStr "" ''
Filename modifiers applied to basename.
See: `:help filename-modifiers`
'';
};
show_dirname = defaultNullOpts.mkBool true ''
Whether to display path to file.
'';
show_basename = defaultNullOpts.mkBool true ''
Whether to display file name.
'';
show_modified = defaultNullOpts.mkBool false ''
Whether to replace file icon with the modified symbol when buffer is modified.
'';
modified =
defaultNullOpts.mkLuaFn
''
function(bufnr)
return vim.bo[bufnr].modified
end
''
''
Get modified status of file.
NOTE: This can be used to get file modified status from SCM (e.g. git)
'';
show_navic = defaultNullOpts.mkBool true ''
Whether to show/use navic in the winbar.
'';
lead_custom_section =
defaultNullOpts.mkLuaFn
''
function()
return " "
end
''
''
Get leading custom section contents.
NOTE: This function shouldn't do any expensive actions as it is run on each render.
'';
custom_section =
defaultNullOpts.mkLuaFn
''
function()
return " "
end
''
''
Get custom section contents.
NOTE: This function shouldn't do any expensive actions as it is run on each render.
'';
theme = defaultNullOpts.mkStr "auto" ''
Theme to be used for generating highlight groups dynamically.
'';
context_follow_icon_color = defaultNullOpts.mkBool false ''
Whether context text should follow its icon's color.
'';
symbols = {
modified = defaultNullOpts.mkStr "" ''
Modification indicator.
'';
ellipsis = defaultNullOpts.mkStr "" ''
Truncation indicator.
'';
separator = defaultNullOpts.mkStr "" ''
Entry separator.
'';
};
kinds = lib.mapAttrs (name: default: defaultNullOpts.mkStr default "icon for ${name}.") {
File = "";
Module = "";
Namespace = "";
Package = "";
Class = "";
Method = "";
Property = "";
Field = "";
Constructor = "";
Enum = "";
Interface = "";
Function = "";
Variable = "";
Constant = "";
String = "";
Number = "";
Boolean = "";
Array = "";
Object = "";
Key = "";
Null = "";
EnumMember = "";
Struct = "";
Event = "";
Operator = "";
TypeParameter = "";
};
};
}

View file

@ -0,0 +1,668 @@
{
lib,
pkgs,
...
}:
let
inherit (lib.nixvim) defaultNullOpts nixvimTypes mkSettingsRenamedOptionModules;
types = nixvimTypes;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "bufferline";
originalName = "bufferline.nvim";
package = "bufferline-nvim";
maintainers = [ lib.maintainers.khaneliman ];
# TODO: introduced 2024-08-12: remove after 24.11
#
# NOTE: Old options are equivalent to `settings.options` and
# the old highlight options are equivalent to `settings.highlight`,
# therefore we can't just use `optionsRenamedToSettings`.
imports =
let
oldOptions = [
"mode"
"themable"
"numbers"
"bufferCloseIcon"
"modifiedIcon"
"closeIcon"
"closeCommand"
"leftMouseCommand"
"rightMouseCommand"
"middleMouseCommand"
"indicator"
"leftTruncMarker"
"rightTruncMarker"
"separatorStyle"
"nameFormatter"
"truncateNames"
"tabSize"
"maxNameLength"
"colorIcons"
"showBufferIcons"
"showBufferCloseIcons"
"getElementIcon"
"showCloseIcon"
"showTabIndicators"
"showDuplicatePrefix"
"enforceRegularTabs"
"alwaysShowBufferline"
"persistBufferSort"
"maxPrefixLength"
"sortBy"
"diagnostics"
"diagnosticsIndicator"
"offsets"
[
"groups"
"items"
]
[
"groups"
"options"
"toggleHiddenOnEnter"
]
[
"hover"
"enabled"
]
[
"hover"
"reveal"
]
[
"hover"
"delay"
]
[
"debug"
"logging"
]
"customFilter"
];
oldHighlightOptions = [
"fill"
"background"
"tab"
"tabSelected"
"tabSeparator"
"tabSeparatorSelected"
"tabClose"
"closeButton"
"closeButtonVisible"
"closeButtonSelected"
"bufferVisible"
"bufferSelected"
"numbers"
"numbersVisible"
"numbersSelected"
"diagnostic"
"diagnosticVisible"
"diagnosticSelected"
"hint"
"hintVisible"
"hintSelected"
"hintDiagnostic"
"hintDiagnosticVisible"
"hintDiagnosticSelected"
"info"
"infoVisible"
"infoSelected"
"infoDiagnostic"
"infoDiagnosticVisible"
"infoDiagnosticSelected"
"warning"
"warningVisible"
"warningSelected"
"warningDiagnostic"
"warningDiagnosticVisible"
"warningDiagnosticSelected"
"error"
"errorVisible"
"errorSelected"
"errorDiagnostic"
"errorDiagnosticVisible"
"errorDiagnosticSelected"
"modified"
"modifiedVisible"
"modifiedSelected"
"duplicate"
"duplicateVisible"
"duplicateSelected"
"separator"
"separatorVisible"
"separatorSelected"
"indicatorVisible"
"indicatorSelected"
"pick"
"pickVisible"
"pickSelected"
"offsetSeparator"
];
basePluginPath = [
"plugins"
"bufferline"
];
settingsPath = basePluginPath ++ [ "settings" ];
optionsPath = settingsPath ++ [ "options" ];
oldHighlightsPath = basePluginPath ++ [ "highlights" ];
newHighlightsPath = settingsPath ++ [ "highlights" ];
in
[
(lib.mkRenamedOptionModule (basePluginPath ++ [ "extraOptions" ]) optionsPath)
(lib.mkRenamedOptionModule (basePluginPath ++ [ "diagnosticsUpdateInInsert" ]) [
"diagnostics"
"update_in_insert"
])
(lib.mkRenamedOptionModule (oldHighlightsPath ++ [ "trunkMarker" ]) (
newHighlightsPath ++ [ "trunc_marker" ]
))
]
++ mkSettingsRenamedOptionModules basePluginPath optionsPath oldOptions
++ mkSettingsRenamedOptionModules oldHighlightsPath newHighlightsPath oldHighlightOptions;
settingsOptions = {
options = {
mode =
defaultNullOpts.mkEnumFirstDefault
[
"buffers"
"tabs"
]
''
Mode - set to `tabs` to only show tabpages instead.
'';
themable = defaultNullOpts.mkBool true ''
Whether or not bufferline highlights can be overridden externally.
'';
numbers =
defaultNullOpts.mkEnumFirstDefault
[
"none"
"ordinal"
"buffer_id"
"both"
]
''
Customize the styling of numbers.
Can also be a lua function:
```
function({ ordinal, id, lower, raise }): string
```
'';
buffer_close_icon = defaultNullOpts.mkStr "" ''
The close icon for each buffer.
'';
modified_icon = defaultNullOpts.mkStr "" ''
The icon indicating a buffer was modified.
'';
close_icon = defaultNullOpts.mkStr "" "The close icon.";
close_command = defaultNullOpts.mkStr "bdelete! %d" ''
Command or function run when closing a buffer.
'';
custom_filter = defaultNullOpts.mkLuaFn null ''
```
fun(buf: number, bufnums: number[]): boolean
```
NOTE: this will be called a lot so don't do any heavy processing here.
'';
left_mouse_command = defaultNullOpts.mkStr "buffer %d" ''
Command or function run when clicking on a buffer.
'';
right_mouse_command = defaultNullOpts.mkStr "bdelete! %d" ''
Command or function run when right clicking on a buffer.
'';
middle_mouse_command = defaultNullOpts.mkStr null ''
Command or function run when middle clicking on a buffer.
'';
indicator = {
icon = defaultNullOpts.mkStr "" ''
Indicator icon.
This should be omitted if indicator style is not `icon`.
'';
style = defaultNullOpts.mkEnumFirstDefault [
"icon"
"underline"
"none"
] "Indicator style.";
};
left_trunc_marker = defaultNullOpts.mkStr "" ''
Left truncation marker.
'';
right_trunc_marker = defaultNullOpts.mkStr "" ''
Right truncation marker.
'';
separator_style = defaultNullOpts.mkNullable (
with types;
oneOf [
(enum [
"slant"
"padded_slant"
"slope"
"padded_slope"
"thick"
"thin"
])
(listOfLen str 2)
rawLua
]
) "thin" "Separator style.";
name_formatter = defaultNullOpts.mkLuaFn null ''
A lua function that can be used to modify the buffer's label.
The argument 'buf' containing a name, path and bufnr is supplied.
'';
truncate_names = defaultNullOpts.mkBool true ''
Whether to truncate names.
'';
tab_size = defaultNullOpts.mkInt 18 ''
Size of the tabs.
'';
max_name_length = defaultNullOpts.mkInt 18 ''
Max length of a buffer name.
'';
color_icons = defaultNullOpts.mkBool true ''
Whether or not to add the filetype icon highlights.
'';
show_buffer_icons = defaultNullOpts.mkBool true ''
Show buffer icons.
'';
show_buffer_close_icons = defaultNullOpts.mkBool true ''
Show buffer close icons.
'';
get_element_icon = defaultNullOpts.mkLuaFn null ''
Lua function returning an element icon.
```
fun(opts: IconFetcherOpts): string?, string?
```
'';
show_close_icon = defaultNullOpts.mkBool true ''
Whether to show the close icon.
'';
show_tab_indicators = defaultNullOpts.mkBool true ''
Whether to show the tab indicators.
'';
show_duplicate_prefix = defaultNullOpts.mkBool true ''
Whether to show the prefix of duplicated files.
'';
duplicates_across_groups = defaultNullOpts.mkBool true ''
Whether to consider duplicate paths in different groups as duplicates.
'';
enforce_regular_tabs = defaultNullOpts.mkBool false ''
Whether to enforce regular tabs.
'';
always_show_bufferline = defaultNullOpts.mkBool true ''
Whether to always show the bufferline.
'';
auto_toggle_bufferline = defaultNullOpts.mkBool true ''
Whether to automatically toggle bufferline.
'';
persist_buffer_sort = defaultNullOpts.mkBool true ''
Whether to make the buffer sort persistent.
'';
move_wraps_at_ends = defaultNullOpts.mkBool true ''
Whether or not the move command "wraps" at the first or last position.
'';
max_prefix_length = defaultNullOpts.mkInt 15 ''
Maximum prefix length used when a buffer is de-duplicated.
'';
sort_by =
defaultNullOpts.mkNullableWithRaw
(types.enum [
"insert_after_current"
"insert_at_end"
"id"
"extension"
"relative_directory"
"directory"
"tabs"
])
"id"
''
How to sort the buffers.
Also accepts a function with a signature `function(buffer_a, buffer_b)` allowing you to compare with custom logic.
'';
diagnostics =
defaultNullOpts.mkEnumFirstDefault
[
false
"nvim_lsp"
"coc"
]
''
Diagnostics provider.
Set to `false` to disable.
'';
diagnostics_indicator = defaultNullOpts.mkLuaFn null ''
Either `null` or a function that returns the diagnostics indicator.
'';
diagnostics_update_on_event = defaultNullOpts.mkBool true ''
Use nvim's diagnostic handler.
'';
offsets = defaultNullOpts.mkNullable (types.listOf types.attrs) null "offsets";
groups = {
items = defaultNullOpts.mkListOf types.attrs [ ] "List of groups.";
options = {
toggle_hidden_on_enter = defaultNullOpts.mkBool true ''
Re-open hidden groups on `BufEnter`.
'';
};
};
hover = {
enabled = defaultNullOpts.mkBool false "Whether to enable hover.";
reveal = defaultNullOpts.mkListOf types.str [ ] "Whether to reveal on hover.";
delay = defaultNullOpts.mkInt 200 "Delay to reveal on hover.";
};
debug = {
logging = defaultNullOpts.mkBool false "Whether to enable logging.";
};
};
highlights =
let
highlightsOptions = [
"fill"
"background"
"tab"
"tab_selected"
"tab_separator"
"tab_separator_selected"
"tab_close"
"close_button"
"close_button_visible"
"close_button_selected"
"buffer_visible"
"buffer_selected"
"numbers"
"numbers_visible"
"numbers_selected"
"diagnostic"
"diagnostic_visible"
"diagnostic_selected"
"hint"
"hint_visible"
"hint_selected"
"hint_diagnostic"
"hint_diagnostic_visible"
"hint_diagnostic_selected"
"info"
"info_visible"
"info_selected"
"info_diagnostic"
"info_diagnostic_visible"
"info_diagnostic_selected"
"warning"
"warning_visible"
"warning_selected"
"warning_diagnostic"
"warning_diagnostic_visible"
"warning_diagnostic_selected"
"error"
"error_visible"
"error_selected"
"error_diagnostic"
"error_diagnostic_visible"
"error_diagnostic_selected"
"modified"
"modified_visible"
"modified_selected"
"duplicate"
"duplicate_visible"
"duplicate_selected"
"separator"
"separator_visible"
"separator_selected"
"indicator_visible"
"indicator_selected"
"pick"
"pick_visible"
"pick_selected"
"offset_separator"
"trunc_marker"
];
in
lib.genAttrs highlightsOptions (
name:
defaultNullOpts.mkHighlight { } null ''
Highlight group definition for ${name}.
''
);
};
settingsExample = {
options = {
mode = "buffers";
always_show_bufferline = true;
buffer_close_icon = "󰅖";
close_icon = "";
diagnostics = "nvim_lsp";
diagnostics_indicator = # Lua
''
function(count, level, diagnostics_dict, context)
local s = ""
for e, n in pairs(diagnostics_dict) do
local sym = e == "error" and " "
or (e == "warning" and " " or "" )
if(sym ~= "") then
s = s .. " " .. n .. sym
end
end
return s
end
'';
enforce_regular_tabs = false;
groups = {
options = {
toggle_hidden_on_enter = true;
};
items = [
{
name = "Tests";
highlight = {
underline = true;
fg = "#a6da95";
sp = "#494d64";
};
priority = 2;
matcher.__raw = # Lua
''
function(buf)
return buf.name:match('%test') or buf.name:match('%.spec')
end
'';
}
{
name = "Docs";
highlight = {
undercurl = true;
fg = "#ffffff";
sp = "#494d64";
};
auto_close = false;
matcher.__raw = # Lua
''
function(buf)
return buf.name:match('%.md') or buf.name:match('%.txt')
end
'';
}
];
};
indicator = {
style = "icon";
icon = "";
};
left_trunc_marker = "";
max_name_length = 18;
max_prefix_length = 15;
modified_icon = "";
numbers.__raw = # Lua
''
function(opts)
return string.format('%s·%s', opts.raise(opts.id), opts.lower(opts.ordinal))
end
'';
persist_buffer_sort = true;
right_trunc_marker = "";
show_buffer_close_icons = true;
show_buffer_icons = true;
show_close_icon = true;
show_tab_indicators = true;
tab_size = 18;
offsets = [
{
filetype = "neo-tree";
text = "File Explorer";
text_align = "center";
highlight = "Directory";
}
];
custom_filter = # Lua
''
function(buf_number, buf_numbers)
-- filter out filetypes you don't want to see
if vim.bo[buf_number].filetype ~= "<i-dont-want-to-see-this>" then
return true
end
-- filter out by buffer name
if vim.fn.bufname(buf_number) ~= "<buffer-name-I-dont-want>" then
return true
end
-- filter out based on arbitrary rules
-- e.g. filter out vim wiki buffer from tabline in your work repo
if vim.fn.getcwd() == "<work-repo>" and vim.bo[buf_number].filetype ~= "wiki" then
return true
end
-- filter out by it's index number in list (don't show first buffer)
if buf_numbers[1] ~= buf_number then
return true
end
end
'';
get_element_icon = # Lua
''
function(element)
-- element consists of {filetype: string, path: string, extension: string, directory: string}
-- This can be used to change how bufferline fetches the icon
-- for an element e.g. a buffer or a tab.
-- e.g.
local icon, hl = require('nvim-web-devicons').get_icon_by_filetype(opts.filetype, { default = false })
return icon, hl
end
'';
separator_style = [
"|"
"|"
];
sort_by.__raw = ''
function(buffer_a, buffer_b)
local modified_a = vim.fn.getftime(buffer_a.path)
local modified_b = vim.fn.getftime(buffer_b.path)
return modified_a > modified_b
end
'';
};
highlights =
let
commonBgColor = "#363a4f";
commonFgColor = "#1e2030";
commonSelectedAttrs = {
bg = commonBgColor;
};
selectedAttrsSet = builtins.listToAttrs (
map
(name: {
inherit name;
value = commonSelectedAttrs;
})
[
"buffer_selected"
"tab_selected"
"numbers_selected"
]
);
in
selectedAttrsSet
// {
fill = {
bg = commonFgColor;
};
separator = {
fg = commonFgColor;
};
separator_visible = {
fg = commonFgColor;
};
separator_selected = {
bg = commonBgColor;
fg = commonFgColor;
};
};
};
extraOptions = {
iconsPackage = lib.mkPackageOption pkgs [
"vimPlugins"
"nvim-web-devicons"
] { nullable = true; };
};
extraConfig = cfg: {
extraPlugins = lib.mkIf (cfg.iconsPackage != null) [ cfg.iconsPackage ];
opts.termguicolors = true;
};
}

View file

@ -0,0 +1,120 @@
{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "navic";
originalName = "nvim-navic";
luaName = "nvim-navic";
package = "nvim-navic";
maintainers = [ lib.maintainers.khaneliman ];
# TODO: added 2024-09-03 remove after 24.11
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"icons"
[
"lsp"
"autoAttach"
]
[
"lsp"
"preference"
]
"highlight"
"separator"
"depthLimit"
"depthLimitIndicator"
"safeOutput"
"lazyUpdateContext"
"click"
];
settingsOptions = {
icons = lib.mapAttrs (name: default: defaultNullOpts.mkStr default "icon for ${name}.") {
File = "󰈙 ";
Module = " ";
Namespace = "󰌗 ";
Package = " ";
Class = "󰌗 ";
Method = "󰆧 ";
Property = " ";
Field = " ";
Constructor = " ";
Enum = "󰕘";
Interface = "󰕘";
Function = "󰊕 ";
Variable = "󰆧 ";
Constant = "󰏿 ";
String = "󰀬 ";
Number = "󰎠 ";
Boolean = " ";
Array = "󰅪 ";
Object = "󰅩 ";
Key = "󰌋 ";
Null = "󰟢 ";
EnumMember = " ";
Struct = "󰌗 ";
Event = " ";
Operator = "󰆕 ";
TypeParameter = "󰊄 ";
};
lsp = {
auto_attach = defaultNullOpts.mkBool false ''
Enable to have nvim-navic automatically attach to every LSP for current buffer. Its disabled by default.
'';
preference = defaultNullOpts.mkListOf' {
type = lib.types.str;
pluginDefault = [ ];
example = [
"clangd"
"pyright"
];
description = ''
Table ranking lsp_servers. Lower the index, higher the priority of the server. If there are more than one server attached to a buffer. In the example below will prefer clangd over pyright
'';
};
};
highlight = defaultNullOpts.mkBool false ''
If set to true, will add colors to icons and text as defined by highlight groups NavicIcons* (NavicIconsFile, NavicIconsModule.. etc.), NavicText and NavicSeparator.
'';
separator = defaultNullOpts.mkStr " > " ''
Icon to separate items. to use between items.
'';
depth_limit = defaultNullOpts.mkInt 0 ''
Maximum depth of context to be shown. If the context hits this depth limit, it is truncated.
'';
depth_limit_indicator = defaultNullOpts.mkStr ".." ''
Icon to indicate that depth_limit was hit and the shown context is truncated.
'';
safe_output = defaultNullOpts.mkBool true ''
Sanitize the output for use in statusline and winbar.
'';
lazy_update_context = defaultNullOpts.mkBool false ''
If true, turns off context updates for the "CursorMoved" event.
'';
click = defaultNullOpts.mkBool false ''
Single click to goto element, double click to open nvim-navbuddy on the clicked element.
'';
};
settingsExample = {
lsp = {
auto_attach = true;
preference = [
"clangd"
"tsserver"
];
};
};
}