Skip to content

Commit 9b8b14d

Browse files
committed
Merge branch 'master' of github.com:Gowa2017/lua-language-server
2 parents 8d8ddd6 + eb9eaab commit 9b8b14d

File tree

23 files changed

+303
-37
lines changed

23 files changed

+303
-37
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
/meta/*
55
!/meta/template
66
!/meta/3rd
7-
/bin-Windows
8-
/bin-Linux
9-
/bin-macOS
10-
/bin
7+
/bin*

.vscode/launch.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
]
3737
],
3838
"windows": {
39+
"name": "🍄attach",
40+
"type": "lua",
41+
"request": "attach",
3942
"sourceMaps": [
4043
[
4144
"script\\*",

3rd/luamake

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
3636
* `redundant-return-value`
3737
* `return-type-mismatch`
3838
* `CHG` workspace-symbol: supports chain fields based on global variables and types. try `io.open` or `iolib.open`
39+
* `CHG` [#1641] if a function only has varargs and has `---@overload`, the varargs will be ignored
3940
* `FIX` [#1567]
4041
* `FIX` [#1593]
4142
* `FIX` [#1595]
4243
* `FIX` [#1599]
4344
* `FIX` [#1606]
4445
* `FIX` [#1608]
4546
* `FIX` [#1637]
47+
* `FIX` [#1642]
4648

4749
[#1177]: https://github.com/sumneko/lua-language-server/issues/1177
4850
[#1458]: https://github.com/sumneko/lua-language-server/issues/1458
@@ -58,6 +60,8 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
5860
[#1608]: https://github.com/sumneko/lua-language-server/issues/1608
5961
[#1626]: https://github.com/sumneko/lua-language-server/issues/1626
6062
[#1637]: https://github.com/sumneko/lua-language-server/issues/1637
63+
[#1641]: https://github.com/sumneko/lua-language-server/issues/1641
64+
[#1642]: https://github.com/sumneko/lua-language-server/issues/1642
6165

6266
## 3.5.6
6367
`2022-9-16`

script/brave/work.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ brave.on('removeCaches', function (path)
4040
end)
4141

4242
---@class brave.param.compile
43+
---@field uri uri
4344
---@field text string
4445
---@field mode string
4546
---@field version string
@@ -53,10 +54,15 @@ end)
5354
---@param param brave.param.compile
5455
brave.on('compile', function (param)
5556
local parser = require 'parser'
57+
local clock = os.clock()
5658
local state, err = parser.compile(param.text
5759
, param.mode
5860
, param.version
5961
, param.options
6062
)
61-
return state, err
63+
log.debug('compile', param.uri, 'takes:', os.clock() - clock)
64+
return {
65+
state = state,
66+
err = err,
67+
}
6268
end)

script/config/config.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ end
7676
function m.set(uri, key, value)
7777
local unit = template[key]
7878
assert(unit, 'unknown key: ' .. key)
79-
local scp = getScope(uri)
79+
local scp = getScope(uri, key)
8080
local oldValue = m.get(uri, key)
8181
m.setByScope(scp, key, value)
8282
local newValue = m.get(uri, key)

script/core/completion/completion.lua

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ local function checkLocal(state, word, position, results)
315315
return orders[a] < orders[b]
316316
end)
317317
for _, def in ipairs(defs) do
318-
if def.type == 'function'
318+
if (def.type == 'function' and not vm.isVarargFunctionWithOverloads(def))
319319
or def.type == 'doc.type.function' then
320320
local funcLabel = name .. getParams(def, false)
321321
buildFunction(results, source, def, false, {
@@ -364,7 +364,7 @@ local function checkModule(state, word, position, results)
364364
if not locals[stemName]
365365
and not vm.hasGlobalSets(state.uri, 'variable', stemName)
366366
and not globals[stemName]
367-
and stemName:match '^[%a_][%w_]*$'
367+
and stemName:match(guide.namePatternFull)
368368
and matchKey(word, stemName) then
369369
local targetState = files.getState(uri)
370370
if not targetState then
@@ -422,8 +422,11 @@ local function checkModule(state, word, position, results)
422422
end
423423

424424
local function checkFieldFromFieldToIndex(state, name, src, parent, word, startPos, position)
425-
if name:match '^[%a_][%w_]*$' then
426-
return nil
425+
if name:match(guide.namePatternFull) then
426+
if not name:match '[\x80-\xff]'
427+
or config.get(state.uri, 'Lua.runtime.unicodeName') then
428+
return nil
429+
end
427430
end
428431
local textEdit, additionalTextEdits
429432
local startOffset = guide.positionToOffset(state, startPos)
@@ -474,8 +477,8 @@ local function checkFieldFromFieldToIndex(state, name, src, parent, word, startP
474477
}
475478
end
476479
else
477-
if config.get(state.uri, 'Lua.runtime.version') == 'lua 5.1'
478-
or config.get(state.uri, 'Lua.runtime.version') == 'luaJIT' then
480+
if config.get(state.uri, 'Lua.runtime.version') == 'Lua 5.1'
481+
or config.get(state.uri, 'Lua.runtime.version') == 'LuaJIT' then
479482
textEdit.newText = '_G' .. textEdit.newText
480483
else
481484
textEdit.newText = '_ENV' .. textEdit.newText
@@ -487,7 +490,7 @@ end
487490
local function checkFieldThen(state, name, src, word, startPos, position, parent, oop, results)
488491
local value = vm.getObjectFunctionValue(src) or src
489492
local kind = define.CompletionItemKind.Field
490-
if value.type == 'function'
493+
if (value.type == 'function' and not vm.isVarargFunctionWithOverloads(value))
491494
or value.type == 'doc.type.function' then
492495
if oop then
493496
kind = define.CompletionItemKind.Method
@@ -569,9 +572,11 @@ local function checkFieldOfRefs(refs, state, word, startPos, position, parent, o
569572
local value = vm.getObjectFunctionValue(src) or src
570573
if value.type == 'function'
571574
or value.type == 'doc.type.function' then
572-
funcLabel = name .. getParams(value, oop)
573-
fields[funcLabel] = src
574-
count = count + 1
575+
if not vm.isVarargFunctionWithOverloads(value) then
576+
funcLabel = name .. getParams(value, oop)
577+
fields[funcLabel] = src
578+
count = count + 1
579+
end
575580
if value.type == 'function' and value.bindDocs then
576581
for _, doc in ipairs(value.bindDocs) do
577582
if doc.type == 'doc.overload' then
@@ -726,7 +731,7 @@ local function checkCommon(state, word, position, results)
726731
end
727732
end
728733
end
729-
for str, offset in state.lua:gmatch '([%a_][%w_]+)()' do
734+
for str, offset in state.lua:gmatch('(' .. guide.namePattern .. ')()') do
730735
if #results >= 100 then
731736
results.incomplete = true
732737
break

script/core/hover/init.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,12 @@ local function getHover(source)
6060
if guide.isOOP(def) then
6161
oop = true
6262
end
63-
if def.type == 'function'
64-
or def.type == 'doc.type.function' then
63+
if def.type == 'function'
64+
and not vm.isVarargFunctionWithOverloads(def) then
65+
hasFunc = true
66+
addHover(def, true, oop)
67+
end
68+
if def.type == 'doc.type.function' then
6569
hasFunc = true
6670
addHover(def, true, oop)
6771
end

script/core/look-backward.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ end
3737

3838
function m.findWord(text, offset)
3939
for i = offset, 1, -1 do
40-
if not text:sub(i, i):match '[%w_]' then
40+
if not text:sub(i, i):match '[%w_\x80-\xff]' then
4141
if i == offset then
4242
return nil
4343
end

0 commit comments

Comments
 (0)