Skip to content

Commit 8dd2710

Browse files
authored
Merge branch 'master' into fixes-a-specific-case-for-getVisibleType
2 parents e558d6e + 3d88f33 commit 8dd2710

File tree

8 files changed

+53
-13
lines changed

8 files changed

+53
-13
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
- { os: ubuntu-22.04, target: linux, platform: linux-x64, container: 'alpine:latest', libc: musl }
2828
- { os: ubuntu-20.04, target: linux, platform: linux-x64 }
2929
- { os: ubuntu-20.04, target: linux, platform: linux-arm64 }
30-
- { os: macos-11, target: darwin, platform: darwin-x64 }
31-
- { os: macos-11, target: darwin, platform: darwin-arm64 }
30+
- { os: macos-latest, target: darwin, platform: darwin-x64 }
31+
- { os: macos-latest, target: darwin, platform: darwin-arm64 }
3232
- { os: windows-latest, target: windows, platform: win32-ia32 }
3333
- { os: windows-latest, target: windows, platform: win32-x64 }
3434
runs-on: ${{ matrix.os }}

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
* `FIX` Respect `completion.showParams` config for local function completion
99
* `CHG` Improve performance of multithreaded `--check` and `undefined-field` diagnostic
1010
* `FIX` Now correctly evaluates the visibility of fields in a class when they are defined directly in the object. use for completion and invisible dianostic. [#2752](https://github.com/LuaLS/lua-language-server/issues/2752)
11+
* `NEW` added lua regular expression support for Lua.doc.<scope>Name [#2753](https://github.com/LuaLS/lua-language-server/pull/2753)
1112
* `FIX` Bad triggering of the `inject-field` diagnostic, when the fields are declared at the creation of the object [#2746](https://github.com/LuaLS/lua-language-server/issues/2746)
13+
* `CHG` Change spacing of parameter inlay hints to match other LSPs, like `rust-analyzer`
1214

1315
## 3.9.3
1416
`2024-6-11`

meta/template/string.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ function string.gmatch(s, pattern, init) end
7373
---@param n? integer
7474
---@return string
7575
---@return integer count
76-
---@nodiscard
7776
function string.gsub(s, pattern, repl, n) end
7877

7978
---#DES 'string.len'

script/config/template.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,10 @@ local template = {
402402
['Lua.doc.privateName'] = Type.Array(Type.String),
403403
['Lua.doc.protectedName'] = Type.Array(Type.String),
404404
['Lua.doc.packageName'] = Type.Array(Type.String),
405-
405+
['Lua.doc.regengine'] = Type.String >> 'glob' << {
406+
'glob',
407+
'lua',
408+
},
406409
-- VSCode
407410
["Lua.addonManager.enable"] = Type.Boolean >> true,
408411
['files.associations'] = Type.Hash(Type.String, Type.String),

script/core/hint.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ local function typeHint(uri, results, start, finish)
5959
end
6060
mark[src] = true
6161
results[#results+1] = {
62-
text = ':' .. view,
62+
text = ': ' .. view,
6363
offset = src.finish,
6464
kind = define.InlayHintKind.Type,
6565
where = 'right',

script/provider/provider.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,8 +1426,8 @@ m.register 'textDocument/inlayHint' {
14261426
},
14271427
position = converter.packPosition(state, res.offset),
14281428
kind = res.kind,
1429-
paddingLeft = res.kind == 1,
1430-
paddingRight = res.kind == 2,
1429+
paddingLeft = false,
1430+
paddingRight = res.kind == define.InlayHintKind.Parameter,
14311431
}
14321432
end
14331433
return hintResults

script/vm/visible.lua

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ local glob = require 'glob'
77
---@class parser.object
88
---@field package _visibleType? parser.visibleType
99

10+
local function globMatch(patterns, fieldName)
11+
return glob.glob(patterns)(fieldName)
12+
end
13+
14+
local function luaMatch(patterns, fieldName)
15+
for i = 1, #patterns do
16+
if string.find(fieldName, patterns[i]) then
17+
return true
18+
end
19+
end
20+
return false
21+
end
22+
1023
local function getVisibleType(source)
1124
if guide.isLiteral(source) then
1225
return 'public'
@@ -42,21 +55,22 @@ local function getVisibleType(source)
4255

4356
if type(fieldName) == 'string' then
4457
local uri = guide.getUri(source)
45-
58+
local regengine = config.get(uri, 'Lua.doc.regengine')
59+
local match = regengine == "glob" and globMatch or luaMatch
4660
local privateNames = config.get(uri, 'Lua.doc.privateName')
47-
if #privateNames > 0 and glob.glob(privateNames)(fieldName) then
61+
if #privateNames > 0 and match(privateNames, fieldName) then
4862
source._visibleType = 'private'
4963
return 'private'
5064
end
51-
65+
5266
local protectedNames = config.get(uri, 'Lua.doc.protectedName')
53-
if #protectedNames > 0 and glob.glob(protectedNames)(fieldName) then
67+
if #protectedNames > 0 and match(protectedNames, fieldName) then
5468
source._visibleType = 'protected'
5569
return 'protected'
5670
end
57-
71+
5872
local packageNames = config.get(uri, 'Lua.doc.packageName')
59-
if #packageNames > 0 and glob.glob(packageNames)(fieldName) then
73+
if #packageNames > 0 and match(packageNames, fieldName) then
6074
source._visibleType = 'package'
6175
return 'package'
6276
end

test/diagnostics/invisible.lua

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,28 @@ print(t2._id)
138138
]]
139139
config.set(nil, 'Lua.doc.protectedName', nil)
140140

141+
config.set(nil, 'Lua.doc.regengine', 'lua' )
142+
config.set(nil, 'Lua.doc.privateName', { '^_[%w_]*%w$' })
143+
config.set(nil, 'Lua.doc.protectedName', { '^_[%w_]*_$' })
144+
TEST [[
145+
---@class A
146+
---@field _id_ number
147+
---@field _user number
148+
149+
---@type A
150+
local t
151+
print(t.<!_id_!>)
152+
print(t.<!_user!>)
153+
154+
---@class B: A
155+
local t2
156+
print(t2._id_)
157+
print(t2.<!_user!>)
158+
]]
159+
config.set(nil, 'Lua.doc.privateName', nil)
160+
config.set(nil, 'Lua.doc.protectedName', nil)
161+
config.set(nil, 'Lua.doc.regengine', nil )
162+
141163
TEST [[
142164
---@class A
143165
---@field private x number

0 commit comments

Comments
 (0)