Skip to content

Commit 6edf342

Browse files
committed
update to 3.10.6
1 parent 1878bec commit 6edf342

File tree

9 files changed

+204
-320
lines changed

9 files changed

+204
-320
lines changed

resources/script/cli/doc/export.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---@diagnostic disable: await-in-sync, param-type-mismatch
12
local ws = require 'workspace'
23
local vm = require 'vm'
34
local guide = require 'parser.guide'
@@ -351,4 +352,4 @@ function export.serializeAndExport(docs, outputDir)
351352
return true, {jsonPath, mdPath}
352353
end
353354

354-
return export
355+
return export

resources/script/cli/doc/init.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ end
5252

5353
---clones a module and assigns any internal upvalues pointing to the module to the new clone
5454
---useful for sandboxing
55-
---@param tbl table module to be cloned
56-
---@return table module_clone the cloned module
55+
---@param tbl any module to be cloned
56+
---@return any module_clone the cloned module
5757
local function reinstantiateModule(tbl, _new_module, _old_module, _has_seen)
5858
_old_module = _old_module or tbl --remember old module only at root
5959
_has_seen = _has_seen or {} --remember visited indecies
@@ -78,6 +78,7 @@ local function reinstantiateModule(tbl, _new_module, _old_module, _has_seen)
7878
i = i + 1
7979
end
8080
local new_func = load(string.dump(func))--, 'function@reinstantiateModule()', 'b', _ENV)
81+
assert(new_func, 'could not load dumped function')
8182
for index, upvalue in ipairs(upvalues) do
8283
debug.setupvalue(new_func, index, upvalue)
8384
end
@@ -240,4 +241,4 @@ function doc.runCLI()
240241
end)
241242
end
242243

243-
return doc
244+
return doc

resources/script/core/completion/completion.lua

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ local function findNearestSource(state, position)
7878
---@type parser.object
7979
local source
8080
guide.eachSourceContain(state.ast, position, function (src)
81-
source = src
81+
if not source or source.start <= src.start then
82+
source = src
83+
end
8284
end)
8385
return source
8486
end
@@ -455,19 +457,8 @@ local function checkFieldFromFieldToIndex(state, name, src, parent, word, startP
455457
name = ('%q'):format(name)
456458
end
457459
local textEdit, additionalTextEdits
458-
local startOffset = guide.positionToOffset(state, startPos)
459460
local offset = guide.positionToOffset(state, position)
460-
local wordStartOffset
461-
if word == '' then
462-
wordStartOffset = state.lua:match('()%S', startOffset + 1)
463-
if wordStartOffset then
464-
wordStartOffset = wordStartOffset - 1
465-
else
466-
wordStartOffset = offset
467-
end
468-
else
469-
wordStartOffset = offset - #word
470-
end
461+
local wordStartOffset = offset - #word
471462
local wordStartPos = guide.offsetToPosition(state, wordStartOffset)
472463
local newText = ('[%s]'):format(name)
473464
textEdit = {

resources/script/lclient.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ local defaultClientOptions = {
8383
},
8484
},
8585
},
86+
workspace = {
87+
configuration = true,
88+
},
8689
},
8790
}
8891

resources/script/plugin.lua

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ local scope = require 'workspace.scope'
77
local ws = require 'workspace'
88
local fs = require 'bee.filesystem'
99

10-
---@class pluginInterfaces
11-
local pluginConfigs = {
12-
-- create plugin for vm module
13-
VM = {
14-
OnCompileFunctionParam = function (next, func, source)
15-
end
16-
}
17-
}
18-
1910
---@class plugin
2011
local m = {}
2112

@@ -60,14 +51,13 @@ function m.dispatch(event, uri, ...)
6051
return failed == 0, res1, res2
6152
end
6253

63-
function m.getVmPlugin(uri)
54+
function m.getPluginInterfaces(uri)
6455
local scp = scope.getScope(uri)
65-
---@type pluginInterfaces
6656
local interfaces = scp:get('pluginInterfaces')
6757
if not interfaces then
6858
return
6959
end
70-
return interfaces.VM
60+
return interfaces
7161
end
7262

7363
---@async
@@ -100,40 +90,6 @@ local function checkTrustLoad(scp)
10090
return true
10191
end
10292

103-
local function createMethodGroup(interfaces, key, methods)
104-
local methodGroup = {}
105-
106-
for method in pairs(methods) do
107-
local funcs = setmetatable({}, {
108-
__call = function (t, next, ...)
109-
if #t == 0 then
110-
return next(...)
111-
else
112-
local result
113-
for _, fn in ipairs(t) do
114-
result = fn(next, ...)
115-
end
116-
return result
117-
end
118-
end
119-
})
120-
for _, interface in ipairs(interfaces) do
121-
local func = interface[method]
122-
if not func then
123-
local namespace = interface[key]
124-
if namespace then
125-
func = namespace[method]
126-
end
127-
end
128-
if func then
129-
funcs[#funcs+1] = func
130-
end
131-
end
132-
methodGroup[method] = funcs
133-
end
134-
return #methodGroup>0 and methodGroup or nil
135-
end
136-
13793
---@param uri uri
13894
local function initPlugin(uri)
13995
await.call(function () ---@async
@@ -206,10 +162,6 @@ local function initPlugin(uri)
206162
interfaces[#interfaces+1] = interface
207163
end
208164

209-
for key, config in pairs(pluginConfigs) do
210-
interfaces[key] = createMethodGroup(interfaces, key, config)
211-
end
212-
213165
ws.resetFiles(scp)
214166
end)
215167
end

resources/script/provider/provider.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ function m.updateConfig(uri)
4141
end
4242

4343
for _, folder in ipairs(scope.folders) do
44-
local clientConfig = cfgLoader.loadClientConfig(folder.uri)
44+
local clientConfig = nil
45+
if client.getAbility('workspace.configuration') then
46+
clientConfig = cfgLoader.loadClientConfig(folder.uri)
47+
end
4548
if clientConfig then
4649
log.info('Load config from client', folder.uri)
4750
log.info(inspect(clientConfig))
@@ -57,10 +60,12 @@ function m.updateConfig(uri)
5760
config.update(folder, clientConfig, rc)
5861
end
5962

60-
local global = cfgLoader.loadClientConfig()
61-
log.info('Load config from client', 'fallback')
62-
log.info(inspect(global))
63-
config.update(scope.fallback, global)
63+
if client.getAbility('workspace.configuration') then
64+
local global = cfgLoader.loadClientConfig()
65+
log.info('Load config from client', 'fallback')
66+
log.info(inspect(global))
67+
config.update(scope.fallback, global)
68+
end
6469
end
6570

6671
function m.register(method)

0 commit comments

Comments
 (0)