Skip to content

Commit 27d1676

Browse files
author
cos
committed
Only call workspace/configuration when available
Not all clients implement the client capability: `configuration`, which was added in version 3.6.0 of the Language Server Protocol. The LSP Specification also states: > A missing property should be interpreted as an absence of the capability. Above claims are possible to verify by reading the mentioned spec. at: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_configuration Hence this change modifies behaviour to only call the method on clients explicitly announcing to support it. This commit makes the lua-language-server work with vim-ale. Thanks to Tom Lau for assistance in getting the test-setup updated.
1 parent a126e9c commit 27d1676

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

script/lclient.lua

Lines changed: 3 additions & 0 deletions
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

Lines changed: 10 additions & 5 deletions
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)