<commit_before>"from https://github.com/jgdavey/tslime.vim

function! s:first_readable_file(files) abort
  let files = type(a:files) == type([]) ? copy(a:files) : split(a:files,"\n")
  for file in files
    if filereadable(rails#app().path(file))
      return file
    endif
  endfor
  return ''
endfunction

function! s:prefix_for_test(file)
  if a:file =~# '_spec.rb$'
    return "rspec "
  elseif a:file =~# '_test.rb$'
    return "ruby -Itest "
  endif
  return ''
endfunction

function! s:SendAlternateToTmux(suffix) abort
  let current_file = expand("%")
  let executable = ""
  if s:prefix_for_test(current_file) != ''
    let executable = s:prefix_for_test(current_file) . current_file . a:suffix
  elseif current_file =~# '.feature$'
    let executable = "cucumber " . current_file . a:suffix
  elseif exists('g:autoloaded_rails')
    let related_file = s:first_readable_file(rails#buffer().related())
    if related_file =~# '.rb$'
      let executable = s:prefix_for_test(related_file) . related_file
    endif
  endif
  if executable == ""
    let executable = "!!"
  endif
  return Send_to_Tmux("".executable."\n")
endfunction

nnoremap <leader>rt :w \| :call <SID>SendAlternateToTmux("")<CR>
nnoremap <leader>rl :w \| :call <SID>SendAlternateToTmux(":".line('.'))<CR><commit_msg>tslime by line number is only rspec, minitest + bacon where art thou?<commit_after>"from https://github.com/jgdavey/tslime.vim

function! s:first_readable_file(files) abort
  let files = type(a:files) == type([]) ? copy(a:files) : split(a:files,"\n")
  for file in files
    if filereadable(rails#app().path(file))
      return file
    endif
  endfor
  return ''
endfunction

function! s:prefix_for_test(file)
  if a:file =~# '_spec.rb$'
    return "rspec "
  elseif a:file =~# '_test.rb$'
    return exists('g:tslime_cmd') ? g:tslime_cmd . ' ' : "ruby -Itest "
  endif
  return ''
endfunction

function! s:SendAlternateToTmux(suffix) abort
  let current_file = expand("%")
  let executable = ""
  if s:prefix_for_test(current_file) != ''
    let executable = s:prefix_for_test(current_file) . current_file . a:suffix
  elseif current_file =~# '.feature$'
    let executable = "cucumber " . current_file . a:suffix
  elseif exists('g:autoloaded_rails')
    let related_file = s:first_readable_file(rails#buffer().related())
    if related_file =~# '.rb$'
      let executable = s:prefix_for_test(related_file) . related_file
    endif
  endif
  if executable == ""
    let executable = "!!"
  endif
  return Send_to_Tmux("".executable."\n")
endfunction

nnoremap <leader>rt :w \| :call <SID>SendAlternateToTmux("")<CR>
nnoremap <leader>rl :let g:tslime_cmd='rspec' \| :w \| :call <SID>SendAlternateToTmux(":".line('.'))<CR>
{'fraction_non_alphanumeric': 0.15053367684946634, 'fraction_numerical': 0.0, 'mean_word_length': 4.339882121807466, 'pattern_counts': {'":': 2, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5594339', 'n_tokens_mistral': 1030, 'n_tokens_neox': 974, 'n_words': 202}