From 1ec12cc8c26a6b97b6d36081fc198a7228229b4f Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Mon, 6 Mar 2023 23:28:40 +0100 Subject: [PATCH] Add test for "customNotificationHandlers" --- test/unit_tests.vim | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/test/unit_tests.vim b/test/unit_tests.vim index 8bd1010..dd16bfd 100644 --- a/test/unit_tests.vim +++ b/test/unit_tests.vim @@ -19,10 +19,17 @@ if do_profile endif source ../plugin/lsp.vim + var lspServers = [{ filetype: ['c', 'cpp'], path: (exepath('clangd-14') ?? exepath('clangd')), - args: ['--background-index', '--clang-tidy'] + args: ['--background-index', '--clang-tidy'], + initializationOptions: { clangdFileStatus: true }, + customNotificationHandlers: { + 'textDocument/clangd.fileStatus': (lspserver: dict, reply: dict) => { + g:LSPTest_customNotificationHandlerReplied = true + } + } }] call LspAddServer(lspServers) echomsg systemlist($'{lspServers[0].path} --version') @@ -40,7 +47,7 @@ g:LSPTest = true # Return zero for success, one for failure (like the assert function). func WaitForAssert(assert, ...) let timeout = get(a:000, 0, 5000) - if WaitForCommon(v:null, a:assert, timeout) < 0 + if s:WaitForCommon(v:null, a:assert, timeout) < 0 return 1 endif return 0 @@ -900,6 +907,24 @@ def Test_LspDiagsUpdated_Autocmd() assert_equal(3, g:LspAutoCmd) enddef +# Test custom notification handlers +def Test_LspCustomNotificationHandlers() + + g:LSPTest_customNotificationHandlerReplied = false + + silent! edit Xtest.c + sleep 200m + var lines: list =<< trim END + int a = 1; + int main(void) { + return a; + } + END + setline(1, lines) + WaitForAssert(() => assert_equal(true, g:LSPTest_customNotificationHandlerReplied)) + :%bw! +enddef + # Start the C language server. Returns true on success and false on failure. def StartLangServer(): bool # Edit a dummy C file to start the LSP server -- 2.48.1