From dcaf81f511c47ca8be9860e4237c1faae0fd3a89 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 2 Jan 2023 13:59:25 +0100 Subject: 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. --- init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3