lualine: update options

This commit is contained in:
Pedro Alves 2021-11-02 19:37:08 +00:00
parent e1313862b0
commit fed1ded896
2 changed files with 42 additions and 41 deletions

View file

@ -31,7 +31,7 @@
programs.nixvim = { programs.nixvim = {
enable = true; enable = true;
package = pkgs.neovim-nightly; package = pkgs.neovim-nightly;
colorschemes.onedark = { enable = true; }; colorschemes.tokyonight = { enable = true; };
extraPlugins = [ pkgs.vimPlugins.vim-nix ]; extraPlugins = [ pkgs.vimPlugins.vim-nix ];
@ -50,9 +50,8 @@
maps.normalVisualOp."ç" = ":"; maps.normalVisualOp."ç" = ":";
plugins.airline = { plugins.lualine = {
enable = true; enable = true;
powerline = true;
}; };
plugins.undotree.enable = true; plugins.undotree.enable = true;

View file

@ -46,35 +46,30 @@ let
in { in {
options = { options = {
programs.nixvim.plugins.lualine = { programs.nixvim.plugins.lualine = {
enable = mkEnableOption "Enable airline"; enable = mkEnableOption "Enable lualine";
options = mkOption {
type = types.submodule {
options = {
theme = mkOption { theme = mkOption {
default = "auto"; default = "auto";
type = types.str; type = types.str;
description = "The theme to use for lualine-nvim."; description = "The theme to use for lualine-nvim.";
}; };
section_separators = separators;
component_separators = separators; sectionSeparators = separators;
disabled_filestypes = mkOption { componentSeparators = separators;
disabledFilestypes = mkOption {
type = types.listOf types.str; type = types.listOf types.str;
default = [ ]; default = [ ];
example = ''[ "lua" ]''; example = ''[ "lua" ]'';
description = "filetypes to disable lualine on"; description = "filetypes to disable lualine on";
}; };
always_divide_middle = mkOption {
alwaysDivideMiddle = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = description = "When true, left_sections (a,b,c) can't take over entire statusline";
"When true left_sections (a,b,c) can't take over entire statusline";
};
};
};
default = { };
description = "Options for lualine";
}; };
sections = mkOption { sections = mkOption {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({ ... }: {
options = { options = {
@ -87,8 +82,10 @@ in {
lualine_z = component_options "location"; lualine_z = component_options "location";
}; };
})); }));
default = { }; default = { };
}; };
tabline = mkOption { tabline = mkOption {
type = types.nullOr (types.submodule ({ ... }: { type = types.nullOr (types.submodule ({ ... }: {
options = { options = {
@ -111,19 +108,24 @@ in {
}; };
}; };
}; };
config = mkIf cfg.enable { config = let
setupOptions = {
options = {
theme = cfg.theme;
section_separators = cfg.sectionSeparators;
component_separators = cfg.componentSeparators;
disabled_filestypes = cfg.disabledFilestypes;
always_divide_middle = cfg.alwaysDivideMiddle;
};
sections = cfg.sections;
tabline = cfg.tabline;
extensions = cfg.extensions;
};
in mkIf cfg.enable {
programs.nixvim = { programs.nixvim = {
extraPlugins = [ pkgs.vimPlugins.lualine-nvim ]; extraPlugins = [ pkgs.vimPlugins.lualine-nvim ];
extraConfigLua = ''require("lualine").setup{'' extraConfigLua = ''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
+ optionalString (cfg.options != { }) ''
options = ${helpers.toLuaObject cfg.options};
'' + optionalString (cfg.sections != { }) ''
sections = ${helpers.toLuaObject cfg.sections};
'' + optionalString (!isNull cfg.tabline) ''
tabline = ${helpers.toLuaObject cfg.tabline};
'' + optionalString (cfg.extensions != [ ]) ''
extensions = ${helpers.toLuaObject cfg.extensions};
'' + "}";
}; };
}; };
} }