kassio / neoterm

Wrapper of some vim/neovim's :terminal functions.
Other
1.32k stars 117 forks source link

Using termopen #12

Closed ianks closed 9 years ago

ianks commented 9 years ago

I have noticed in neoterm that all commands when they are first run initiate a new shell then send the command text to the shell. This leaves extra output in the shell, and spawns an unneccesary process which you also have to quit when finished.

Do you this it would be possible to use termopen() with the command instead? This would avoid starting a shell everytime, and is a rather clean way of doing things IMO.

Here is how I am currently accomplishing what I am referring to.

autocmd FileType python
      \ let b:termy = executable('ipython') ? 'ipython -i %' : 'python -i %'
autocmd FileType ruby
      \ let b:termy = executable('pry') ? 'pry -r %:p' : 'irb -r %:p"'
autocmd FileType scala
      \ let b:termy = 'sbt console'
autocmd FileType javascript
      \ let b:termy = 'node'

function! Termy(cmd)
  let command = substitute(command, '%', expand('%:p'), 'g')
  :vnew | call termopen(command) | startinsert
endfunction
kassio commented 9 years ago

I tried this. But the termopen() does not keep the term buffer opened, it's killed after each command. I'd prefer to keep the terminal opened, this way I can just keep sending other commands.

ianks commented 9 years ago

Why not just open a new terminal? Or, if you really want to be able to keep the terminal open, make the reply command configurable and then you can have your own mapping to run your shell then execute you command. So instead your REPL mapping would be like 'let b:neoterm_repl = zsh -e "irb"'. This way you don't force your users to run a shell.

ianks commented 9 years ago

I realize the tone of that did not sound too polite after reading it again. It was meant to offer another way of thinking out the issue and was not at all supposed to be critical. Just thought I would clarify that. My main point was that there are ways to accomplish both of our goals in a clean, customizable way.

kassio commented 9 years ago

Sorry about the delay. So, My initial idea was to keep a terminal open, so if I wanted to write something on the terminal manually it'd be possible.