@@ -19,10 +19,8 @@ def join_path(path: str) -> str:
1919 return os .path .join (project_root , path )
2020
2121
22- PATH_MAIN_RS = join_path ("data/sample-rs/src/main.rs" )
23- PATH_LIBS_RS = join_path ("data/sample-rs/src/libs.rs" )
24- PATH_CODEACTION = join_path ("data/sample-ts/src/codeAction.ts" )
25- print (PATH_MAIN_RS )
22+ PATH_MAIN_GO = join_path ("data/sample-go/main.go" )
23+ print (PATH_MAIN_GO )
2624
2725
2826def assertRetry (predicate , retry_max = 100 ):
@@ -55,130 +53,135 @@ def setup(nvim):
5553
5654
5755def test_textDocument_definition (nvim ):
58- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
59- time .sleep (10 )
60- nvim .funcs .cursor (3 , 22 )
56+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
57+ time .sleep (2 )
58+ nvim .funcs .cursor (10 , 16 )
6159 nvim .funcs .LanguageClient_textDocument_definition ()
6260 time .sleep (3 )
6361
64- assert nvim .current .window .cursor == [8 , 3 ]
62+ assert nvim .current .window .cursor == [13 , 5 ]
6563
6664
6765def test_textDocument_hover (nvim ):
68- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
66+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
6967 time .sleep (1 )
70- nvim .funcs .cursor (3 , 22 )
68+ nvim .funcs .cursor (10 , 16 )
7169 nvim .funcs .LanguageClient_textDocument_hover ()
7270 time .sleep (1 )
7371 buf = getLanguageClientBuffers (nvim )[0 ]
74- expect = "fn greet() -> i32 "
72+ expect = "func greet() int32 "
7573
7674 assert expect in "\n " .join (buf )
7775
7876
7977def test_textDocument_rename (nvim ):
80- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
78+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
8179 time .sleep (1 )
8280 expect = [line .replace ("greet" , "hello" ) for line in nvim .current .buffer ]
83- nvim .funcs .cursor (3 , 22 )
81+ nvim .funcs .cursor (10 , 16 )
8482 nvim .funcs .LanguageClient_textDocument_rename ({"newName" : "hello" })
8583 time .sleep (1 )
8684
8785 assert nvim .current .buffer [:] == expect
8886
89- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
87+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
9088
9189
9290def test_textDocument_rename_multiple_oneline (nvim ):
93- nvim .command ("edit! {}" .format (PATH_LIBS_RS ))
91+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
9492 time .sleep (1 )
95- expect = [line .replace ("a" , "x" ) for line in nvim .current .buffer ]
96- nvim .funcs .cursor (2 , 9 )
93+ expect = [line .replace ("someVar" , "newVarName" )
94+ for line in nvim .current .buffer ]
95+ nvim .funcs .cursor (18 , 2 )
9796 # TODO: Test case where new variable length is different.
98- nvim .funcs .LanguageClient_textDocument_rename ({"newName" : "x " })
99- time .sleep (3 )
97+ nvim .funcs .LanguageClient_textDocument_rename ({"newName" : "newVarName " })
98+ time .sleep (1 )
10099
101100 assert nvim .current .buffer [:] == expect
102101
103102 nvim .command ("bd!" )
104- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
103+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
105104
106105
107106def test_textDocument_rename_multiple_files (nvim ):
108- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
107+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
109108 time .sleep (1 )
110- nvim .funcs .cursor (17 , 5 )
111- expect = [line .replace ("yo " , "hello" ) for line in nvim .current .buffer ]
109+ nvim .funcs .cursor (21 , 15 )
110+ expect = [line .replace ("otherYo " , "hello" ) for line in nvim .current .buffer ]
112111 nvim .funcs .LanguageClient_textDocument_rename ({"newName" : "hello" })
113112 time .sleep (1 )
114113
115114 assert nvim .current .buffer [:] == expect
116115
117116 nvim .command ("bd!" )
118117 nvim .command ("bd!" )
119- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
118+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
120119
121120
122121def test_textDocument_documentSymbol (nvim ):
123- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
122+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
124123 time .sleep (1 )
125124 nvim .funcs .cursor (1 , 1 )
126125 nvim .funcs .LanguageClient_textDocument_documentSymbol ()
127126 time .sleep (1 )
128127
129128 assert nvim .funcs .getloclist (0 )
130129
131- nvim .command ("3lnext " )
130+ nvim .command ("1lnext " )
132131
133132 assert nvim .current .window .cursor != [1 , 1 ]
134133
135134
136135def test_workspace_symbol (nvim ):
137- nvim .command ("edit! {}" .format (PATH_LIBS_RS ))
136+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
138137 time .sleep (1 )
139138 nvim .funcs .cursor (1 , 1 )
140139 nvim .funcs .LanguageClient_workspace_symbol ()
141140 time .sleep (1 )
142141
143142 assert nvim .funcs .getloclist (0 )
144143
145- nvim .command ("1lnext " )
144+ nvim .command ("3lnext " )
146145
147- assert nvim .current .window .cursor == [8 , 0 ]
146+ assert nvim .current .window .cursor == [17 , 0 ]
148147
149148
150149def test_textDocument_references (nvim ):
151- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
150+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
152151 time .sleep (1 )
153- nvim .funcs .cursor (8 , 6 )
152+ nvim .funcs .cursor (13 , 6 )
154153 nvim .funcs .LanguageClient_textDocument_references ()
155- time .sleep (1 )
156- expect = ["fn greet() -> i32 {" , """println!("{}", greet());""" ]
154+ time .sleep (2 )
155+ expect = ["func greet() int32 {" , "log.Println(greet())" ,
156+ "log.Println(greet())" ]
157157
158158 assert [location ["text" ]
159159 for location in nvim .funcs .getloclist (0 )] == expect
160160
161161 nvim .command ("lnext" )
162162
163- assert nvim .current .window .cursor == [3 , 19 ]
163+ assert nvim .current .window .cursor == [10 , 13 ]
164164
165165
166166def test_textDocument_references_modified_buffer (nvim ):
167- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
167+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
168168 time .sleep (1 )
169- nvim .funcs .cursor (8 , 6 )
169+ nvim .funcs .cursor (13 , 6 )
170170 nvim .input ("iabc" )
171171 time .sleep (1 )
172172 nvim .funcs .LanguageClient_textDocument_references ()
173173 time .sleep (1 )
174174
175- assert nvim .current .window .cursor == [8 , 3 ]
175+ nvim .command ("lnext" )
176+
177+ # first call to greet in sample-go/other.go
178+ assert nvim .current .window .cursor == [6 , 13 ]
176179
177- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
180+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
178181
179182
180183def test_languageClient_registerServerCommands (nvim ):
181- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
184+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
182185 time .sleep (1 )
183186 nvim .command ('let g:responses = []' )
184187 nvim .command ("call LanguageClient_registerServerCommands("
@@ -188,7 +191,7 @@ def test_languageClient_registerServerCommands(nvim):
188191
189192
190193def test_languageClient_registerHandlers (nvim ):
191- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
194+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
192195 time .sleep (1 )
193196 nvim .command ('let g:responses = []' )
194197 nvim .command ("call LanguageClient_registerHandlers("
@@ -218,7 +221,7 @@ def test_languageClient_registerHandlers(nvim):
218221
219222
220223def _open_float_window (nvim ):
221- nvim .funcs .cursor (3 , 22 )
224+ nvim .funcs .cursor (10 , 15 )
222225 pos = nvim .funcs .getpos ('.' )
223226 nvim .funcs .LanguageClient_textDocument_hover ()
224227 time .sleep (1 )
@@ -229,7 +232,7 @@ def test_textDocument_hover_float_window_closed_on_cursor_moved(nvim):
229232 if not nvim .funcs .exists ("*nvim_open_win" ):
230233 pytest .skip ("Neovim 0.3.0 or earlier does not support floating window" )
231234
232- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
235+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
233236 time .sleep (1 )
234237
235238 buf = nvim .current .buffer
@@ -247,7 +250,7 @@ def test_textDocument_hover_float_window_closed_on_cursor_moved(nvim):
247250 assert pos == nvim .funcs .getpos ("." )
248251
249252 # Move cursor to left
250- nvim .funcs .cursor (13 , 17 )
253+ nvim .funcs .cursor (10 , 14 )
251254
252255 # Check float window buffer was closed by CursorMoved
253256 assert len (getLanguageClientBuffers (nvim )) == 0
@@ -257,7 +260,7 @@ def test_textDocument_hover_float_window_closed_on_entering_window(nvim):
257260 if not nvim .funcs .exists ("*nvim_open_win" ):
258261 pytest .skip ("Neovim 0.3.0 or earlier does not support floating window" )
259262
260- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
263+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
261264 time .sleep (1 )
262265
263266 win_id = nvim .funcs .win_getid ()
@@ -288,7 +291,7 @@ def test_textDocument_hover_float_window_closed_on_switching_to_buffer(nvim):
288291 another_bufnr = nvim .current .buffer .number
289292
290293 try :
291- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
294+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
292295 time .sleep (1 )
293296
294297 source_bufnr = nvim .current .buffer .number
@@ -315,7 +318,7 @@ def test_textDocument_hover_float_window_move_cursor_into_window(nvim):
315318 if not nvim .funcs .exists ("*nvim_open_win" ):
316319 pytest .skip ("Neovim 0.3.0 or earlier does not support floating window" )
317320
318- nvim .command ("edit! {}" .format (PATH_MAIN_RS ))
321+ nvim .command ("edit! {}" .format (PATH_MAIN_GO ))
319322 time .sleep (1 )
320323
321324 prev_bufnr = nvim .current .buffer .number
0 commit comments