From 2cd7d34375a20b8b6527a1730c38a026c29de13a Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 6 Aug 2024 17:29:36 +0100 Subject: [PATCH] Actually fix restarting the LSP in :BuildDir job callback --- plugin/build.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugin/build.lua b/plugin/build.lua index ce3ff19..e924a74 100644 --- a/plugin/build.lua +++ b/plugin/build.lua @@ -31,9 +31,12 @@ function build.set_dir(dirname) -- Restart clangd language server on_exit = function() - vim.cmd('LspStop') - vim.cmd('LspStart') - echo('Build directory selected: ' .. dirname, 'DiagnosticInfo') + -- This is a callback so doesn't run on the main thread which causes + -- issues for running commands, so schedule that on the main thread. + vim.schedule(function() + vim.cmd('LspRestart') + echo('Build directory selected: ' .. dirname, 'DiagnosticInfo') + end) end, -- Display any error messages to the user