I broke up with neovim....vim is my best friend now

This commit is contained in:
LinlyBoi
2023-04-30 08:14:07 +03:00
parent 0d185449c5
commit 4a4a6b1e81
5245 changed files with 468325 additions and 25 deletions

View File

@@ -0,0 +1,4 @@
/deps/vim-lsp
/deps/ale
/lsp-log.txt
/integ_messages.txt

View File

@@ -0,0 +1,44 @@
call themis#option('exclude', 'test/README.md')
let s:dir = expand('<sfile>:p:h')
let s:sep = has('win32') ? '\' : '/'
let s:vim_lsp_dir = join([s:dir, 'deps', 'vim-lsp'], s:sep)
let s:ale_dir = join([s:dir, 'deps', 'ale'], s:sep)
if !isdirectory(s:vim_lsp_dir)
throw 'vim-lsp is not cloned at ' . s:vim_lsp_dir
endif
if !isdirectory(s:ale_dir)
throw 'ALE is not cloned at ' . s:ale_dir
endif
function! IntegTestRootDir() abort
return s:dir
endfunction
execute 'set rtp+=' . s:vim_lsp_dir
execute 'set rtp+=' . s:ale_dir
filetype plugin indent on
let g:lsp_log_file = 'lsp-log.txt'
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'rust-analyzer',
\ 'cmd': { server_info -> ['rust-analyzer'] },
\ 'allowlist': ['rust'],
\ })
let g:ale_linters = { 'rust': ['vim-lsp'] }
runtime plugin/lsp_ale.vim
runtime plugin/lsp.vim
runtime plugin/ale.vim
" This is called automatically at VimEnter, but our tests load vim-lsp
" after the event. So manually call it here
call lsp#enable()
let s:helper = themis#helper('assert')
call themis#helper('command').with(s:helper)
" vim: set ft=vim:

View File

@@ -0,0 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "project"
version = "0.1.0"

View File

@@ -0,0 +1,9 @@
[package]
name = "project"
version = "0.1.0"
authors = ["rhysd <lin90162@yahoo.co.jp>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@@ -0,0 +1,2 @@
/target
**/*.rs.bk

View File

@@ -0,0 +1,3 @@
pub fn do_something() {
let this_variable_is_unused = 42;
}

View File

@@ -0,0 +1,103 @@
let s:SEP = has('win32') ? '\' : '/'
function! s:get_debug_info(bufnr) abort
let uri = lsp#utils#get_buffer_uri(a:bufnr)
let all_diags = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(uri)
return "\nall diags: " . string(all_diags)
\ . "\nlocation list: " . string(ale#engine#GetLoclist(a:bufnr))
\ . "\nserver_status: " . lsp#get_server_status()
\ . "\ncurrent lines: " . string(getline(1, '$'))
endfunction
Describe rust-analyzer
Before all
if !executable('rust-analyzer')
throw 'rust-analyzer command is not found. It must be installed for running integration tests'
endif
let dir = IntegTestRootDir()
execute 'cd' dir
let file = join([dir, 'project', 'src', 'lib.rs'], s:SEP)
" Note: It might be better to write lib.rs here and delete in `After all` hook rather than
" modifying a file committed to repository directly.
let lib_rs_contents = readfile(file)
End
After all
" Restore contents of lib.rs since it was modified by test case
call writefile(lib_rs_contents, file)
redir! > integ_messages.txt
if exists(':LspStatus')
LspStatus
else
echom 'No :LspStatus command is defined'
endif
message
redir END
End
Before each
execute 'edit!' file
End
After each
bwipeout!
End
It shows diagnostics results with ALE through vim-lsp
Assert lsp#ale#enabled()
let bufnr = bufnr('')
let elapsed = 0 " in seconds
let timeout = 120 " in seconds
let counts = ale#statusline#Count(bufnr)
while elapsed <= timeout
if counts.total > 0
break
endif
sleep 1
let elapsed += 1
let counts = ale#statusline#Count(bufnr)
endwhile
let info = s:get_debug_info(bufnr)
Assert True(counts.total > 0, 'No error found after ' . elapsed . ' seconds' . info)
let loclist = ale#engine#GetLoclist(bufnr)
Assert NotEmpty(loclist, 'Location list from ALE is empty after ' . elapsed . ' seconds. ' . info)
let item = loclist[0]
let item_str = string(item)
Assert Equals(item.linter_name, 'vim-lsp', item_str . info)
Assert True(item.from_other_source, item_str . info)
Assert Match(item.filename, 'lib\.rs$', item_str . info)
Assert Match(item.text, 'this_variable_is_unused', item_str . info)
" Fix the problem
normal! ggjdd
write
let elapsed = 0 " in seconds
let counts = ale#statusline#Count(bufnr)
while elapsed <= timeout
if counts.total == 0
break
endif
sleep 1
let elapsed += 1
let counts = ale#statusline#Count(bufnr)
endwhile
let info = s:get_debug_info(bufnr)
Assert True(counts.total == 0, 'Error found after ' . elapsed . ' seconds' . info)
" Check the error was removed from location list since it'd been fixed
let loclist = ale#engine#GetLoclist(bufnr)
Assert Empty(loclist, 'Location list from ALE is not empty after ' . elapsed . ' seconds. ' . info)
End
End
" vim: set ft=vim: