diff --git a/lua/colorful_diff/config.lua b/lua/colorful_diff/config.lua new file mode 100644 index 0000000..61b7d32 --- /dev/null +++ b/lua/colorful_diff/config.lua @@ -0,0 +1,12 @@ +local config = { + colors = { + diff = "#555522", + origin = "#225555", + }, +} + +function config.update(user_config) + config.colors = vim.tbl_deep_extend("force", config.colors, user_config.colors or {}) +end + +return config diff --git a/lua/colorful_diff/init.lua b/lua/colorful_diff/init.lua index 518dbea..6a38025 100644 --- a/lua/colorful_diff/init.lua +++ b/lua/colorful_diff/init.lua @@ -1,9 +1,21 @@ local myTint = require("colorful_diff.tint") -myTint.InitHighlightGroup("#444422", "#224444") +local config = require("colorful_diff.config") local buffer_change = require("colorful_diff.buffer_change") --- Set up autocmd to call our function on buffer change and when a file is opened -vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI", "BufRead" }, { - pattern = "*", - callback = buffer_change.on_buffer_change, -}) +local M = {} + +function M.setup(user_config) + -- Merge user config with default config + config.update(user_config or {}) + + -- Initialize highlight groups + myTint.InitHighlightGroup(config.colors.diff, config.colors.origin) + + -- Set up autocmd to call our function on buffer change and when a file is opened + vim.api.nvim_create_autocmd({ "TextChanged", "TextChangedI", "BufRead" }, { + pattern = "*", + callback = buffer_change.on_buffer_change, + }) +end + +return M diff --git a/plugin/hello.lua b/plugin/hello.lua index bfddfc4..558531a 100644 --- a/plugin/hello.lua +++ b/plugin/hello.lua @@ -1,2 +1 @@ -require("colorful_diff") -print("Hello, this is ColorfulDiff.nvim") +-- put any code you want to execute onstart here