From 6fe2301c8996526cc1e83cdbb3a0ff13e5a9b061 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Mon, 20 Feb 2023 13:01:31 -0800 Subject: [PATCH] Config --- lua/argonaut.lua | 59 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/lua/argonaut.lua b/lua/argonaut.lua index 4cdadb4..254285b 100644 --- a/lua/argonaut.lua +++ b/lua/argonaut.lua @@ -1,22 +1,55 @@ -local ArgonautConfig = { - line_prefix = '', - padded_braces = {}, - tail_comma = false, - tail_comma_braces = {}, - tail_indent_braces = {}, - wrap_closing_brace = true, - comma_first = false, - comma_first_indent = false, +local argonaut_configs = { + default = { + line_prefix = '', + padded_braces = {}, + tail_comma = false, + tail_comma_braces = {}, + tail_indent_braces = {}, + wrap_closing_brace = true, + comma_first = false, + comma_first_indent = false, + } } -local function setup(opts) +local function setup(opts, filetypes) if opts then - for key, value in pairs(opts) do - ArgonautConfig[key] = value + if type(filetypes) == 'string' then + filetypes = {filetypes} + elseif not filetypes then + filetypes = {'default'} + end + + for _, filetype in ipairs(filetypes) do + local config = argonaut_configs[filetype] + if not config then + config = {} + argonaut_configs[filetype] = config + end + + for key, value in pairs(opts) do + config[key] = value + end end end end +local function get_config() + local file_config = argonaut_configs[vim.bo.filetype] + + local config = {} + for key, value in pairs(argonaut_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] + end + end + end + + return config +end + local function get_cursor_pos() local _, row, col, _ = unpack(vim.fn.getpos('.')) return {row = row, col = col} @@ -262,5 +295,5 @@ end return { reflow = reflow, - ssetup = setup, + setup = setup, }