Skip to content

Instantly share code, notes, and snippets.

@grepsuzette
Created February 29, 2024 11:07
Show Gist options
  • Save grepsuzette/66f5cfaccc1a919c67f52bd7b31a3b09 to your computer and use it in GitHub Desktop.
Save grepsuzette/66f5cfaccc1a919c67f52bd7b31a3b09 to your computer and use it in GitHub Desktop.
:GnoFileTest gno filetest command for vim
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