summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-14 15:29:38 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-14 15:29:38 +0800
commit1a2f3d251a69421d6368585dbb2ef9cafb23fd24 (patch)
tree592bf264490b257bb7c76dcd6542cc9d6c8f642b /script/provider
parentffb9d5437ad78dbd392f72fd60b4c03f4cefb970 (diff)
downloadlua-language-server-1a2f3d251a69421d6368585dbb2ef9cafb23fd24.zip
update build-meta
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/build-meta.lua12
-rw-r--r--script/provider/provider.lua18
2 files changed, 18 insertions, 12 deletions
diff --git a/script/provider/build-meta.lua b/script/provider/build-meta.lua
index 21390411..090b7b04 100644
--- a/script/provider/build-meta.lua
+++ b/script/provider/build-meta.lua
@@ -124,13 +124,9 @@ local function buildRootText(api)
end
---@async
----@param name string
+---@param path string
---@param api meta
----@return string
-function m.build(name, api)
- local encoding = config.get(nil, 'Lua.runtime.fileEncoding')
- local fileDir = fs.path(METAPATH) / (name .. ' ' .. encoding)
- fs.create_directories(fileDir)
+function m.build(path, api)
local files = util.multiTable(2, function ()
return { '---@meta' }
@@ -149,10 +145,8 @@ function m.build(name, api)
end
for space, texts in pairs(files) do
- util.saveFile((fileDir / (space .. '.lua')):string(), table.concat(texts, '\n\n'))
+ util.saveFile(path .. '/' .. space .. '.lua', table.concat(texts, '\n\n'))
end
-
- return fileDir:string()
end
return m
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index a5255f44..eb1362eb 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -21,6 +21,7 @@ local furi = require 'file-uri'
local inspect = require 'inspect'
local markdown = require 'provider.markdown'
local guide = require 'parser.guide'
+local fs = require 'bee.filesystem'
---@async
local function updateConfig(uri)
@@ -1342,14 +1343,25 @@ m.register '$/api/report' {
---@async
function (params)
local buildMeta = require 'provider.build-meta'
+ local SDBMHash = require 'SDBMHash'
await.close 'api/report'
await.setID 'api/report'
- local dir = buildMeta.build('default', params)
+ local name = params.name or 'default'
+ local uri = workspace.getFirstScope().uri
+ local hash = uri and ('%08x'):format(SDBMHash():hash(uri))
+ local encoding = config.get(nil, 'Lua.runtime.fileEncoding')
+ local nameBuf = {}
+ nameBuf[#nameBuf+1] = name
+ nameBuf[#nameBuf+1] = hash
+ nameBuf[#nameBuf+1] = encoding
+ local fileDir = METAPATH .. '/' .. table.concat(nameBuf, ' ')
+ fs.create_directories(fs.path(fileDir))
+ buildMeta.build(fileDir, params)
client.setConfig {
{
- key = 'Lua.runtime.library',
+ key = 'Lua.workspace.library',
action = 'add',
- value = dir,
+ value = fileDir,
}
}
end