Skip to content

Commit

Permalink
feat: update source configs on new config
Browse files Browse the repository at this point in the history
  • Loading branch information
max397574 committed Nov 7, 2024
1 parent 394d71f commit c609221
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,7 @@ dependencies installed by running
```bash
nix run .#nvim
```

# Debugging tricks
Print out source configurations:
`:lua =vim.iter(require"care.sources".sources):map(function(source) return source.config end):totable()`
1 change: 1 addition & 0 deletions lua/care/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ care.api = {
---@param options? care.config
function care.setup(options)
require("care.config").setup(options)
require("care.sources").update_configs()
end

--- Sets up care
Expand Down
7 changes: 7 additions & 0 deletions lua/care/sources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ function care_sources.get_sources()
return vim.deepcopy(care_sources.sources)
end

function care_sources.update_configs()
local source_configs = require("care.config").options.sources or {}
for _, source in ipairs(care_sources.sources) do
source.config = source_configs[source.source.name] or {}
end
end

---@param context care.context
---@param source care.internal_source
---@param callback fun(items: care.entry[], is_incomplete?: boolean)
Expand Down

0 comments on commit c609221

Please sign in to comment.