summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json2
m---------3rd/EmmyLuaCodeStyle0
m---------3rd/bee.lua0
m---------3rd/love-api0
m---------3rd/lovr-api0
m---------3rd/luamake0
-rw-r--r--changelog.md4
-rw-r--r--locale/en-us/script.lua9
-rw-r--r--locale/zh-cn/script.lua7
-rw-r--r--meta/3rd/lovr/library/lovr.graphics.lua4
-rw-r--r--meta/3rd/lovr/library/lovr.math.lua42
-rw-r--r--script/core/semantic-tokens.lua13
-rw-r--r--script/file-uri.lua4
-rw-r--r--script/files.lua21
-rw-r--r--script/parser/luadoc.lua11
-rw-r--r--script/provider/diagnostic.lua27
-rw-r--r--script/provider/provider.lua12
-rw-r--r--script/service/service.lua5
-rw-r--r--script/service/telemetry.lua4
-rw-r--r--script/workspace/workspace.lua15
-rw-r--r--test/tclient/tests/folders-with-single-file.lua4
-rw-r--r--test/tclient/tests/single-mode.lua8
22 files changed, 143 insertions, 49 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 94991839..1fe9d711 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -21,7 +21,7 @@
],
},
{
- "name": "🪡attach",
+ "name": "🍄attach",
"type": "lua",
"request": "attach",
"stopOnEntry": false,
diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle
-Subproject 66a38c054a61fd5993c747cb967802f34e635ae
+Subproject 7584fe6367e1379c8a4faca5935fd1aa9a14207
diff --git a/3rd/bee.lua b/3rd/bee.lua
-Subproject 55c9c6bfd6ae4a576cd8777e232d7be48253b94
+Subproject 2f044267000fce0d033d46802ba538d2f8bf9d5
diff --git a/3rd/love-api b/3rd/love-api
-Subproject 6532c3890915ceb265afc64a33ca1b838a28acb
+Subproject 97e24dc98106a59fa312dd2d14f01ea5c9f2bd6
diff --git a/3rd/lovr-api b/3rd/lovr-api
-Subproject 8548de845c91dfd8639d47018b7d421f857322e
+Subproject 0e0f2d21761571d3b4caefc12c1b57bffeb8166
diff --git a/3rd/luamake b/3rd/luamake
-Subproject 909a3bf9770c61efc8a3050402ecbfa4daf24dd
+Subproject 974d5b631056086d7fa0abc8fc96873df5514c4
diff --git a/changelog.md b/changelog.md
index 58877c5f..8ef9b06a 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,8 +1,12 @@
# changelog
## 2.6.7
+`2022-3-9`
* `NEW` offline diagnostic, [read more](https://github.com/sumneko/lua-language-server/wiki/Offline-Diagnostic)
+* `CHG` `VSCode`: 1.65 has built in new `Lua` syntax files, so this extension no longer provides syntax files, which means you can install other syntax extensions in the marketplace. If you have any suggestions or issues, please [open issues here](https://github.com/sumneko/lua.tmbundle).
+* `CHG` telemetry: the prompt will only appear in VSCode to avoid repeated prompts in other platforms due to the inability to automatically modify the settings.
* `FIX` [#965](https://github.com/sumneko/lua-language-server/issues/965)
+* `FIX` [#975](https://github.com/sumneko/lua-language-server/issues/975)
## 2.6.6
`2022-2-21`
diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua
index 5e9a4099..edf76e2c 100644
--- a/locale/en-us/script.lua
+++ b/locale/en-us/script.lua
@@ -34,7 +34,7 @@ DIAG_PREFIELD_CALL =
'Will be interpreted as `{}{}`. It may be necessary to add a `,` or `;`.'
DIAG_OVER_MAX_ARGS =
'The function takes only {:d} parameters, but you passed {:d}.'
-DIAG_OVER_MAX_ARGS =
+DIAG_OVER_MAX_VALUES =
'Only has {} variables, but you set {} values.'
DIAG_AMBIGUITY_1 =
'Compute `{}` first. You may need to add brackets.'
@@ -457,6 +457,13 @@ WINDOW_LUA_STATUS_CACHED_FILES =
'Cached files: {ast}/{max}'
WINDOW_LUA_STATUS_MEMORY_COUNT =
'Memory usage: {mem:.f}M'
+WINDOW_LUA_STATUS_TIP =
+[[
+
+This icon is a cat,
+Not a dog nor a fox!
+ ↓↓↓
+]]
WINDOW_APPLY_SETTING =
'Apply setting'
WINDOW_CHECK_SEMANTIC =
diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua
index 32cd7d13..f30257fb 100644
--- a/locale/zh-cn/script.lua
+++ b/locale/zh-cn/script.lua
@@ -456,6 +456,13 @@ WINDOW_LUA_STATUS_CACHED_FILES =
'已缓存文件:{ast}/{max}'
WINDOW_LUA_STATUS_MEMORY_COUNT =
'内存占用:{mem:.f}M'
+WINDOW_LUA_STATUS_TIP =
+[[
+
+这个图标是猫,
+不是狗也不是狐狸!
+ ↓↓↓
+]]
WINDOW_APPLY_SETTING =
'应用设置'
WINDOW_CHECK_SEMANTIC =
diff --git a/meta/3rd/lovr/library/lovr.graphics.lua b/meta/3rd/lovr/library/lovr.graphics.lua
index f0ccb310..fe0b6c33 100644
--- a/meta/3rd/lovr/library/lovr.graphics.lua
+++ b/meta/3rd/lovr/library/lovr.graphics.lua
@@ -1450,6 +1450,10 @@ function Canvas:isStereo() end
---
---Returns a new Image containing the contents of a Texture attached to the Canvas.
---
+---
+---### NOTE:
+---The Image will have the same pixel format as the Texture that is read from.
+---
---@param index? number # The index of the Texture to read from.
---@return lovr.Image image # The new Image.
function Canvas:newImage(index) end
diff --git a/meta/3rd/lovr/library/lovr.math.lua b/meta/3rd/lovr/library/lovr.math.lua
index 7cf348c6..3ce62dd9 100644
--- a/meta/3rd/lovr/library/lovr.math.lua
+++ b/meta/3rd/lovr/library/lovr.math.lua
@@ -644,6 +644,20 @@ local Vec2 = {}
function Vec2:add(u) end
---
+---Returns the angle between vectors.
+---
+---
+---### NOTE:
+---If any of the two vectors have a length of zero, the angle between them is not well defined.
+---
+---In this case the function returns `math.pi / 2`.
+---
+---@overload fun(self: lovr.Vec2, x: number, y: number):number
+---@param u lovr.Vec2 # The other vector.
+---@return number angle # The angle to the other vector, in radians.
+function Vec2:angle(u) end
+
+---
---Returns the distance to another vector.
---
---@overload fun(self: lovr.Vec2, x: number, y: number):number
@@ -749,6 +763,20 @@ local Vec3 = {}
function Vec3:add(u) end
---
+---Returns the angle between vectors.
+---
+---
+---### NOTE:
+---If any of the two vectors have a length of zero, the angle between them is not well defined.
+---
+---In this case the function returns `math.pi / 2`.
+---
+---@overload fun(self: lovr.Vec3, x: number, y: number, z: number):number
+---@param u lovr.Vec3 # The other vector.
+---@return number angle # The angle to the other vector, in radians.
+function Vec3:angle(u) end
+
+---
---Sets this vector to be equal to the cross product between this vector and another one.
---
---The new `v` will be perpendicular to both the old `v` and `u`.
@@ -873,6 +901,20 @@ local Vec4 = {}
function Vec4:add(u) end
---
+---Returns the angle between vectors.
+---
+---
+---### NOTE:
+---If any of the two vectors have a length of zero, the angle between them is not well defined.
+---
+---In this case the function returns `math.pi / 2`.
+---
+---@overload fun(self: lovr.Vec4, x: number, y: number, z: number, w: number):number
+---@param u lovr.Vec4 # The other vector.
+---@return number angle # The angle to other vector, in radians.
+function Vec4:angle(u) end
+
+---
---Returns the distance to another vector.
---
---@overload fun(self: lovr.Vec4, x: number, y: number, z: number, w: number):number
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index bb6282a4..ef426633 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -817,18 +817,17 @@ return function (uri, start, finish)
for _, comm in ipairs(state.comms) do
if start <= comm.start and comm.finish <= finish then
if comm.type == 'comment.short' then
- local head = comm.text:sub(1, 2)
- if head == '-@'
- or head == '-|' then
+ local head = comm.text:match '^%-%s*[@|]'
+ if head then
results[#results+1] = {
start = comm.start,
- finish = comm.start + 3,
+ finish = comm.start + #head + 1,
type = define.TokenTypes.comment,
}
results[#results+1] = {
- start = comm.start + 3,
- finish = comm.start + 2 + #comm.text:match '%S+',
- type = define.TokenTypes.comment,
+ start = comm.start + #head + 1,
+ finish = comm.start + #head + 2 + #comm.text:match('%S*', #head + 1),
+ type = define.TokenTypes.keyword,
modifieres = define.TokenModifiers.documentation,
}
else
diff --git a/script/file-uri.lua b/script/file-uri.lua
index 7f3e36a8..ccd47156 100644
--- a/script/file-uri.lua
+++ b/script/file-uri.lua
@@ -94,4 +94,8 @@ function m.decode(uri)
return value
end
+function m.split(uri)
+ return uri:match('([^:]*):?/?/?([^/]*)(.*)')
+end
+
return m
diff --git a/script/files.lua b/script/files.lua
index 37aef7e1..9ddc5039 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -36,13 +36,10 @@ end
m.reset()
local fixedUri = {}
---- 获取文件的真实uri(真实大小写)
+--- 获取文件的真实uri
---@param uri uri
---@return uri
function m.getRealUri(uri)
- if platform.OS ~= 'Windows' then
- return uri
- end
local filename = furi.decode(uri)
local path = fs.path(filename)
local suc, res = pcall(fs.exists, path)
@@ -69,7 +66,6 @@ function m.open(uri)
cache = {},
}
m.onWatch('open', uri)
- m.addRef(uri)
end
--- 关闭文件
@@ -81,7 +77,11 @@ function m.close(uri)
file.trusted = false
end
m.onWatch('close', uri)
- m.delRef(uri)
+ if file then
+ if (file._ref or 0) <= 0 and not m.isOpen(uri) then
+ m.remove(uri)
+ end
+ end
end
--- 是否打开
@@ -380,7 +380,7 @@ function m.delRef(uri)
end
file._ref = (file._ref or 0) - 1
log.debug('del ref', uri)
- if file._ref <= 0 then
+ if file._ref <= 0 and not m.isOpen(uri) then
m.remove(uri)
end
end
@@ -661,13 +661,10 @@ end
---@param uri uri
---@return boolean
function m.isLua(uri)
- local ext = uri:match '%.([^%.%/%\\]+)$'
- if not ext then
- return false
- end
- if ext == 'lua' then
+ if util.stringEndWith(uri:lower(), '.lua') then
return true
end
+ -- check customed assoc, e.g. `*.lua.txt = *.lua`
local matcher = m.getAssoc(uri)
local path = furi.decode(uri)
return matcher(path)
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index ebbc8bcb..cf734a53 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -714,20 +714,21 @@ function parseType(parent)
if currentRow < nextCommRow then
return false
end
- if nextComm.text:sub(1, 2) == '-@' then
+ if nextComm.text:match '^%-%s*%@' then
return false
else
- if nextComm.text:sub(1, 2) == '-|' then
+ local resumeHead = nextComm.text:match '^%-%s*%|'
+ if resumeHead then
NextComment(i)
row = row + i + 1
- local finishPos = nextComm.text:find('#', 3) or #nextComm.text
- parseTokens(nextComm.text:sub(3, finishPos), nextComm.start + 3)
+ local finishPos = nextComm.text:find('#', #resumeHead + 1) or #nextComm.text
+ parseTokens(nextComm.text:sub(#resumeHead + 1, finishPos), nextComm.start + #resumeHead + 1)
local resume = parseResume(result)
if resume then
if comments then
resume.comment = table.concat(comments, '\n')
else
- resume.comment = nextComm.text:match('#%s*(.+)', 3)
+ resume.comment = nextComm.text:match('#%s*(.+)', #resumeHead + 1)
end
result.types[#result.types+1] = resume
result.finish = resume.finish
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index de1a735e..ac93dc52 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -13,6 +13,7 @@ local converter = require 'proto.converter'
local loading = require 'workspace.loading'
local scope = require 'workspace.scope'
local time = require 'bee.time'
+local ltable = require 'linked-table'
---@class diagnosticProvider
local m = {}
@@ -225,7 +226,7 @@ function m.doDiagnostic(uri, isScopeDiag)
local prog <close> = progress.create(scp, lang.script.WINDOW_DIAGNOSING, 0.5)
prog:setMessage(ws.getRelativePath(uri))
- log.debug('Diagnostic file:', uri)
+ --log.debug('Diagnostic file:', uri)
local syntax = m.syntaxErrors(uri, state)
@@ -235,7 +236,7 @@ function m.doDiagnostic(uri, isScopeDiag)
tracy.ZoneBeginN 'mergeSyntaxAndDiags'
local _ <close> = tracy.ZoneEnd
local full = mergeDiags(syntax, lastDiag, diags)
- log.debug(('Pushed [%d] results'):format(full and #full or 0))
+ --log.debug(('Pushed [%d] results'):format(full and #full or 0))
if not full then
m.clear(uri)
return
@@ -360,28 +361,38 @@ local function askForDisable(uri)
end
---@async
-function m.awaitDiagnosticsScope(uri)
- local scp = scope.getScope(uri)
+function m.awaitDiagnosticsScope(suri)
+ local scp = scope.getScope(suri)
while loading.count() > 0 do
await.sleep(1.0)
end
local clock = os.clock()
- local bar <close> = progress.create(scope.getScope(uri), lang.script.WORKSPACE_DIAGNOSTIC, 1)
+ local bar <close> = progress.create(scope.getScope(suri), lang.script.WORKSPACE_DIAGNOSTIC, 1)
local cancelled
bar:onCancel(function ()
log.debug('Cancel workspace diagnostics')
cancelled = true
---@async
await.call(function ()
- askForDisable(uri)
+ askForDisable(suri)
end)
end)
- local uris = files.getAllUris(uri)
+ local uris = files.getAllUris(suri)
+ local sortedUris = ltable()
+ for _, uri in ipairs(uris) do
+ if files.isOpen(uri) then
+ sortedUris:pushHead(uri)
+ else
+ sortedUris:pushTail(uri)
+ end
+ end
log.info(('Diagnostics scope [%s], files count:[%d]'):format(scp:getName(), #uris))
- for i, uri in ipairs(uris) do
+ local i = 0
+ for uri in sortedUris:pairs() do
while loading.count() > 0 do
await.sleep(1.0)
end
+ i = i + 1
bar:setMessage(('%d/%d'):format(i, #uris))
bar:setPercentage(i / #uris * 100)
xpcall(m.doDiagnostic, log.error, uri, true)
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 5ee99b3e..eb4a274c 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -225,8 +225,13 @@ m.register 'workspace/didRenameFiles' {
m.register 'textDocument/didOpen' {
---@async
function (params)
- local doc = params.textDocument
- local uri = files.getRealUri(doc.uri)
+ local doc = params.textDocument
+ local scheme = furi.split(doc.uri)
+ if scheme ~= 'file' then
+ return
+ end
+ local uri = files.getRealUri(doc.uri)
+ log.debug('didOpen', uri)
workspace.awaitReady(uri)
local text = doc.text
files.setText(uri, text, true, function (file)
@@ -613,6 +618,9 @@ m.register 'textDocument/completion' {
end
items[i] = item
end
+ if result.incomplete == nil then
+ result.incomplete = false
+ end
return {
isIncomplete = result.incomplete,
items = items,
diff --git a/script/service/service.lua b/script/service/service.lua
index 66143f84..a1db02a8 100644
--- a/script/service/service.lua
+++ b/script/service/service.lua
@@ -197,6 +197,8 @@ function m.eventLoop()
end
end
+local showStatusTip = math.random(100) == 1
+
function m.reportStatus()
local info = {}
if m.workingClock and time.monotonic() - m.workingClock > 100 then
@@ -218,6 +220,9 @@ function m.reportStatus()
end
tooltips[#tooltips+1] = lang.script('WINDOW_LUA_STATUS_CACHED_FILES', params)
tooltips[#tooltips+1] = lang.script('WINDOW_LUA_STATUS_MEMORY_COUNT', params)
+ if showStatusTip then
+ tooltips[#tooltips+1] = lang.script('WINDOW_LUA_STATUS_TIP')
+ end
info.tooltip = table.concat(tooltips, '\n')
if util.equal(m.lastInfo, info) then
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua
index d975a986..1104865c 100644
--- a/script/service/telemetry.lua
+++ b/script/service/telemetry.lua
@@ -90,7 +90,6 @@ local function pushErrorLog(link)
))
end
-local validMap = {}
local isValid = false
timer.wait(5, function ()
@@ -145,6 +144,9 @@ function m.updateConfig()
if isValid ~= nil then
return
end
+ if not client.getOption 'changeConfiguration' then
+ return
+ end
if m.hasShowedMessage then
return
end
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index 80df7d9c..934c0735 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -241,8 +241,9 @@ function m.awaitLoadFile(uri)
log.info('Scan files at:', uri)
---@async
native:scan(furi.decode(uri), function (path)
- scp:get('cachedUris')[furi.encode(path)] = true
- ld:loadFile(furi.encode(path))
+ local uri = files.getRealUri(furi.encode(path))
+ scp:get('cachedUris')[uri] = true
+ ld:loadFile(uri)
end)
ld:loadAll()
end
@@ -282,8 +283,9 @@ function m.awaitPreload(scp)
log.info('Scan files at:', scp:getName())
---@async
native:scan(furi.decode(scp.uri), function (path)
- scp:get('cachedUris')[furi.encode(path)] = true
- ld:loadFile(furi.encode(path))
+ local uri = files.getRealUri(furi.encode(path))
+ scp:get('cachedUris')[uri] = true
+ ld:loadFile(uri)
end)
end
@@ -292,8 +294,9 @@ function m.awaitPreload(scp)
scp:addLink(libMatcher.uri)
---@async
libMatcher.matcher:scan(furi.decode(libMatcher.uri), function (path)
- scp:get('cachedUris')[furi.encode(path)] = true
- ld:loadFile(furi.encode(path), libMatcher.uri)
+ local uri = files.getRealUri(furi.encode(path))
+ scp:get('cachedUris')[uri] = true
+ ld:loadFile(uri, libMatcher.uri)
end)
scp:gc(fw.watch(furi.decode(libMatcher.uri)))
end
diff --git a/test/tclient/tests/folders-with-single-file.lua b/test/tclient/tests/folders-with-single-file.lua
index e77535c9..2a5db70b 100644
--- a/test/tclient/tests/folders-with-single-file.lua
+++ b/test/tclient/tests/folders-with-single-file.lua
@@ -45,7 +45,7 @@ print(x)
client:notify('textDocument/didOpen', {
textDocument = {
- uri = 'test://single-file.lua',
+ uri = 'file://single-file.lua',
languageId = 'lua',
version = 0,
text = [[
@@ -58,7 +58,7 @@ print(x)
ws.awaitReady(nil)
local locations = client:awaitRequest('textDocument/definition', {
- textDocument = { uri = 'test://single-file.lua' },
+ textDocument = { uri = 'file://single-file.lua' },
position = { line = 1, character = 0 },
})
diff --git a/test/tclient/tests/single-mode.lua b/test/tclient/tests/single-mode.lua
index f79fa2e8..4e14415b 100644
--- a/test/tclient/tests/single-mode.lua
+++ b/test/tclient/tests/single-mode.lua
@@ -9,7 +9,7 @@ lclient():start(function (client)
client:notify('textDocument/didOpen', {
textDocument = {
- uri = 'test://single-file.lua',
+ uri = 'file://single-file.lua',
languageId = 'lua',
version = 0,
text = [[
@@ -22,13 +22,13 @@ print(x)
ws.awaitReady()
local locations = client:awaitRequest('textDocument/definition', {
- textDocument = { uri = 'test://single-file.lua' },
+ textDocument = { uri = 'file://single-file.lua' },
position = { line = 1, character = 7 },
})
assert(util.equal(locations, {
{
- uri = 'test://single-file.lua',
+ uri = 'file://single-file.lua',
range = {
start = { line = 0, character = 6 },
['end'] = { line = 0, character = 7 },
@@ -37,7 +37,7 @@ print(x)
}))
local locations = client:awaitRequest('textDocument/definition', {
- textDocument = { uri = 'test://single-file.lua' },
+ textDocument = { uri = 'file://single-file.lua' },
position = { line = 1, character = 0 },
})