From e8dcbc6da43fdb9791ce3db097b36f136f124121 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 29 Apr 2024 20:33:02 -0700 Subject: [PATCH] Update preferences --- lua/argonaut/config.lua | 46 +++++++++++++++++------------------------ lua/argonaut/init.lua | 2 +- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/lua/argonaut/config.lua b/lua/argonaut/config.lua index ec9d1c5..3540161 100644 --- a/lua/argonaut/config.lua +++ b/lua/argonaut/config.lua @@ -1,4 +1,4 @@ -local configs = { +local opt_curr = { default = { brace_last_indent = false, brace_last_wrap = true, @@ -17,46 +17,38 @@ local configs = { } } -local function set(opts, filetypes) - if opts then - if type(filetypes) == 'string' then - filetypes = {filetypes} - elseif not filetypes then - filetypes = {'default'} +local function setup(opt) + for file_type, file_opt in pairs(opt) do + local file_opt_curr = opt_curr[file_type] + if not file_opt_curr then + file_opt_curr = {} + opt_curr[file_type] = file_opt_curr end - for _, filetype in ipairs(filetypes) do - local config = configs[filetype] - if not config then - config = {} - configs[filetype] = config - end - - for key, value in pairs(opts) do - config[key] = value - end + for param_name, param_value in pairs(file_opt) do + file_opt_curr[param_name] = param_value end end end local function get() - local file_config = configs[vim.bo.filetype] + local file_opt_curr = opt_curr[vim.bo.filetype] - local config = {} - for key, value in pairs(configs.default) do - config[key] = value - if file_config then - local file_value = file_config[key] - if file_value ~= nil then - config[key] = file_config[key] + local file_opt = {} + for param_name, param_value in pairs(opt_curr.default) do + file_opt[param_name] = param_value + if file_opt_curr then + param_value = file_opt_curr[param_name] + if param_value ~= nil then + file_opt[param_name] = param_value end end end - return config + return file_opt end return { - set = set, + setup = setup, get = get, } diff --git a/lua/argonaut/init.lua b/lua/argonaut/init.lua index 13a2a01..cf1c62a 100644 --- a/lua/argonaut/init.lua +++ b/lua/argonaut/init.lua @@ -10,5 +10,5 @@ end return { reflow = reflow, - setup = config.set, + setup = config.setup, }