plugins/barbecue: init + tests (#622)

* doing changes

* fixing stuff

* fixing stuff

* Update plugins/bufferlines/barbecue.nix

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

* Update plugins/bufferlines/barbecue.nix

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

* Update plugins/bufferlines/barbecue.nix

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

* Update tests/test-sources/plugins/bufferlines/barbecue.nix

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

* fix function formatting

* Update plugins/bufferlines/barbecue.nix

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

* fix semicolon in modified

---------

Co-authored-by: Haseeb Majid <haseeb.majid@imaginecurve.com>
Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>
This commit is contained in:
Haseeb Majid 2023-10-06 12:57:31 +01:00 committed by GitHub
parent a0c35acab5
commit eb84003a09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 264 additions and 0 deletions

View file

@ -0,0 +1,201 @@
{
lib,
pkgs,
config,
...
}:
with lib; let
cfg = config.plugins.barbecue;
helpers = import ../helpers.nix {inherit lib;};
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);
in {
options.plugins.barbecue =
helpers.extraOptionsOptions
// {
enable = mkEnableOption "barbecue-nvim";
package = helpers.mkPackageOption "barbecue-nvim" pkgs.vimPlugins.barbecue-nvim;
attachNavic = helpers.defaultNullOpts.mkBool true ''
Whether to attach navic to language servers automatically.
'';
createAutocmd = helpers.defaultNullOpts.mkBool true ''
Whether to create winbar updater autocmd.
'';
includeBuftypes = mkListStr ''[""]'' ''
Buftypes to enable winbar in.
'';
excludeFiletypes = mkListStr ''["netrw" "toggleterm"]'' ''
Filetypes not to enable winbar in.
'';
modifiers = {
dirname = helpers.defaultNullOpts.mkStr ":~:." ''
Filename modifiers applied to dirname.
See: `:help filename-modifiers`
'';
basename = helpers.defaultNullOpts.mkStr "" ''
Filename modifiers applied to basename.
See: `:help filename-modifiers`
'';
};
showDirname = helpers.defaultNullOpts.mkBool true ''
Whether to display path to file.
'';
showBasename = helpers.defaultNullOpts.mkBool true ''
Whether to display file name.
'';
showModified = helpers.defaultNullOpts.mkBool false ''
Whether to replace file icon with the modified symbol when buffer is modified.
'';
modified =
helpers.defaultNullOpts.mkStr
''
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)
'';
showNavic = helpers.defaultNullOpts.mkBool true ''
Whether to show/use navic in the winbar.
'';
leadCustomSection =
helpers.defaultNullOpts.mkStr
''
function()
return " "
end
''
''
Get leading custom section contents.
NOTE: This function shouldn't do any expensive actions as it is run on each render.
'';
customSection =
helpers.defaultNullOpts.mkStr
''
function()
return " "
end
''
''
Get custom section contents.
NOTE: This function shouldn't do any expensive actions as it is run on each render.
'';
theme = helpers.defaultNullOpts.mkStr "auto" ''
Theme to be used for generating highlight groups dynamically.
'';
contextFollowIconColor = helpers.defaultNullOpts.mkBool false ''
Whether context text should follow its icon's color.
'';
symbols = {
modified = helpers.defaultNullOpts.mkStr "" ''
Modification indicator.
'';
ellipsis = helpers.defaultNullOpts.mkStr "" ''
Truncation indicator.
'';
separator = helpers.defaultNullOpts.mkStr "" ''
Entry separator.
'';
};
kinds =
mapAttrs
(
name: default:
helpers.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 = "";
};
};
config = let
setupOptions = with cfg;
{
attach_navic = attachNavic;
create_autocmd = createAutocmd;
include_buftypes = includeBuftypes;
exclude_filetypes = excludeFiletypes;
modifiers = {
inherit
(modifiers)
dirname
basename
;
};
show_dirname = showDirname;
show_basename = showBasename;
show_modified = showModified;
modified = helpers.ifNonNull' modified (helpers.mkRaw modified);
show_navic = showNavic;
lead_custom_section = helpers.ifNonNull' leadCustomSection (helpers.mkRaw leadCustomSection);
custom_section = helpers.ifNonNull' customSection (helpers.mkRaw customSection);
inherit theme;
context_follow_icon_color = contextFollowIconColor;
symbols = {
inherit
(symbols)
modified
ellipsis
separator
;
};
inherit kinds;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraConfigLua = ''
require('barbecue').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -1,6 +1,7 @@
{
imports = [
./bufferlines/barbar.nix
./bufferlines/barbecue.nix
./bufferlines/bufferline.nix
./bufferlines/navic.nix

View file

@ -0,0 +1,62 @@
{
empty = {
plugins.barbecue.enable = true;
};
defaults = {
plugins.barbecue = {
enable = true;
attachNavic = true;
createAutocmd = true;
includeBuftypes = [""];
excludeFiletypes = ["netrw" "toggleterm"];
modifiers = {
dirname = ":~:.";
basename = "";
};
showDirname = true;
showBasename = true;
showModified = true;
modified = "function(bufnr) return vim.bo[bufnr].modified end";
showNavic = true;
leadCustomSection = ''function() return " " end'';
customSection = ''function() return " " end'';
theme = "auto";
contextFollowIconColor = true;
symbols = {
modified = "M";
ellipsis = "///";
separator = "{";
};
kinds = {
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 = "";
};
};
};
}