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,242 +12,219 @@ 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; (
oneOf with helpers.nixvimTypes;
[ oneOf
str [
(listOf str) rawLua
(attrsOf anything) str
]; (listOf str)
description = "Configuration for this section."; (attrsOf anything)
}) ]
)
"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` left_sep = helpers.defaultNullOpts.mkStr ">" ''
''; The separator used on the left side.
type = types.bool; '';
};
leftSep = mkDefaultOpt { right_sep = helpers.defaultNullOpts.mkStr "<" ''
global = "left_sep"; The separator used on the right side.
description = '' '';
The separator used on the left side.
Default: ">" detect_modified = helpers.defaultNullOpts.mkBool true ''
''; Enable modified detection.
type = types.str; '';
};
rightSep = mkDefaultOpt { detect_paste = helpers.defaultNullOpts.mkBool true ''
global = "right_sep"; Enable paste detection.
description = '' '';
The separator used on the right side.
Default: "<" detect_crypt = helpers.defaultNullOpts.mkBool true ''
''; Enable crypt detection.
type = types.str; '';
};
detectModified = mkDefaultOpt { detect_spell = helpers.defaultNullOpts.mkBool true ''
global = "detect_modified"; Enable spell detection.
description = '' '';
Enable modified detection.
Default: `true` detect_spelllang =
''; helpers.defaultNullOpts.mkNullable
type = types.bool; (
}; with helpers.nixvimTypes;
oneOf [
detectPaste = mkDefaultOpt { rawLua
global = "detect_paste"; bool
description = '' (enum ["flag"])
Enable paste detection. ]
)
Default: `true` "true"
''; ''
type = types.bool; Display spelling language when spell detection is enabled (if enough space is
}; available).
detectCrypt = mkDefaultOpt {
global = "detect_crypt";
description = ''
Enable crypt detection.
Default: `true`
'';
type = types.bool;
};
detectSpell = mkDefaultOpt {
global = "detect_spell";
description = ''
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).
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"; Enable iminsert detection.
description = '' '';
Enable iminsert detection.
Default: `false` inactive_collapse = helpers.defaultNullOpts.mkBool true ''
''; Determine whether inactive windows should have the left section collapsed to only the
type = types.bool; filename of that buffer.
}; '';
inactiveCollapse = mkDefaultOpt { inactive_alt_sep = helpers.defaultNullOpts.mkBool true ''
global = "inactive_collapse"; Use alternative separators for the statusline of inactive windows.
description = '' '';
Determine whether inactive windows should have the left section collapsed to only the
filename of that buffer.
Default: `true` theme = helpers.defaultNullOpts.mkStr "dark" ''
''; Themes are automatically selected based on the matching colorscheme.
type = types.bool; This can be overridden by defining a value.
};
inactiveAltSep = mkDefaultOpt { Note: Only the dark theme is distributed with vim-airline.
global = "inactive_alt_sep"; For more themes, checkout the vim-airline-themes repository
description = '' (https://github.com/vim-airline/vim-airline-themes)
Use alternative separators for the statusline of inactive windows. '';
Default: `true` theme_patch_func = helpers.mkNullOrStr ''
''; If you want to patch the airline theme before it gets applied, you can supply the name of
type = types.bool; a function where you can modify the palette.
};
theme = mkDefaultOpt { Example: "AirlineThemePatch"
description = ''
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. Then, define this function using `extraConfigVim`:
For more themes, checkout the vim-airline-themes repository ```nix
(https://github.com/vim-airline/vim-airline-themes) extraConfigVim = \'\'
function! AirlineThemePatch(palette)
if g:airline_theme == 'badwolf'
for colors in values(a:palette.inactive)
let colors[3] = 245
endfor
endif
endfunction
\'\';
```
'';
Default: "dark" powerline_fonts = helpers.defaultNullOpts.mkBool false ''
''; By default, airline will use unicode symbols if your encoding matches utf-8.
type = types.str; If you want the powerline symbols set this variable to `true`.
}; '';
themePatchFunc = mkDefaultOpt { symbols_ascii = helpers.defaultNullOpts.mkBool false ''
global = "theme_patch_func"; By default, airline will use unicode symbols if your encoding matches utf-8.
description = '' If you want to use plain ascii symbols, set this variable: >
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.
Example: "AirlineThemePatch" mode_map =
helpers.mkNullOrOption
Then, define this function using `extraConfigVim`: (
```nix with helpers.nixvimTypes;
extraConfigVim = \'\' maybeRaw (attrsOf str)
function! AirlineThemePatch(palette) )
if g:airline_theme == 'badwolf' ''
for colors in values(a:palette.inactive)
let colors[3] = 245
endfor
endif
endfunction
\'\';
```
'';
type = types.str;
};
powerlineFonts = mkDefaultOpt {
global = "powerline_fonts";
description = ''
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 = ''
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 = ''
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,123 +244,76 @@ with helpers.vim-plugin;
} }
``` ```
''; '';
type = with types; attrsOf (listOf str);
};
excludePreview = mkDefaultOpt { exclude_preview = helpers.defaultNullOpts.mkBool false ''
global = "exclude_filenames"; Defines whether the preview window should be excluded from having its window statusline
description = '' modified (may help with plugins which use the preview window heavily).
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` disable_statusline = helpers.defaultNullOpts.mkBool false ''
''; Disable the Airline statusline customization globally.
type = types.bool;
};
disableStatusline = mkDefaultOpt { This setting disables setting the 'statusline' option.
global = "disable_statusline"; This allows to use e.g. the tabline extension (`|airline-tabline|`) but keep the
description = '' 'statusline' option totally configurable by a custom configuration.
Disable the Airline statusline customization globally. '';
This setting disables setting the 'statusline' option. skip_empty_sections = helpers.defaultNullOpts.mkBool true ''
This allows to use e.g. the tabline extension (`|airline-tabline|`) but keep the Do not draw separators for empty sections (only for the active window).
'statusline' option totally configurable by a custom configuration. '';
Default: `false` highlighting_cache = helpers.defaultNullOpts.mkBool false ''
''; Caches the changes to the highlighting groups, should therefore be faster.
type = types.bool; Set this to one, if you experience a sluggish Vim.
}; '';
skipEmptySections = mkDefaultOpt { focuslost_inactive = helpers.defaultNullOpts.mkBool false ''
global = "skip_empty_sections"; Disable airline on FocusLost autocommand (e.g. when Vim loses focus).
description = '' '';
Do not draw separators for empty sections (only for the active window).
Default: `true` statusline_ontop = helpers.defaultNullOpts.mkBool false ''
''; Display the statusline in the tabline (first top line).
type = types.bool;
};
highlightingCache = mkDefaultOpt { Setting this option, allows to use the statusline option to be used by a custom function
global = "highlighting_cache"; or another plugin, since airline won't change it.
description = ''
Caches the changes to the highlighting groups, should therefore be faster.
Set this to one, if you experience a sluggish Vim.
Default: `false` Note: This setting is experimental and works on a best effort approach.
''; Updating the statusline might not always happen as fast as needed, but that is a
type = types.bool; limitation, that comes from Vim.
}; airline tries to force an update if needed, but it might not always work as expected.
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.
'';
focuslostInactive = mkDefaultOpt { stl_path_style = helpers.defaultNullOpts.mkStr "short" ''
global = "focuslost_inactive"; Display a short path in statusline.
description = '' '';
Disable airline on FocusLost autocommand (e.g. when Vim loses focus).
Default: `false` section_c_only_filename = helpers.defaultNullOpts.mkBool true ''
''; Display a only file name in statusline.
type = types.bool; '';
};
statuslineOntop = mkDefaultOpt { symbols = helpers.mkNullOrOption (with types; attrsOf str) ''
global = "statusline_ontop"; Customize airline symbols.
description = ''
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 Example:
or another plugin, since airline won't change it. ```nix
{
Note: This setting is experimental and works on a best effort approach. branch = "";
Updating the statusline might not always happen as fast as needed, but that is a colnr = " :";
limitation, that comes from Vim. readonly = "";
airline tries to force an update if needed, but it might not always work as expected. linenr = " :";
To force updating the tabline on mode changes, call `airline#check_mode()` in your custom maxlinenr = " ";
statusline setting: `:set stl=%!airline#check_mode(winnr())` will correctly update the dirty= "";
tabline on mode changes. }
```
Default: `false` '';
'';
type = types.bool;
};
stlPathStyle = mkDefaultOpt {
global = "stl_path_style";
description = ''
Display a short path in statusline.
Default: "short"
'';
type = types.str;
};
sectionCOnlyFilename = mkDefaultOpt {
global = "section_c_only_filename";
description = ''
Display a only file name in statusline.
Default: `true`
'';
type = types.bool;
};
symbols = mkDefaultOpt {
description = ''
Customize airline symbols.
Example:
```nix
{
branch = "";
colnr = " :";
readonly = "";
linenr = " :";
maxlinenr = " ";
dirty= "";
}
```
'';
type = with types; attrsOf str;
};
}; };
settingsExample = {
powerline_fonts = true;
theme = "base16";
skip_empty_sections = true;
};
} }

View file

@ -7,75 +7,77 @@
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";
experimental = true; section_z = "foo";
leftSep = ">"; experimental = true;
rightSep = "<"; left_sep = ">";
detectModified = true; right_sep = "<";
detectPaste = true; detect_modified = true;
detectCrypt = true; detect_paste = true;
detectSpell = true; detect_crypt = true;
detectSpelllang = true; detect_spell = true;
detectIminsert = false; detect_spelllang = true;
inactiveCollapse = true; detect_iminsert = false;
inactiveAltSep = true; inactive_collapse = true;
theme = "dark"; inactive_alt_sep = true;
themePatchFunc = null; theme = "dark";
powerlineFonts = false; theme_patch_func = null;
symbolsAscii = false; powerline_fonts = false;
modeMap = { symbols_ascii = false;
__ = "-"; mode_map = {
c = "C"; __ = "-";
i = "I"; c = "C";
ic = "I"; i = "I";
ix = "I"; ic = "I";
n = "N"; ix = "I";
multi = "M"; n = "N";
ni = "N"; multi = "M";
no = "N"; ni = "N";
R = "R"; no = "N";
Rv = "R"; R = "R";
s = "S"; Rv = "R";
S = "S"; s = "S";
t = "T"; S = "S";
v = "V"; t = "T";
V = "V"; v = "V";
}; V = "V";
excludeFilenames = []; };
excludeFiletypes = []; exclude_filenames = [];
filetypeOverrides = { exclude_filetypes = [];
coc-explorer = ["CoC Explorer" ""]; filetype_overrides = {
defx = ["defx" "%{b:defx.paths[0]}"]; coc-explorer = ["CoC Explorer" ""];
fugitive = ["fugitive" "%{airline#util#wrap(airline#extensions#branch#get_head(),80)}"]; defx = ["defx" "%{b:defx.paths[0]}"];
gundo = ["Gundo" ""]; fugitive = ["fugitive" "%{airline#util#wrap(airline#extensions#branch#get_head(),80)}"];
help = ["Help" "%f"]; gundo = ["Gundo" ""];
minibufexpl = ["MiniBufExplorer" ""]; help = ["Help" "%f"];
startify = ["startify" ""]; minibufexpl = ["MiniBufExplorer" ""];
vim-plug = ["Plugins" ""]; startify = ["startify" ""];
vimfiler = ["vimfiler" "%{vimfiler#get_status_string()}"]; vim-plug = ["Plugins" ""];
vimshell = ["vimshell" "%{vimshell#get_status_string()}"]; vimfiler = ["vimfiler" "%{vimfiler#get_status_string()}"];
vaffle = ["Vaffle" "%{b:vaffle.dir}"]; vimshell = ["vimshell" "%{vimshell#get_status_string()}"];
}; vaffle = ["Vaffle" "%{b:vaffle.dir}"];
excludePreview = false; };
disableStatusline = false; exclude_preview = false;
skipEmptySections = true; disable_statusline = false;
highlightingCache = false; skip_empty_sections = true;
focuslostInactive = false; highlighting_cache = false;
statuslineOntop = false; focuslost_inactive = false;
stlPathStyle = "short"; statusline_ontop = false;
sectionCOnlyFilename = true; stl_path_style = "short";
symbols = { section_c_only_filename = true;
branch = ""; symbols = {
colnr = " :"; branch = "";
readonly = ""; colnr = " :";
linenr = " :"; readonly = "";
maxlinenr = " "; linenr = " :";
dirty = ""; maxlinenr = " ";
dirty = "";
};
}; };
}; };
}; };