]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add test for "customNotificationHandlers"
authorAndreas Louv <andreas@louv.dk>
Mon, 6 Mar 2023 22:28:40 +0000 (23:28 +0100)
committerAndreas Louv <andreas@louv.dk>
Tue, 7 Mar 2023 16:38:39 +0000 (17:38 +0100)
test/unit_tests.vim

index 8bd10108965dbaf122c67dddea49c7863ff5303a..dd16bfde1259391b11bf47e9860bd7b73a514b2c 100644 (file)
@@ -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<any>, reply: dict<any>) => {
+          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<string> =<< 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