From da7767a1fb510b58ca998c2e5223fc5c11fd2389 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Mon, 7 Nov 2022 16:04:36 +0000 Subject: [PATCH] Keep support for depracated format syntax in version <= 7 --- lua/config_lsp.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lua/config_lsp.lua b/lua/config_lsp.lua index 7ffd4bd1..b5b22263 100644 --- a/lua/config_lsp.lua +++ b/lua/config_lsp.lua @@ -29,9 +29,16 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) - vim.keymap.set('n', 'i', function () - vim.lsp.buf.format({timeout_ms=10000,async=false}) -- async=true is strange behavior - end, bufopts) + -- Keep support for deprecated syntax in vim <= 7 + if vim.version().major <= 7 then + vim.keymap.set('n', 'i', function () + vim.lsp.buf.formatting_sync({timeout_ms=10000}) + end, bufopts) + else + vim.keymap.set('n', 'i', function () + vim.lsp.buf.format({timeout_ms=10000,async=false}) + end, bufopts) + end -- Enable aerial support require("aerial").on_attach(client, bufnr) end