plugins/airline: switch to settings option

This commit is contained in:
Gaetan Lepage 2024-03-03 00:07:12 +01:00 committed by Gaétan Lepage
parent 601010900b
commit 6a414ea2cd
3 changed files with 291 additions and 359 deletions

View file

@ -99,7 +99,7 @@ in {
colorscheme = mkIf (cfg.colorscheme != null) "base16-${cfg.colorscheme}";
extraPlugins = [cfg.package];
plugins.airline.theme = mkIf cfg.setUpBar "base16";
plugins.airline.settings.theme = mkIf cfg.setUpBar "base16";
plugins.lualine.theme = mkIf cfg.setUpBar "base16";
plugins.lightline.colorscheme = null;

View file

@ -12,165 +12,146 @@ with helpers.vim-plugin;
originalName = "vim-airline";
defaultPackage = pkgs.vimPlugins.vim-airline;
globalPrefix = "airline_";
deprecateExtraConfig = true;
maintainers = [maintainers.GaetanLepage];
options =
# TODO introduced 2024-03-02: remove 2024-05-02
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"sectionA"
"sectionB"
"sectionC"
"sectionX"
"sectionY"
"sectionZ"
"experimental"
"leftSep"
"rightSep"
"detectModified"
"detectPaste"
"detectCrypt"
"detectSpell"
"detectSpelllang"
"detectIminsert"
"inactiveCollapse"
"inactiveAltSep"
"theme"
"themePatchFunc"
"powerlineFonts"
"symbolsAscii"
"modeMap"
"excludeFilenames"
"excludeFiletypes"
"filetypeOverrides"
"excludePreview"
"disableStatusline"
"skipEmptySections"
"highlightingCache"
"focuslostInactive"
"statuslineOntop"
"stlPathStyle"
"sectionCOnlyFilename"
"symbols"
];
settingsOptions =
(
listToAttrs (
map
(
name:
nameValuePair
"section${toUpper name}"
(mkDefaultOpt {
global = "section_${name}";
type = with types;
"section_${name}"
(
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
oneOf
[
rawLua
str
(listOf str)
(attrsOf anything)
];
description = "Configuration for this section.";
})
]
)
"Configuration for this section."
)
)
["a" "b" "c" "x" "y" "z"]
)
)
// {
experimental = mkDefaultOpt {
description = ''
experimental = helpers.defaultNullOpts.mkBool true ''
Enable experimental features.
Currently: Enable Vim9 Script implementation.
Default: `true`
'';
type = types.bool;
};
leftSep = mkDefaultOpt {
global = "left_sep";
description = ''
left_sep = helpers.defaultNullOpts.mkStr ">" ''
The separator used on the left side.
Default: ">"
'';
type = types.str;
};
rightSep = mkDefaultOpt {
global = "right_sep";
description = ''
right_sep = helpers.defaultNullOpts.mkStr "<" ''
The separator used on the right side.
Default: "<"
'';
type = types.str;
};
detectModified = mkDefaultOpt {
global = "detect_modified";
description = ''
detect_modified = helpers.defaultNullOpts.mkBool true ''
Enable modified detection.
Default: `true`
'';
type = types.bool;
};
detectPaste = mkDefaultOpt {
global = "detect_paste";
description = ''
detect_paste = helpers.defaultNullOpts.mkBool true ''
Enable paste detection.
Default: `true`
'';
type = types.bool;
};
detectCrypt = mkDefaultOpt {
global = "detect_crypt";
description = ''
detect_crypt = helpers.defaultNullOpts.mkBool true ''
Enable crypt detection.
Default: `true`
'';
type = types.bool;
};
detectSpell = mkDefaultOpt {
global = "detect_spell";
description = ''
detect_spell = helpers.defaultNullOpts.mkBool true ''
Enable spell detection.
Default: `true`
'';
type = types.bool;
};
detectSpelllang = mkDefaultOpt {
global = "detect_spelllang";
description = ''
Display spelling language when spell detection is enabled (if enough space is available).
detect_spelllang =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
oneOf [
rawLua
bool
(enum ["flag"])
]
)
"true"
''
Display spelling language when spell detection is enabled (if enough space is
available).
Set to 'flag' to get a unicode icon of the relevant country flag instead of the
'spelllang' itself.
Default: `true`
'';
type = with types; either bool (enum ["flag"]);
};
detectIminsert = mkDefaultOpt {
global = "detect_iminsert";
description = ''
detect_iminsert = helpers.defaultNullOpts.mkBool false ''
Enable iminsert detection.
Default: `false`
'';
type = types.bool;
};
inactiveCollapse = mkDefaultOpt {
global = "inactive_collapse";
description = ''
inactive_collapse = helpers.defaultNullOpts.mkBool true ''
Determine whether inactive windows should have the left section collapsed to only the
filename of that buffer.
Default: `true`
'';
type = types.bool;
};
inactiveAltSep = mkDefaultOpt {
global = "inactive_alt_sep";
description = ''
inactive_alt_sep = helpers.defaultNullOpts.mkBool true ''
Use alternative separators for the statusline of inactive windows.
Default: `true`
'';
type = types.bool;
};
theme = mkDefaultOpt {
description = ''
theme = helpers.defaultNullOpts.mkStr "dark" ''
Themes are automatically selected based on the matching colorscheme.
This can be overridden by defining a value.
Note: Only the dark theme is distributed with vim-airline.
For more themes, checkout the vim-airline-themes repository
(https://github.com/vim-airline/vim-airline-themes)
Default: "dark"
'';
type = types.str;
};
themePatchFunc = mkDefaultOpt {
global = "theme_patch_func";
description = ''
theme_patch_func = helpers.mkNullOrStr ''
If you want to patch the airline theme before it gets applied, you can supply the name of
a function where you can modify the palette.
@ -189,65 +170,61 @@ with helpers.vim-plugin;
\'\';
```
'';
type = types.str;
};
powerlineFonts = mkDefaultOpt {
global = "powerline_fonts";
description = ''
powerline_fonts = helpers.defaultNullOpts.mkBool false ''
By default, airline will use unicode symbols if your encoding matches utf-8.
If you want the powerline symbols set this variable to `true`.
Default: `false`
'';
type = types.bool;
};
symbolsAscii = mkDefaultOpt {
global = "symbols_ascii";
description = ''
symbols_ascii = helpers.defaultNullOpts.mkBool false ''
By default, airline will use unicode symbols if your encoding matches utf-8.
If you want to use plain ascii symbols, set this variable: >
Default: `false`
'';
type = types.bool;
};
modeMap = mkDefaultOpt {
global = "mode_map";
description = ''
mode_map =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
maybeRaw (attrsOf str)
)
''
Define the set of text to display for each mode.
Default: see source
'';
type = with types; attrsOf str;
};
excludeFilenames = mkDefaultOpt {
global = "exclude_filenames";
description = ''
exclude_filenames =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
maybeRaw (listOf str)
)
''
Define the set of filename match queries which excludes a window from having its
statusline modified.
Default: see source for current list
'';
type = with types; listOf str;
};
excludeFiletypes = mkDefaultOpt {
global = "exclude_filetypes";
description = ''
exclude_filetypes =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
maybeRaw (listOf str)
)
''
Define the set of filetypes which are excluded from having its window statusline modified.
Default: see source for current list
'';
type = with types; listOf str;
};
filetypeOverrides = mkDefaultOpt {
global = "filetype_overrides";
description = ''
filetype_overrides =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
maybeRaw (attrsOf (listOf str))
)
''
Define the set of names to be displayed instead of a specific filetypes.
Example:
@ -267,68 +244,34 @@ with helpers.vim-plugin;
}
```
'';
type = with types; attrsOf (listOf str);
};
excludePreview = mkDefaultOpt {
global = "exclude_filenames";
description = ''
exclude_preview = helpers.defaultNullOpts.mkBool false ''
Defines whether the preview window should be excluded from having its window statusline
modified (may help with plugins which use the preview window heavily).
Default: `false`
'';
type = types.bool;
};
disableStatusline = mkDefaultOpt {
global = "disable_statusline";
description = ''
disable_statusline = helpers.defaultNullOpts.mkBool false ''
Disable the Airline statusline customization globally.
This setting disables setting the 'statusline' option.
This allows to use e.g. the tabline extension (`|airline-tabline|`) but keep the
'statusline' option totally configurable by a custom configuration.
Default: `false`
'';
type = types.bool;
};
skipEmptySections = mkDefaultOpt {
global = "skip_empty_sections";
description = ''
skip_empty_sections = helpers.defaultNullOpts.mkBool true ''
Do not draw separators for empty sections (only for the active window).
Default: `true`
'';
type = types.bool;
};
highlightingCache = mkDefaultOpt {
global = "highlighting_cache";
description = ''
highlighting_cache = helpers.defaultNullOpts.mkBool false ''
Caches the changes to the highlighting groups, should therefore be faster.
Set this to one, if you experience a sluggish Vim.
Default: `false`
'';
type = types.bool;
};
focuslostInactive = mkDefaultOpt {
global = "focuslost_inactive";
description = ''
focuslost_inactive = helpers.defaultNullOpts.mkBool false ''
Disable airline on FocusLost autocommand (e.g. when Vim loses focus).
Default: `false`
'';
type = types.bool;
};
statuslineOntop = mkDefaultOpt {
global = "statusline_ontop";
description = ''
statusline_ontop = helpers.defaultNullOpts.mkBool false ''
Display the statusline in the tabline (first top line).
Setting this option, allows to use the statusline option to be used by a custom function
@ -341,34 +284,17 @@ with helpers.vim-plugin;
To force updating the tabline on mode changes, call `airline#check_mode()` in your custom
statusline setting: `:set stl=%!airline#check_mode(winnr())` will correctly update the
tabline on mode changes.
Default: `false`
'';
type = types.bool;
};
stlPathStyle = mkDefaultOpt {
global = "stl_path_style";
description = ''
stl_path_style = helpers.defaultNullOpts.mkStr "short" ''
Display a short path in statusline.
Default: "short"
'';
type = types.str;
};
sectionCOnlyFilename = mkDefaultOpt {
global = "section_c_only_filename";
description = ''
section_c_only_filename = helpers.defaultNullOpts.mkBool true ''
Display a only file name in statusline.
Default: `true`
'';
type = types.bool;
};
symbols = mkDefaultOpt {
description = ''
symbols = helpers.mkNullOrOption (with types; attrsOf str) ''
Customize airline symbols.
Example:
@ -383,7 +309,11 @@ with helpers.vim-plugin;
}
```
'';
type = with types; attrsOf str;
};
settingsExample = {
powerline_fonts = true;
theme = "base16";
skip_empty_sections = true;
};
}

View file

@ -7,28 +7,29 @@
plugins.airline = {
enable = true;
sectionA = "foo";
sectionB = "foo";
sectionC = "foo";
sectionX = "foo";
sectionY = "foo";
sectionZ = "foo";
settings = {
section_a = "foo";
section_b = "foo";
section_c = "foo";
section_x = "foo";
section_y = "foo";
section_z = "foo";
experimental = true;
leftSep = ">";
rightSep = "<";
detectModified = true;
detectPaste = true;
detectCrypt = true;
detectSpell = true;
detectSpelllang = true;
detectIminsert = false;
inactiveCollapse = true;
inactiveAltSep = true;
left_sep = ">";
right_sep = "<";
detect_modified = true;
detect_paste = true;
detect_crypt = true;
detect_spell = true;
detect_spelllang = true;
detect_iminsert = false;
inactive_collapse = true;
inactive_alt_sep = true;
theme = "dark";
themePatchFunc = null;
powerlineFonts = false;
symbolsAscii = false;
modeMap = {
theme_patch_func = null;
powerline_fonts = false;
symbols_ascii = false;
mode_map = {
__ = "-";
c = "C";
i = "I";
@ -46,9 +47,9 @@
v = "V";
V = "V";
};
excludeFilenames = [];
excludeFiletypes = [];
filetypeOverrides = {
exclude_filenames = [];
exclude_filetypes = [];
filetype_overrides = {
coc-explorer = ["CoC Explorer" ""];
defx = ["defx" "%{b:defx.paths[0]}"];
fugitive = ["fugitive" "%{airline#util#wrap(airline#extensions#branch#get_head(),80)}"];
@ -61,14 +62,14 @@
vimshell = ["vimshell" "%{vimshell#get_status_string()}"];
vaffle = ["Vaffle" "%{b:vaffle.dir}"];
};
excludePreview = false;
disableStatusline = false;
skipEmptySections = true;
highlightingCache = false;
focuslostInactive = false;
statuslineOntop = false;
stlPathStyle = "short";
sectionCOnlyFilename = true;
exclude_preview = false;
disable_statusline = false;
skip_empty_sections = true;
highlighting_cache = false;
focuslost_inactive = false;
statusline_ontop = false;
stl_path_style = "short";
section_c_only_filename = true;
symbols = {
branch = "";
colnr = " :";
@ -79,4 +80,5 @@
};
};
};
};
}