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.

Revisions

  1. grepsuzette created this gist Feb 29, 2024.
    28 changes: 28 additions & 0 deletions GnoFileTest.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    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