-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a simple rust language server test
- Loading branch information
Showing
3 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
vim9script | ||
# Unit tests for LSP rust-analyzer client | ||
|
||
source common.vim | ||
source term_util.vim | ||
source screendump.vim | ||
|
||
var lspServers = [{ | ||
filetype: ['rust'], | ||
path: exepath('rust-analyzer'), | ||
args: [] | ||
}] | ||
call LspAddServer(lspServers) | ||
echomsg systemlist($'{lspServers[0].path} --version') | ||
|
||
def g:Test_LspGotoDef() | ||
settagstack(0, {items: []}) | ||
:cd xrust_tests/src | ||
try | ||
silent! edit ./main.rs | ||
sleep 600m | ||
var lines: list<string> =<< trim END | ||
fn foo() { | ||
} | ||
fn bar() { | ||
foo(); | ||
} | ||
END | ||
append('$', lines) | ||
g:WaitForServerFileLoad(0) | ||
cursor(7, 5) | ||
:LspGotoDefinition | ||
assert_equal([4, 4], [line('.'), col('.')]) | ||
:%bw! | ||
finally | ||
:cd ../.. | ||
endtry | ||
enddef | ||
|
||
def g:Test_ZZZ_Cleanup() | ||
delete('./xrust_tests', 'rf') | ||
enddef | ||
|
||
# Start the rust-analyzer language server. Returns true on success and false | ||
# on failure. | ||
def g:StartLangServer(): bool | ||
system('cargo new xrust_tests') | ||
:cd xrust_tests/src | ||
var status = false | ||
try | ||
status = g:StartLangServerWithFile('./main.rs') | ||
finally | ||
:cd ../.. | ||
endtry | ||
return status | ||
enddef | ||
|
||
# vim: shiftwidth=2 softtabstop=2 noexpandtab |