summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-24 18:06:27 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-24 18:06:27 +0800
commit1933f28cdb6859660c6bc4dbb2f5c2b41b9eec02 (patch)
tree2c61c82fe4c82523f784a5b75ebd9f148fdb72b6
parentff6a7e95e1a6be16338bcd1819b512cb36960e3b (diff)
downloadlua-language-server-1933f28cdb6859660c6bc4dbb2f5c2b41b9eec02.zip
check local setting
-rw-r--r--locale/en-us/script.lua1
-rw-r--r--locale/zh-cn/script.lua1
-rw-r--r--script/client.lua9
-rw-r--r--script/config/config.lua12
-rw-r--r--script/provider/provider.lua6
5 files changed, 23 insertions, 6 deletions
diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua
index 16a66b0a..c75cfa7d 100644
--- a/locale/en-us/script.lua
+++ b/locale/en-us/script.lua
@@ -237,6 +237,7 @@ WINDOW_TELEMETRY_HINT = 'Please allow sending anonymous usage data an
WINDOW_TELEMETRY_ENABLE = 'Allow'
WINDOW_TELEMETRY_DISABLE = 'Prohibit'
WINDOW_CLIENT_NOT_SUPPORT_CONFIG = 'Your client does not support modifying settings from the server side, please manually modify the following settings:'
+WINDOW_LCONFIG_NOT_SUPPORT_CONFIG= 'Automatic modification of local settings is not currently supported, please manually modify the following settings:'
WINDOW_MANUAL_CONFIG_ADD = '`{key}`: add element `{value:q}` ;'
WINDOW_MANUAL_CONFIG_SET = '`{key}`: set to `{value:q}` ;'
WINDOW_MANUAL_CONFIG_PROP = '`{key}`: set the property `{prop}` to `{value:q}`;'
diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua
index f1e9d95f..025efa75 100644
--- a/locale/zh-cn/script.lua
+++ b/locale/zh-cn/script.lua
@@ -236,6 +236,7 @@ WINDOW_TELEMETRY_HINT = '请允许发送匿名的使用数据与错
WINDOW_TELEMETRY_ENABLE = '允许'
WINDOW_TELEMETRY_DISABLE = '禁止'
WINDOW_CLIENT_NOT_SUPPORT_CONFIG = '你的客户端不支持从服务侧修改设置,请手动修改如下设置:'
+WINDOW_LCONFIG_NOT_SUPPORT_CONFIG= '暂不支持自动修改本地设置,请手动修改如下设置:'
WINDOW_MANUAL_CONFIG_ADD = '为 `{key}` 添加值 `{value:q}`;'
WINDOW_MANUAL_CONFIG_SET = '将 `{key}` 的值设置为 `{value:q}`;'
WINDOW_MANUAL_CONFIG_PROP = '将 `{key}` 的属性 `{prop}` 设置为 `{value:q}`;'
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