From 82d2c82e8581f08740b22e6c5c645f6ad16545f1 Mon Sep 17 00:00:00 2001 From: Builditluc <37375448+Builditluc@users.noreply.github.com> Date: Tue, 2 Nov 2021 12:00:14 +0100 Subject: [PATCH 1/5] tokyonight: init colorscheme --- plugins/colorschemes/tokyonight.nix | 17 +++++++++++++++++ plugins/default.nix | 1 + 2 files changed, 18 insertions(+) create mode 100644 plugins/colorschemes/tokyonight.nix diff --git a/plugins/colorschemes/tokyonight.nix b/plugins/colorschemes/tokyonight.nix new file mode 100644 index 00000000..248d0fb3 --- /dev/null +++ b/plugins/colorschemes/tokyonight.nix @@ -0,0 +1,17 @@ +{ pkgs, config, lib, ... }: +with lib; +let cfg = config.programs.nixvim.colorschemes.tokyonight; +in { + options = { + programs.nixvim.colorschemes.tokyonight = { + enable = mkEnableOption "Enable tokyonight"; + }; + }; + config = mkIf cfg.enable { + programs.nixvim = { + colorscheme = "tokyonight"; + extraPlugins = [ pkgs.vimPlugins.tokyonight-nvim ]; + options = { termguicolors = true; }; + }; + }; +} diff --git a/plugins/default.nix b/plugins/default.nix index 6efc2ff5..dbd71e9b 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -4,6 +4,7 @@ ./colorschemes/onedark.nix ./colorschemes/one.nix ./colorschemes/base16.nix + ./colorschemes/tokyonight.nix ./pluginmanagers/packer.nix From f3cbb78bcc7ce92a506193f30a44d4b6325c5414 Mon Sep 17 00:00:00 2001 From: Builditluc <37375448+Builditluc@users.noreply.github.com> Date: Tue, 2 Nov 2021 13:50:16 +0100 Subject: [PATCH 2/5] tokyonight: add options --- plugins/colorschemes/tokyonight.nix | 44 ++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/plugins/colorschemes/tokyonight.nix b/plugins/colorschemes/tokyonight.nix index 248d0fb3..8178e64f 100644 --- a/plugins/colorschemes/tokyonight.nix +++ b/plugins/colorschemes/tokyonight.nix @@ -1,10 +1,35 @@ { pkgs, config, lib, ... }: with lib; -let cfg = config.programs.nixvim.colorschemes.tokyonight; +let + cfg = config.programs.nixvim.colorschemes.tokyonight; + style = types.enum [ "storm" "night" "day" ]; in { options = { programs.nixvim.colorschemes.tokyonight = { enable = mkEnableOption "Enable tokyonight"; + style = mkOption { + type = types.nullOr style; + default = null; + description = "Theme style"; + }; + terminalColors = mkEnableOption + "Configure the colors used when opening a :terminal in Neovim"; + italicComments = mkEnableOption "Make comments italic"; + italicKeywods = mkEnableOption "Make keywords italic"; + italicFunctions = mkEnableOption "Make functions italic"; + italicVariables = mkEnableOption "Make variables and identifiers italic"; + transparent = + mkEnableOption "Enable this to disable setting the background color"; + hideInactiveStatusline = mkEnableOption + "Enabling this option will hide inactive statuslines and replace them with a thin border"; + transparentSidebar = mkEnableOption + "Sidebar like windows like NvimTree get a transparent background"; + darkSidebar = mkEnableOption + "Sidebar like windows like NvimTree get a darker background"; + darkFloat = mkEnableOption + "Float windows like the lsp diagnostics windows get a darker background"; + lualineBold = mkEnableOption + "When true, section headers in the lualine theme will be bold"; }; }; config = mkIf cfg.enable { @@ -12,6 +37,23 @@ in { colorscheme = "tokyonight"; extraPlugins = [ pkgs.vimPlugins.tokyonight-nvim ]; options = { termguicolors = true; }; + globals = { + tokyonight_style = mkIf (!isNull cfg.style) cfg.style; + tokyonight_terminal_colors = mkIf (!cfg.terminalColors) 0; + + tokyonight_italic_comments = mkIf (!cfg.italicComments) 0; + tokyonight_italic_keywords = mkIf (!cfg.italicKeywods) 0; + tokyonight_italic_functions = mkIf (cfg.italicFunctions) 1; + tokyonight_italic_variables = mkIf (cfg.italicVariables) 1; + + tokyonight_transparent = mkIf (cfg.transparent) 1; + tokyonight_hide_inactive_statusline = + mkIf (cfg.hideInactiveStatusline) 1; + tokyonight_transparent_sidebar = mkIf (cfg.transparentSidebar) 1; + tokyonight_dark_sidebar = mkIf (!cfg.darkSidebar) 0; + tokyonight_dark_float = mkIf (!cfg.darkFloat) 0; + tokyonight_lualine_bold = mkIf (cfg.lualineBold) 1; + }; }; }; } From ea8d02bf1031e78bbc31cc66912fd549834101b2 Mon Sep 17 00:00:00 2001 From: Builditluc <37375448+Builditluc@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:04:12 +0100 Subject: [PATCH 3/5] lualine: init statusline --- flake.nix | 28 ++++++++-------------------- plugins/default.nix | 1 + plugins/statuslines/lualine.nix | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 plugins/statuslines/lualine.nix diff --git a/flake.nix b/flake.nix index fb7d4c94..f97bf7a9 100644 --- a/flake.nix +++ b/flake.nix @@ -1,13 +1,11 @@ { description = "A neovim configuration system for NixOS"; - inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; - inputs.neovim-nightly.url = github:nix-community/neovim-nightly-overlay; + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + inputs.neovim-nightly.url = "github:nix-community/neovim-nightly-overlay"; outputs = { self, nixpkgs, ... }@inputs: rec { - overlays = [ - inputs.neovim-nightly.overlay - ]; + overlays = [ inputs.neovim-nightly.overlay ]; nixosModules.nixvim = import ./nixvim.nix { nixos = true; }; homeManagerModules.nixvim = import ./nixvim.nix { homeManager = true; }; @@ -26,22 +24,16 @@ password = ""; }; - imports = [ - nixosModules.nixvim - ]; + imports = [ nixosModules.nixvim ]; nixpkgs.overlays = [ inputs.neovim-nightly.overlay ]; programs.nixvim = { enable = true; package = pkgs.neovim-nightly; - colorschemes.onedark = { - enable = true; - }; + colorschemes.onedark = { enable = true; }; - extraPlugins = [ - pkgs.vimPlugins.vim-nix - ]; + extraPlugins = [ pkgs.vimPlugins.vim-nix ]; options = { number = true; @@ -83,14 +75,10 @@ plugins.telescope = { enable = true; - extensions = { - frecency.enable = true; - }; + extensions = { frecency.enable = true; }; }; - plugins.nvim-autopairs = { - enable = true; - }; + plugins.nvim-autopairs = { enable = true; }; globals = { vimsyn_embed = "l"; diff --git a/plugins/default.nix b/plugins/default.nix index dbd71e9b..c4d3d81b 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -10,6 +10,7 @@ ./statuslines/lightline.nix ./statuslines/airline.nix + ./statuslines/lualine.nix ./git/gitgutter.nix ./git/fugitive.nix diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix new file mode 100644 index 00000000..e18b2d92 --- /dev/null +++ b/plugins/statuslines/lualine.nix @@ -0,0 +1,15 @@ +{ pkgs, config, lib, ... }: +with lib; +let cfg = config.programs.nixvim.plugins.lualine; +in { + options = { + programs.nixvim.plugins.lualine = { + enable = mkEnableOption "Enable airline"; + }; + }; + if mkIf cfg.enable { + programs.nixvim = { + extraPlugins = with pkgs.vimPlugins.lualine-nvim; + }; + }; +} From e1313862b019a70e8755addd5aca107a686f6c54 Mon Sep 17 00:00:00 2001 From: Builditluc <37375448+Builditluc@users.noreply.github.com> Date: Tue, 2 Nov 2021 18:03:01 +0100 Subject: [PATCH 4/5] lualine: add options --- plugins/statuslines/lualine.nix | 120 +++++++++++++++++++++++++++++++- 1 file changed, 117 insertions(+), 3 deletions(-) diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix index e18b2d92..6c970225 100644 --- a/plugins/statuslines/lualine.nix +++ b/plugins/statuslines/lualine.nix @@ -1,15 +1,129 @@ { pkgs, config, lib, ... }: with lib; -let cfg = config.programs.nixvim.plugins.lualine; +let + cfg = config.programs.nixvim.plugins.lualine; + helpers = import ../helpers.nix { lib = lib; }; + separators = mkOption { + type = types.submodule { + options = { + left = mkOption { + default = " "; + type = types.str; + description = "left separator"; + }; + right = mkOption { + default = " "; + type = types.str; + description = "right separator"; + }; + }; + }; + default = { }; + }; + component_options = mode: + mkOption { + type = types.submodule { + options = { + mode = mkOption { + type = types.str; + default = "${mode}"; + }; + icons_enabled = mkOption { + type = types.enum [ "True" "False" ]; + default = "True"; + description = "displays icons in alongside component"; + }; + icon = mkOption { + type = types.nullOr types.str; + default = null; + description = "displays icon in front of the component"; + }; + separator = separators; + }; + }; + default = { }; + }; in { options = { programs.nixvim.plugins.lualine = { enable = mkEnableOption "Enable airline"; + + 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"; + }; + sections = mkOption { + type = types.nullOr (types.submodule ({ ... }: { + options = { + lualine_a = component_options "mode"; + lualine_b = component_options "branch"; + lualine_c = component_options "filename"; + + lualine_x = component_options "encoding"; + lualine_y = component_options "progress"; + lualine_z = component_options "location"; + }; + })); + default = { }; + }; + tabline = mkOption { + type = types.nullOr (types.submodule ({ ... }: { + options = { + lualine_a = component_options ""; + lualine_b = component_options ""; + lualine_c = component_options ""; + + lualine_x = component_options ""; + lualine_y = component_options ""; + lualine_z = component_options ""; + }; + })); + default = null; + }; + extensions = mkOption { + type = types.listOf types.str; + default = [ ]; + example = ''[ "fzf" ]''; + description = "list of enabled extensions"; + }; }; }; - if mkIf cfg.enable { + config = mkIf cfg.enable { programs.nixvim = { - extraPlugins = with pkgs.vimPlugins.lualine-nvim; + 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}; + '' + "}"; }; }; } From fed1ded89648fcbadddf764702a4583764cc162b Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Tue, 2 Nov 2021 19:37:08 +0000 Subject: [PATCH 5/5] lualine: update options --- flake.nix | 5 +-- plugins/statuslines/lualine.nix | 78 +++++++++++++++++---------------- 2 files changed, 42 insertions(+), 41 deletions(-) diff --git a/flake.nix b/flake.nix index f97bf7a9..b2b48c18 100644 --- a/flake.nix +++ b/flake.nix @@ -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 ]; @@ -50,9 +50,8 @@ maps.normalVisualOp."รง" = ":"; - plugins.airline = { + plugins.lualine = { enable = true; - powerline = true; }; plugins.undotree.enable = true; diff --git a/plugins/statuslines/lualine.nix b/plugins/statuslines/lualine.nix index 6c970225..5f0f6aa6 100644 --- a/plugins/statuslines/lualine.nix +++ b/plugins/statuslines/lualine.nix @@ -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 = { @@ -87,8 +82,10 @@ in { lualine_z = component_options "location"; }; })); + default = { }; }; + tabline = mkOption { type = types.nullOr (types.submodule ({ ... }: { 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 = { 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})''; }; }; }