1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-12 17:52:50 +08:00

Add stdin support for python (#2536)

* Add stdin support for python

* Remove extra line break in stdout
This commit is contained in:
Wang Shidong 2019-02-01 20:39:07 +08:00 committed by GitHub
parent 294f723469
commit 8391fa1fa8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -53,7 +53,8 @@ function! SpaceVim#layers#lang#python#config() abort
call SpaceVim#plugins#runner#reg_runner('python', call SpaceVim#plugins#runner#reg_runner('python',
\ { \ {
\ 'exe' : function('s:getexe'), \ 'exe' : function('s:getexe'),
\ 'opt' : [], \ 'opt' : ['-'],
\ 'usestdin' : 1,
\ }) \ })
call SpaceVim#mapping#gd#add('python', function('s:go_to_def')) call SpaceVim#mapping#gd#add('python', function('s:go_to_def'))
call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings')) call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings'))

View File

@ -156,6 +156,7 @@ endfunction
" @vimlint(EVL103, 1, a:data) " @vimlint(EVL103, 1, a:data)
" @vimlint(EVL103, 1, a:event) " @vimlint(EVL103, 1, a:event)
if has('nvim') && exists('*chanclose') if has('nvim') && exists('*chanclose')
" remoet at the end of each
let s:_out_data = [''] let s:_out_data = ['']
function! s:on_stdout(job_id, data, event) abort function! s:on_stdout(job_id, data, event) abort
let s:_out_data[-1] .= a:data[0] let s:_out_data[-1] .= a:data[0]
@ -167,6 +168,7 @@ if has('nvim') && exists('*chanclose')
let lines = s:_out_data let lines = s:_out_data
endif endif
if !empty(lines) if !empty(lines)
let lines = map(lines, "substitute(v:val, ' $', '', 'g')")
call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines) call s:BUFFER.buf_set_lines(s:bufnr, s:lines , s:lines + 1, 0, lines)
endif endif
let s:lines += len(lines) let s:lines += len(lines)