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}"; colorscheme = mkIf (cfg.colorscheme != null) "base16-${cfg.colorscheme}";
extraPlugins = [cfg.package]; 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.lualine.theme = mkIf cfg.setUpBar "base16";
plugins.lightline.colorscheme = null; plugins.lightline.colorscheme = null;

View file

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