2021-11-23 16:33:52 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
2022-09-18 11:19:23 +01:00
|
|
|
cfg = config.plugins.bufferline;
|
2021-11-23 16:33:52 +01:00
|
|
|
helpers = import ../helpers.nix { inherit lib; };
|
2021-11-23 18:14:53 +01:00
|
|
|
|
|
|
|
highlight = mkOption {
|
|
|
|
type = types.nullOr (types.submodule ({ ... }: {
|
|
|
|
options = {
|
|
|
|
guifg = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "foreground color";
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
guibg = mkOption {
|
|
|
|
type = types.nullOr types.str;
|
|
|
|
description = "background color";
|
|
|
|
default = null;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}));
|
|
|
|
default = null;
|
|
|
|
};
|
2021-11-23 16:33:52 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
2022-09-18 11:19:23 +01:00
|
|
|
plugins.bufferline = {
|
2023-01-22 03:32:08 +00:00
|
|
|
enable = mkEnableOption "bufferline";
|
2023-01-19 20:39:37 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
description = "Plugin to use for bufferline";
|
|
|
|
default = pkgs.vimPlugins.bufferline-nvim;
|
|
|
|
};
|
2021-11-23 16:33:52 +01:00
|
|
|
numbers = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.lines;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "A lua function customizing the styling of numbers.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
closeCommand = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.lines;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "Command or function run when closing a buffer.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
rightMouseCommand = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.lines;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "Command or function run when right clicking on a buffer.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
leftMouseCommand = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.lines;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "Command or function run when clicking on a buffer.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
middleMouseCommand = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.lines;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "Command or function run when middle clicking on a buffer.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
indicatorIcon = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.str;
|
2023-01-21 18:12:09 +01:00
|
|
|
description = "The Icon shown as a indicator for buffer. Changing it is NOT recommended,
|
2021-11-23 16:33:52 +01:00
|
|
|
this is intended to be an escape hatch for people who cannot bear it for whatever reason.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
bufferCloseIcon = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.str;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "The close icon for each buffer.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
modifiedIcon = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.str;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "The icon indicating a buffer was modified.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
closeIcon = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.str;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "The close icon.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
leftTruncMarker = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
rightTruncMarker = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.str;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
nameFormatter = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.lines;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "A lua function that can be used to modify the buffer's lable. The argument 'buf' containing a name, path and bufnr is supplied.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
maxNameLength = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.int;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "Max length of a buffer name.";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
maxPrefixLength = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.int;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "Max length of a buffer prefix (used when a buffer is de-duplicated)";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
tabSize = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.int;
|
2021-11-23 16:33:52 +01:00
|
|
|
description = "Size of the tabs";
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
diagnostics = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr (types.enum [ false "nvim_lsp" "coc" ]);
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
diagnosticsUpdateInInsert = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
diagnosticsIndicator = mkOption {
|
2023-01-19 20:39:37 +00:00
|
|
|
type = types.nullOr helpers.rawType;
|
2021-11-24 16:29:42 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
customFilter = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.lines;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
showBufferIcons = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
2022-09-18 11:19:23 +01:00
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
showBufferCloseIcons = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
showCloseIcon = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
showTabIndicators = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
persistBufferSort = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
separatorStyle = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr (types.enum [ "slant" "thick" "thin" ]);
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
enforceRegularTabs = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
alwaysShowBufferline = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr types.bool;
|
|
|
|
default = null;
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
sortBy = mkOption {
|
2021-11-24 16:29:42 +01:00
|
|
|
type = types.nullOr (types.enum [ "id" "extension" "relative_directory" "directory" "tabs" ]);
|
|
|
|
default = null;
|
2021-11-23 18:14:53 +01:00
|
|
|
};
|
|
|
|
highlights = mkOption {
|
2022-01-01 15:08:57 +00:00
|
|
|
default = null;
|
2022-09-18 11:19:23 +01:00
|
|
|
type = types.nullOr (types.submodule ({ ... }: {
|
2021-11-23 18:14:53 +01:00
|
|
|
options = {
|
|
|
|
fill = highlight;
|
|
|
|
background = highlight;
|
|
|
|
|
|
|
|
tab = highlight;
|
|
|
|
tabSelected = highlight;
|
|
|
|
tabClose = highlight;
|
|
|
|
|
|
|
|
closeButton = highlight;
|
|
|
|
closeButtonVisible = highlight;
|
|
|
|
closeButtonSelected = highlight;
|
|
|
|
|
|
|
|
bufferVisible = highlight;
|
|
|
|
bufferSelected = highlight;
|
|
|
|
|
|
|
|
diagnostic = highlight;
|
|
|
|
diagnosticVisible = highlight;
|
|
|
|
diagnosticSelected = highlight;
|
|
|
|
|
|
|
|
info = highlight;
|
|
|
|
infoVisible = highlight;
|
|
|
|
infoSelected = highlight;
|
|
|
|
|
|
|
|
infoDiagnostic = highlight;
|
|
|
|
infoDiagnosticVisible = highlight;
|
|
|
|
infoDiagnosticSelected = highlight;
|
|
|
|
|
|
|
|
warning = highlight;
|
|
|
|
warningVisible = highlight;
|
|
|
|
warningSelected = highlight;
|
|
|
|
|
|
|
|
warningDiagnostic = highlight;
|
|
|
|
warningDiagnosticVisible = highlight;
|
|
|
|
warningDiagnosticSelected = highlight;
|
|
|
|
|
|
|
|
error = highlight;
|
|
|
|
errorVisible = highlight;
|
|
|
|
errorSelected = highlight;
|
|
|
|
|
|
|
|
errorDiagnostic = highlight;
|
|
|
|
errorDiagnosticVisible = highlight;
|
|
|
|
errorDiagnosticSelected = highlight;
|
|
|
|
|
|
|
|
modified = highlight;
|
|
|
|
modifiedVisible = highlight;
|
|
|
|
modifiedSelected = highlight;
|
|
|
|
|
|
|
|
duplicate = highlight;
|
|
|
|
duplicateVisible = highlight;
|
|
|
|
duplicateSelected = highlight;
|
|
|
|
|
|
|
|
separator = highlight;
|
|
|
|
separatorVisible = highlight;
|
|
|
|
separatorSelected = highlight;
|
|
|
|
|
|
|
|
indicatorSelected = highlight;
|
|
|
|
|
|
|
|
pick = highlight;
|
|
|
|
pickVisible = highlight;
|
|
|
|
pickSelected = highlight;
|
|
|
|
};
|
2021-11-24 16:29:42 +01:00
|
|
|
}));
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
2023-01-19 20:39:37 +00:00
|
|
|
|
|
|
|
extraOptions = mkOption {
|
|
|
|
type = types.attrs;
|
|
|
|
default = { };
|
|
|
|
description = "Extra options, will override others if defined";
|
|
|
|
};
|
2021-11-23 16:33:52 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
config =
|
|
|
|
let
|
|
|
|
setupOptions = {
|
|
|
|
options = {
|
|
|
|
numbers = cfg.numbers;
|
|
|
|
close_command = cfg.closeCommand;
|
|
|
|
right_mouse_command = cfg.rightMouseCommand;
|
|
|
|
left_mouse_command = cfg.leftMouseCommand;
|
|
|
|
middle_mouse_command = cfg.middleMouseCommand;
|
|
|
|
indicator_icon = cfg.indicatorIcon;
|
|
|
|
buffer_close_icon = cfg.bufferCloseIcon;
|
|
|
|
modified_icon = cfg.modifiedIcon;
|
|
|
|
close_icon = cfg.closeIcon;
|
|
|
|
left_trunc_marker = cfg.leftTruncMarker;
|
|
|
|
right_trunc_marker = cfg.rightTruncMarker;
|
|
|
|
name_formatter = cfg.nameFormatter;
|
|
|
|
max_name_length = cfg.maxNameLength;
|
|
|
|
max_prefix_length = cfg.maxPrefixLength;
|
|
|
|
tab_size = cfg.tabSize;
|
|
|
|
diagnostics = cfg.diagnostics;
|
|
|
|
diagnostics_update_in_insert = cfg.diagnosticsUpdateInInsert;
|
|
|
|
diagnostics_indicator = cfg.diagnosticsIndicator;
|
|
|
|
custom_filter = cfg.customFilter;
|
|
|
|
show_buffer_icons = cfg.showBufferIcons;
|
|
|
|
show_buffer_close_icons = cfg.showBufferCloseIcons;
|
|
|
|
show_close_icon = cfg.showCloseIcon;
|
|
|
|
show_tab_indicators = cfg.showTabIndicators;
|
|
|
|
persist_buffer_sort = cfg.persistBufferSort;
|
|
|
|
separator_style = cfg.separatorStyle;
|
|
|
|
enforce_regular_tabs = cfg.enforceRegularTabs;
|
|
|
|
always_show_bufferline = cfg.alwaysShowBufferline;
|
|
|
|
sort_by = cfg.sortBy;
|
2023-01-19 20:39:37 +00:00
|
|
|
} // cfg.extraOptions;
|
2022-09-18 11:19:23 +01:00
|
|
|
highlights = if builtins.isNull cfg.highlights then null else with cfg.highlights; {
|
|
|
|
fill = fill;
|
|
|
|
background = background;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
tab = tab;
|
|
|
|
tab_selected = tabSelected;
|
|
|
|
tab_close = tabClose;
|
|
|
|
close_button = closeButton;
|
|
|
|
close_button_visible = closeButtonVisible;
|
|
|
|
close_button_selected = closeButtonSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
buffer_visible = bufferVisible;
|
|
|
|
buffer_selected = bufferSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
diagnostic = diagnostic;
|
|
|
|
diagnostic_visible = diagnosticVisible;
|
|
|
|
diagnostic_selected = diagnosticSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
info = info;
|
|
|
|
info_visible = infoVisible;
|
|
|
|
info_selected = infoSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
info_diagnostic = infoDiagnostic;
|
|
|
|
info_diagnostic_visible = infoDiagnosticVisible;
|
|
|
|
info_diagnostic_selected = infoDiagnosticSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
warning = warning;
|
|
|
|
warning_visible = warningVisible;
|
|
|
|
warning_selected = warningSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
warning_diagnostic = warningDiagnostic;
|
|
|
|
warning_diagnostic_visible = warningDiagnosticVisible;
|
|
|
|
warning_diagnostic_selected = warningDiagnosticSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
error = error;
|
|
|
|
error_visible = errorVisible;
|
|
|
|
error_selected = errorSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
error_dagnostic = errorDiagnostic;
|
|
|
|
error_diagnostic_visible = errorDiagnosticVisible;
|
|
|
|
error_diagnostic_selected = errorDiagnosticSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
modified = modified;
|
|
|
|
modified_visible = modifiedVisible;
|
|
|
|
modified_selected = modifiedSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
duplicate = duplicate;
|
|
|
|
duplicate_visible = duplicateVisible;
|
|
|
|
duplicate_selected = duplicateSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
separator = separator;
|
|
|
|
separator_visible = separatorVisible;
|
|
|
|
separator_selected = separatorSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
indicator_selected = indicatorSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
pick = pick;
|
|
|
|
pick_visible = pickVisible;
|
|
|
|
pick_selected = pickSelected;
|
2021-11-23 18:14:53 +01:00
|
|
|
|
2022-09-18 11:19:23 +01:00
|
|
|
};
|
2021-11-23 18:14:53 +01:00
|
|
|
};
|
2022-09-18 11:19:23 +01:00
|
|
|
in
|
|
|
|
mkIf cfg.enable {
|
2021-11-23 16:33:52 +01:00
|
|
|
extraPlugins = with pkgs.vimPlugins; [
|
2023-01-19 20:39:37 +00:00
|
|
|
cfg.package
|
2021-11-23 16:33:52 +01:00
|
|
|
nvim-web-devicons
|
|
|
|
];
|
|
|
|
options.termguicolors = true;
|
|
|
|
extraConfigLua = ''
|
2021-11-23 18:14:53 +01:00
|
|
|
require('bufferline').setup${helpers.toLuaObject setupOptions}
|
2021-11-23 16:33:52 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|