Skip to content

Commit e87d7d6

Browse files
authored
Merge pull request #2843 from nospam2998/fix/honour_configuration_capability-master
Only call workspace/configuration when available
2 parents a126e9c + c900372 commit e87d7d6

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* `FIX` Improve type narrow by checking exact match on literal type params
1111
* `FIX` Correctly list enums for function overload arguments [#2840](https://github.com/LuaLS/lua-language-server/pull/2840)
1212
* `FIX` Incorrect function params' type infer when there is only `@overload` [#2509](https://github.com/LuaLS/lua-language-server/issues/2509) [#2708](https://github.com/LuaLS/lua-language-server/issues/2708) [#2709](https://github.com/LuaLS/lua-language-server/issues/2709)
13+
* `FIX` Only call workspace/configuration when available [#981](https://github.com/LuaLS/lua-language-server/issues/981), [#2318](https://github.com/LuaLS/lua-language-server/issues/2318), [2336](https://github.com/LuaLS/lua-language-server/issues/2336) [#2843](https://github.com/LuaLS/lua-language-server/pull/2843)
1314

1415
## 3.10.5
1516
`2024-8-19`

script/lclient.lua

+3
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

script/provider/provider.lua

+10-5
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)