diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/client.lua | 9 | ||||
-rw-r--r-- | script/config/config.lua | 12 | ||||
-rw-r--r-- | script/provider/provider.lua | 6 |
3 files changed, 21 insertions, 6 deletions
diff --git a/script/client.lua b/script/client.lua index 4e4196b4..c22b59ab 100644 --- a/script/client.lua +++ b/script/client.lua @@ -188,14 +188,19 @@ function m.setConfig(changes, onlyMemory) if #finalChanges == 0 then return end - if m.getOption 'changeConfiguration' then + if m.getOption 'changeConfiguration' + and config.getSource() == 'client' then proto.notify('$/command', { command = 'lua.config', data = finalChanges, }) else local messages = {} - messages[1] = lang.script('WINDOW_CLIENT_NOT_SUPPORT_CONFIG') + if not m.getOption 'changeConfiguration' then + messages[1] = lang.script('WINDOW_CLIENT_NOT_SUPPORT_CONFIG') + elseif config.getSource() ~= 'client' then + messages[1] = lang.script('WINDOW_LCONFIG_NOT_SUPPORT_CONFIG') + end for _, change in ipairs(finalChanges) do if change.action == 'add' then messages[#messages+1] = lang.script('WINDOW_MANUAL_CONFIG_ADD', change) diff --git a/script/config/config.lua b/script/config/config.lua index 57a16b1b..fd112845 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -2,6 +2,8 @@ local util = require 'utility' local define = require 'proto.define' local timer = require 'timer' +---@alias config.source '"client"'|'"path"'|'"local"' + ---@class config.unit ---@field caller function local mt = {} @@ -349,6 +351,16 @@ function m.event(key, value, oldValue) } end +---@param source config.source +function m.setSource(source) + m._source = source +end + +---@return config.source +function m.getSource() + return m._source +end + function m.init() if m.inited then return diff --git a/script/provider/provider.lua b/script/provider/provider.lua index fdcaebb2..21929734 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -7,24 +7,22 @@ local define = require 'proto.define' local workspace = require 'workspace' local config = require 'config' local library = require 'library' -local markdown = require 'provider.markdown' local client = require 'client' -local furi = require 'file-uri' local pub = require 'pub' -local fs = require 'bee.filesystem' local lang = require 'language' local progress = require 'progress' local tm = require 'text-merger' -local nonil = require 'without-check-nil' local cfgLoader = require 'config.loader' local function updateConfig() local new if CONFIGPATH then new = cfgLoader.loadLocalConfig(CONFIGPATH) + config.setSource 'path' log.debug('load config from local', CONFIGPATH) else new = cfgLoader.loadClientConfig() + config.setSource 'client' log.debug('load config from client') end if not new then |