From 5563238f0a160b3105e99749219a1b63d58d5eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 16 Feb 2025 23:19:43 +0100 Subject: [PATCH] fix: reduce size of config And add more knobs to further reduce the config size. --- flake-modules/nvim.nix | 5 +- home/default.nix | 6 +- home/gui/default.nix | 2 + nvim/mappings.nix | 29 ++++--- nvim/options.nix | 1 + nvim/standalone.nix | 172 +++++++++++++++++++++-------------------- 6 files changed, 112 insertions(+), 103 deletions(-) diff --git a/flake-modules/nvim.nix b/flake-modules/nvim.nix index 75fd4e8..89832f3 100644 --- a/flake-modules/nvim.nix +++ b/flake-modules/nvim.nix @@ -17,7 +17,10 @@ }; }; moduleDev = nvimModule { }; - moduleHeadless = nvimModule { jhome.nvim.dev.enable = false; }; + moduleHeadless = nvimModule { + jhome.nvim.dev.enable = false; + jhome.nvim.reduceSize = true; + }; moduleNoLsp = nvimModule { jhome.nvim.dev.bundleLSPs = false; }; moduleNoTSGrammars = nvimModule { jhome.nvim.dev.bundleGrammars = false; }; moduleNoBundledBins = nvimModule { diff --git a/home/default.nix b/home/default.nix index 851e89c..158c493 100644 --- a/home/default.nix +++ b/home/default.nix @@ -69,12 +69,10 @@ in homedir = "${config.xdg.dataHome}/gnupg"; }; # Mail client - himalaya.enable = true; - # Another shell - nushell.enable = true; + himalaya.enable = lib.mkDefault true; # Password manager password-store = { - enable = true; + enable = lib.mkDefault true; package = pkgs.pass-nodmenu; settings.PASSWORD_STORE_DIR = "${config.xdg.dataHome}/pass"; }; diff --git a/home/gui/default.nix b/home/gui/default.nix index bd81732..c24ddcf 100644 --- a/home/gui/default.nix +++ b/home/gui/default.nix @@ -71,6 +71,8 @@ in enable = true; scripts = builtins.attrValues { inherit (pkgs.mpvScripts) uosc thumbfast; }; }; + # Text editor + nixvim.clipboard.providers.wl-copy.enable = lib.mkDefault true; # Status bar waybar = { enable = true; diff --git a/nvim/mappings.nix b/nvim/mappings.nix index a7d5c36..4571332 100644 --- a/nvim/mappings.nix +++ b/nvim/mappings.nix @@ -7,7 +7,6 @@ let inherit (helpers) mkRaw; cfg = config.jhome.nvim; - dev = cfg.dev.enable; in { config.keymaps = @@ -202,21 +201,21 @@ in ''; options.desc = "Find Quickfix"; } - # Nvim Silicon - { - mode = "v"; - key = "sc"; - action = - mkRaw - # lua - '' - require('nvim-silicon').clip - - ''; - options.desc = "Snap Code (to clipboard)"; - } ] - ++ lib.optional dev { + # Nvim Silicon + ++ lib.optional (!cfg.reduceSize) { + mode = "v"; + key = "sc"; + action = + mkRaw + # lua + '' + require('nvim-silicon').clip + + ''; + options.desc = "Snap Code (to clipboard)"; + } + ++ lib.optional cfg.dev.enable { mode = "n"; key = "w"; action = diff --git a/nvim/options.nix b/nvim/options.nix index 1e54e30..292a80e 100644 --- a/nvim/options.nix +++ b/nvim/options.nix @@ -12,6 +12,7 @@ in { options.jhome.nvim = { enable = mkDisableOption "jalil's Neovim configuration"; + reduceSize = mkEnableOption "reduce size by disabling big modules"; dev = mkOption { type = types.submodule { options = { diff --git a/nvim/standalone.nix b/nvim/standalone.nix index 8e25d9e..cec3117 100644 --- a/nvim/standalone.nix +++ b/nvim/standalone.nix @@ -1,4 +1,14 @@ -{ pkgs, ... }: +{ + lib, + pkgs, + config, + ... +}: +let + cfg = config.jhome.nvim; + plugins = pkgs.vimPlugins; + extraPlugins = import ./extraPlugins { inherit pkgs; }; +in { imports = [ ./options.nix @@ -8,91 +18,87 @@ ./augroups.nix ]; - config = { - withRuby = false; - globals.mapleader = " "; - # Appearance - colorschemes.gruvbox = { - enable = true; - settings = { - bold = true; - transparent_mode = true; - terminal_colors = true; + config = lib.mkMerge [ + { + withRuby = false; + globals.mapleader = " "; + # Appearance + colorschemes.gruvbox = { + enable = true; + settings = { + bold = true; + transparent_mode = true; + terminal_colors = true; + }; }; - }; - clipboard.providers.wl-copy.enable = true; - opts = { - number = true; - relativenumber = true; - colorcolumn = "+1"; - cursorline = true; - wrap = false; - splitright = true; - # Tabs & indentation - smarttab = true; - autoindent = true; - smartindent = true; - # Search path - path = ".,/usr/include,**"; - wildmenu = true; - hlsearch = true; - incsearch = true; - ignorecase = true; # Search ignores cases - smartcase = true; # Unless it has a capital letter - # Enable local configuration :h 'exrc' - exrc = true; # safe since nvim 0.9 - }; - extraPlugins = - let - plugins = pkgs.vimPlugins; - extraPlugins = import ./extraPlugins { inherit pkgs; }; - in - [ + opts = { + number = true; + relativenumber = true; + colorcolumn = "+1"; + cursorline = true; + wrap = false; + splitright = true; + # Tabs & indentation + smarttab = true; + autoindent = true; + smartindent = true; + # Search path + path = ".,/usr/include,**"; + wildmenu = true; + hlsearch = true; + incsearch = true; + ignorecase = true; # Search ignores cases + smartcase = true; # Unless it has a capital letter + # Enable local configuration :h 'exrc' + exrc = true; # safe since nvim 0.9 + }; + extraPlugins = [ plugins.nui-nvim plugins.nvim-web-devicons - plugins.vim-jjdescription - extraPlugins.nvim-silicon + plugins.vim-jjdescription # FIXME: included since neovim nightly ]; - # Formatting & linters - extraPackages = [ - pkgs.luajitPackages.jsregexp - pkgs.silicon - ]; - extraConfigLuaPre = - # lua - '' - -- Lua Pre Config - if vim.fn.has 'termguicolors' then - -- Enable RGB colors - vim.g.termguicolors = true - end + extraPackages = [ pkgs.luajitPackages.jsregexp ]; + extraConfigLuaPre = + # lua + '' + -- Lua Pre Config + if vim.fn.has 'termguicolors' then + -- Enable RGB colors + vim.g.termguicolors = true + end - -- Useful function - local has_words_before = function() - -- unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 - and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil - end - -- END: Lua Pre Config - ''; - extraConfigLua = - # lua - '' - -- Lua Config - require("nvim-silicon").setup { - theme = "gruvbox-dark", - pad_horiz = 16, - pad_vert = 16, - -- Current buffer name - window_title = function() - return vim.fn.fnamemodify( - vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()), - ":t" - ) - end, - } - -- END: Lua Config - ''; - }; + -- Useful function + local has_words_before = function() + -- unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 + and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil + end + -- END: Lua Pre Config + ''; + } + # Big packages that are kinda unnecessary + (lib.mkIf (!cfg.reduceSize) { + extraPlugins = [ extraPlugins.nvim-silicon ]; + extraPackages = [ pkgs.silicon ]; + extraConfigLua = + # lua + '' + -- Lua Config + require("nvim-silicon").setup { + theme = "gruvbox-dark", + pad_horiz = 16, + pad_vert = 16, + -- Current buffer name + window_title = function() + return vim.fn.fnamemodify( + vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()), + ":t" + ) + end, + } + -- END: Lua Config + ''; + }) + ]; }