From 4712c14f8b88d3b42a38c3f2d825972010ee6691 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 9 Oct 2023 10:48:15 +0200 Subject: [PATCH 1/3] Remove this from ignored settings --- lua/neogit/config.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/neogit/config.lua b/lua/neogit/config.lua index 2785d6adf..5c44f2ccd 100644 --- a/lua/neogit/config.lua +++ b/lua/neogit/config.lua @@ -226,7 +226,6 @@ function M.get_default_values() "NeogitPushPopup--force-with-lease", "NeogitPushPopup--force", "NeogitPullPopup--rebase", - "NeogitLogPopup--", "NeogitCommitPopup--allow-empty", }, mappings = { From f768a3a14a4ec17b5e0056cecd0b95e2ce141fb3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 9 Oct 2023 10:48:29 +0200 Subject: [PATCH 2/3] If opts has a setup function, call it --- lua/neogit/lib/popup/builder.lua | 4 ++++ lua/neogit/popups/log/init.lua | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lua/neogit/lib/popup/builder.lua b/lua/neogit/lib/popup/builder.lua index 4a184bee0..071104f95 100644 --- a/lua/neogit/lib/popup/builder.lua +++ b/lua/neogit/lib/popup/builder.lua @@ -194,6 +194,10 @@ function M:option(key, cli, value, description, opts) opts.separator = "=" end + if opts.setup then + opts.setup(self) + end + table.insert(self.state.args, { type = "option", id = opts.key_prefix .. key, diff --git a/lua/neogit/popups/log/init.lua b/lua/neogit/popups/log/init.lua index 89a973ffd..a64827bf1 100644 --- a/lua/neogit/popups/log/init.lua +++ b/lua/neogit/popups/log/init.lua @@ -29,6 +29,16 @@ function M.create() key_prefix = "-", separator = "", fn = actions.limit_to_files, + setup = function(popup) + local value = require("neogit.lib.state").get { "NeogitLogPopup", "" } + value = vim.split(value, " ", { trimempty = true }) + value = require("neogit.lib.util").map(value, function(v) + local result, _ = v:gsub([["]], "") + return result + end) + + popup.state.env.files = value + end, }) :switch("f", "follow", "Follow renames when showing single-file log") :arg_heading("Commit Ordering") From a82a7c878f5173068cc55cf88822c2fd9ea9f94a Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 9 Oct 2023 10:48:44 +0200 Subject: [PATCH 3/3] Nullify settings if empty string is passed --- lua/neogit/lib/state.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/neogit/lib/state.lua b/lua/neogit/lib/state.lua index 6c6d466b0..5b0e762f2 100644 --- a/lua/neogit/lib/state.lua +++ b/lua/neogit/lib/state.lua @@ -79,15 +79,21 @@ local function gen_key(key_table) end ---Set option and write to disk ----@param key table +---@param key string[] ---@param value any function M.set(key, value) if not M.enabled() then return end - if not vim.tbl_contains(config.values.ignored_settings, gen_key(key)) then - M.state[gen_key(key)] = value + local cache_key = gen_key(key) + if not vim.tbl_contains(config.values.ignored_settings, cache_key) then + if value == "" then + M.state[cache_key] = nil + else + M.state[cache_key] = value + end + M.write() end end