aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-01-02 13:59:25 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2023-01-02 13:59:25 +0100
commitdcaf81f511c47ca8be9860e4237c1faae0fd3a89 (patch)
tree7ffb6a7f68ba63092616105332e0f7f1db71f4ee
parente41ab2b985c03477025cb518dc8f7903f597e5d9 (diff)
downloadvis-lspc-dcaf81f511c47ca8be9860e4237c1faae0fd3a89.tar.gz
vis-lspc-dcaf81f511c47ca8be9860e4237c1faae0fd3a89.zip
fix textDocumentSync.save ServerCapability check
The ServerCapability textDocumentSync is optional and may be of kind TextDocumentSyncOptions | TextDocumentSyncKind; If a server uses TextDocumentSyncKind which is a integer enum our .save check fails. Test if it is save to use textDocumentSync as table before checking the save capability. Fixes !35.
-rw-r--r--init.lua3
1 files changed, 2 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index c6bbb02..b0339aa 100644
--- a/init.lua
+++ b/init.lua
@@ -1054,7 +1054,8 @@ local function lspc_open(ls, win, file)
end)
-- the server is interested in didSave notifications
- if ls.capabilities.textDocumentSync.save then
+ if ls.capabilities.textDocumentSync and type(ls.capabilities.textDocumentSync) ==
+ 'table' and ls.capabilities.textDocumentSync.save then
vis.events.subscribe(vis.events.FILE_SAVE_POST,
function(file, path) -- luacheck: ignore file
for _, ls in pairs(lspc.running) do -- luacheck: ignore ls