99
1010
1111NVIM_LISTEN_ADDRESS = "/tmp/nvim-LanguageClient-IntegrationTest"
12+ EXPLAIN_ERROR_BUFFER = "__LCNExplainError__"
13+ HOVER_BUFFER = "__LCNHover__"
1214
1315
1416project_root = os .path .dirname (os .path .abspath (__file__ ))
@@ -36,8 +38,8 @@ def assertRetry(predicate, retry_max=100):
3638 assert predicate ()
3739
3840
39- def getLanguageClientBuffers (nvim ):
40- return [b for b in nvim .buffers if b .name .endswith ("__LCNHover__" )]
41+ def getBufferByName (nvim , name : str ):
42+ return [b for b in nvim .buffers if b .name .endswith (name )]
4143
4244
4345@pytest .fixture (scope = "module" )
@@ -52,6 +54,18 @@ def setup(nvim):
5254 nvim .command ("%bdelete!" )
5355
5456
57+ def test_explainErrorAtPoint (nvim ):
58+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
59+ time .sleep (1 )
60+ nvim .funcs .cursor (26 , 2 )
61+ nvim .funcs .LanguageClient_explainErrorAtPoint ()
62+ time .sleep (1 )
63+ buf = getBufferByName (nvim , EXPLAIN_ERROR_BUFFER )[0 ]
64+ expect = "1. assign: self-assignment of x to x"
65+
66+ assert expect in "\n " .join (buf )
67+
68+
5569def test_textDocument_definition (nvim ):
5670 nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
5771 time .sleep (2 )
@@ -68,7 +82,7 @@ def test_textDocument_hover(nvim):
6882 nvim .funcs .cursor (10 , 16 )
6983 nvim .funcs .LanguageClient_textDocument_hover ()
7084 time .sleep (1 )
71- buf = getLanguageClientBuffers (nvim )[0 ]
85+ buf = getBufferByName (nvim , HOVER_BUFFER )[0 ]
7286 expect = "func greet() int32"
7387
7488 assert expect in "\n " .join (buf )
@@ -136,22 +150,22 @@ def test_workspace_symbol(nvim):
136150 nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
137151 time .sleep (1 )
138152 nvim .funcs .cursor (1 , 1 )
139- nvim .funcs .LanguageClient_workspace_symbol ()
153+ nvim .funcs .LanguageClient_workspace_symbol ('yo' )
140154 time .sleep (1 )
141155
142156 assert nvim .funcs .getloclist (0 )
143157
144- nvim .command ("3lnext " )
158+ nvim .command ("lnext " )
145159
146- assert nvim .current .window .cursor == [17 , 0 ]
160+ assert nvim .current .window .cursor == [24 , 5 ]
147161
148162
149163def test_textDocument_references (nvim ):
150164 nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
151165 time .sleep (1 )
152166 nvim .funcs .cursor (13 , 6 )
153167 nvim .funcs .LanguageClient_textDocument_references ()
154- time .sleep (2 )
168+ time .sleep (3 )
155169 expect = ["func greet() int32 {" , "log.Println(greet())" ,
156170 "log.Println(greet())" ]
157171
@@ -239,7 +253,7 @@ def test_textDocument_hover_float_window_closed_on_cursor_moved(nvim):
239253
240254 pos = _open_float_window (nvim )
241255
242- float_buf = getLanguageClientBuffers (nvim )[0 ]
256+ float_buf = getBufferByName (nvim , HOVER_BUFFER )[0 ]
243257
244258 # Check if float window is open
245259 float_winnr = nvim .funcs .bufwinnr (float_buf .number )
@@ -253,7 +267,7 @@ def test_textDocument_hover_float_window_closed_on_cursor_moved(nvim):
253267 nvim .funcs .cursor (10 , 14 )
254268
255269 # Check float window buffer was closed by CursorMoved
256- assert len (getLanguageClientBuffers (nvim )) == 0
270+ assert len (getBufferByName (nvim , HOVER_BUFFER )) == 0
257271
258272
259273def test_textDocument_hover_float_window_closed_on_entering_window (nvim ):
@@ -276,7 +290,7 @@ def test_textDocument_hover_float_window_closed_on_entering_window(nvim):
276290 assert win_id == nvim .funcs .win_getid ()
277291
278292 # Check float window buffer was closed by BufEnter
279- assert len (getLanguageClientBuffers (nvim )) == 0
293+ assert len (getBufferByName (nvim , HOVER_BUFFER )) == 0
280294 finally :
281295 nvim .command ("close!" )
282296
@@ -298,7 +312,7 @@ def test_textDocument_hover_float_window_closed_on_switching_to_buffer(nvim):
298312
299313 _open_float_window (nvim )
300314
301- float_buf = getLanguageClientBuffers (nvim )[0 ]
315+ float_buf = getBufferByName (nvim , HOVER_BUFFER )[0 ]
302316 float_winnr = nvim .funcs .bufwinnr (float_buf .number )
303317 assert float_winnr > 0
304318
@@ -309,7 +323,7 @@ def test_textDocument_hover_float_window_closed_on_switching_to_buffer(nvim):
309323 assert nvim .current .buffer .number == another_bufnr
310324
311325 # Check float window buffer was closed by BufEnter
312- assert len (getLanguageClientBuffers (nvim )) == 0
326+ assert len (getBufferByName (nvim , HOVER_BUFFER )) == 0
313327 finally :
314328 nvim .command ("bdelete! {}" .format (another_bufnr ))
315329
@@ -334,4 +348,4 @@ def test_textDocument_hover_float_window_move_cursor_into_window(nvim):
334348 assert nvim .current .buffer .number == prev_bufnr
335349
336350 # Check float window buffer was closed by :close in the window
337- assert len (getLanguageClientBuffers (nvim )) == 0
351+ assert len (getBufferByName (nvim , HOVER_BUFFER )) == 0
0 commit comments