Отправка визуального выбора на неовим терминал - PullRequest
0 голосов
/ 26 ноября 2018

Я адаптировал следующий код, который должен отправлять визуальный выбор на мой терминал Neovim.

function! REPLSend(lines)
  echo a:lines
  " call jobsend(g:last_terminal_job_id, add(a:lines, ''))
  " call chansend(g:last_terminal_job_id, add(a:lines, ''))
  call chansend(g:last_terminal_job_id, a:lines)
endfunction

command! REPLSendLine call REPLSend([Get_visual_selection()])
" command! REPLSendLine call Get_visual_selection()

nnoremap <silent> <f6> :REPLSendLine<cr>

function! Get_visual_selection()
    " Why is this not a built-in Vim script function?!
    let [line_start, column_start] = getpos("'<")[1:2]
    let [line_end, column_end] = getpos("'>")[1:2]
    let lines = getline(line_start, line_end)
    if len(lines) == 0
        return ''
    endif
    let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)]
    let lines[0] = lines[0][column_start - 1:]
    let lines = insert(lines, "%cpaste")
    return join(lines, "\n")
  endfunction

Когда я вызываю код с помощью f6, Get_visual_selection правильно получает выбранный текст, но REPLSend(линии) функция не вызывается.Что я делаю не так?

...