Skip to content

Commit

Permalink
fix(config): correctly replace config values
Browse files Browse the repository at this point in the history
  • Loading branch information
vyfor committed Dec 27, 2024
1 parent 29170fd commit 17dd6f3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
8 changes: 7 additions & 1 deletion lua/cord/plugin/config/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@
---@field hooks? CordHooksConfig Hooks configuration
---@field advanced? CordAdvancedConfig Advanced configuration

local M = {}

---@type CordConfig
return {
M.opts = {
editor = {
client = 'neovim',
tooltip = 'The Superior Text Editor',
Expand Down Expand Up @@ -154,3 +156,7 @@ return {
variables_in_functions = false,
},
}

M.set_config = function(config) M.opts = config end

return M
5 changes: 3 additions & 2 deletions lua/cord/plugin/config/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function M:validate(user_config)
local logger = require 'cord.plugin.log'
local icons = require 'cord.api.icon'

self.config = require('cord.plugin.config')
local config = vim.tbl_deep_extend('force', self.config, user_config)
local config_manager = require 'cord.plugin.config'
local config = vim.tbl_deep_extend('force', config_manager.opts, user_config)
logger.set_level(config.advanced.plugin.log_level)
icons.set_theme(config.display.theme)

Expand Down Expand Up @@ -42,6 +42,7 @@ function M:validate(user_config)

::continue::

config_manager.set_config(config)
self.config = config

return true
Expand Down
2 changes: 1 addition & 1 deletion lua/cord/server/init.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local async = require 'cord.core.async'
local logger = require 'cord.plugin.log'
local pipe = require 'cord.core.uv.pipe'
local config = require 'cord.plugin.config'
local config = require('cord.plugin.config').opts

local M = {}

Expand Down
2 changes: 1 addition & 1 deletion lua/cord/server/spawn/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ M.spawn = async.wrap(function(client_id, pipe_path, exec_path)
'-c',
client_id,
'-t',
require('cord.plugin.config').advanced.server.timeout,
require('cord.plugin.config').opts.advanced.server.timeout,
},
on_stdout = function(data)
if data:match 'Ready' then resolve(false) end
Expand Down

0 comments on commit 17dd6f3

Please sign in to comment.