From 8391fa1fa8e0e58f92021388f92c46ee653e4f98 Mon Sep 17 00:00:00 2001 From: Wang Shidong Date: Fri, 1 Feb 2019 20:39:07 +0800 Subject: [PATCH] Add stdin support for python (#2536) * Add stdin support for python * Remove extra line break in stdout --- autoload/SpaceVim/layers/lang/python.vim | 3 ++- autoload/SpaceVim/plugins/runner.vim | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/autoload/SpaceVim/layers/lang/python.vim b/autoload/SpaceVim/layers/lang/python.vim index c04f8c155..e70982df4 100644 --- a/autoload/SpaceVim/layers/lang/python.vim +++ b/autoload/SpaceVim/layers/lang/python.vim @@ -53,7 +53,8 @@ function! SpaceVim#layers#lang#python#config() abort call SpaceVim#plugins#runner#reg_runner('python', \ { \ 'exe' : function('s:getexe'), - \ 'opt' : [], + \ 'opt' : ['-'], + \ 'usestdin' : 1, \ }) call SpaceVim#mapping#gd#add('python', function('s:go_to_def')) call SpaceVim#mapping#space#regesit_lang_mappings('python', function('s:language_specified_mappings')) diff --git a/autoload/SpaceVim/plugins/runner.vim b/autoload/SpaceVim/plugins/runner.vim index 428ce335b..15a3bb06b 100644 --- a/autoload/SpaceVim/plugins/runner.vim +++ b/autoload/SpaceVim/plugins/runner.vim @@ -156,6 +156,7 @@ endfunction " @vimlint(EVL103, 1, a:data) " @vimlint(EVL103, 1, a:event) if has('nvim') && exists('*chanclose') + " remoet at the end of each let s:_out_data = [''] function! s:on_stdout(job_id, data, event) abort let s:_out_data[-1] .= a:data[0] @@ -167,6 +168,7 @@ if has('nvim') && exists('*chanclose') let lines = s:_out_data endif 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) endif let s:lines += len(lines)