Skip to content

Commit

Permalink
lualine: update options
Browse files Browse the repository at this point in the history
  • Loading branch information
pta2002 committed Nov 2, 2021
1 parent e131386 commit fed1ded
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 41 deletions.
5 changes: 2 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
programs.nixvim = {
enable = true;
package = pkgs.neovim-nightly;
colorschemes.onedark = { enable = true; };
colorschemes.tokyonight = { enable = true; };

extraPlugins = [ pkgs.vimPlugins.vim-nix ];

Expand All @@ -50,9 +50,8 @@

maps.normalVisualOp."ç" = ":";

plugins.airline = {
plugins.lualine = {
enable = true;
powerline = true;
};

plugins.undotree.enable = true;
Expand Down
78 changes: 40 additions & 38 deletions plugins/statuslines/lualine.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,30 @@ let
in {
options = {
programs.nixvim.plugins.lualine = {
enable = mkEnableOption "Enable airline";
enable = mkEnableOption "Enable lualine";

options = mkOption {
type = types.submodule {
options = {
theme = mkOption {
default = "auto";
type = types.str;
description = "The theme to use for lualine-nvim.";
};
section_separators = separators;
component_separators = separators;
disabled_filestypes = mkOption {
type = types.listOf types.str;
default = [ ];
example = ''[ "lua" ]'';
description = "filetypes to disable lualine on";
};
always_divide_middle = mkOption {
type = types.bool;
default = true;
description =
"When true left_sections (a,b,c) can't take over entire statusline";
};
};
};
default = { };
description = "Options for lualine";
theme = mkOption {
default = "auto";
type = types.str;
description = "The theme to use for lualine-nvim.";
};

sectionSeparators = separators;
componentSeparators = separators;

disabledFilestypes = mkOption {
type = types.listOf types.str;
default = [ ];
example = ''[ "lua" ]'';
description = "filetypes to disable lualine on";
};

alwaysDivideMiddle = mkOption {
type = types.bool;
default = true;
description = "When true, left_sections (a,b,c) can't take over entire statusline";
};

sections = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
options = {
Expand All @@ -87,8 +82,10 @@ in {
lualine_z = component_options "location";
};
}));

default = { };
};

tabline = mkOption {
type = types.nullOr (types.submodule ({ ... }: {
options = {
Expand All @@ -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 = {
extraPlugins = [ pkgs.vimPlugins.lualine-nvim ];
extraConfigLua = ''require("lualine").setup{''
+ 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};
'' + "}";
extraConfigLua = ''require("lualine").setup(${helpers.toLuaObject setupOptions})'';
};
};
}

0 comments on commit fed1ded

Please sign in to comment.