Created
February 29, 2024 11:07
-
-
Save grepsuzette/66f5cfaccc1a919c67f52bd7b31a3b09 to your computer and use it in GitHub Desktop.
:GnoFileTest gno filetest command for vim
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
command! -nargs=0 GnoFileTest call GnoFileTest() | |
" place yourself in a xxxxx_filetest.gno | |
" type `:GnoFileTest`. | |
" It will | |
" - get rid of the previous lines following 'Error: ', | |
" - run `gno test .` for you | |
" - refresh the filetest automatically | |
" (so you see the errors, or absence of it | |
" without opening a terminal). | |
" | |
function! GnoFileTest() | |
if !expand('%:t') =~ '_filetest.gno$' | |
echo "Error: File does not end with _filetest.gno" | |
else | |
call cursor(1, 1) | |
let lnum = search('Error:', 'ne', line('$')) | |
if lnum == 0 | |
echo "Not found in the file: 'Error: '." | |
else | |
setlocal autoread | |
silent execute lnum+1 . ',$delete' | |
write | |
silent !gno test . | |
redraw! | |
endif | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment