Skip to content

Commit

Permalink
feat. add config
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen-Yulin committed Oct 14, 2024
1 parent c621758 commit 14bbad6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
12 changes: 12 additions & 0 deletions lua/colorful_diff/config.lua
Original file line number Diff line number Diff line change
@@ -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
24 changes: 18 additions & 6 deletions lua/colorful_diff/init.lua
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions plugin/hello.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
require("colorful_diff")
print("Hello, this is ColorfulDiff.nvim")
-- put any code you want to execute onstart here

0 comments on commit 14bbad6

Please sign in to comment.