numToStr / FTerm.nvim

:fire: No-nonsense floating terminal plugin for neovim :fire:
MIT License
743 stars 23 forks source link

Behavior similar to the integrated terminal #18

Closed CRAG666 closed 3 years ago

CRAG666 commented 3 years ago

I am creating a code runner like the one in vscode, but when executing the terminal it is immediately sawed and does not show the output. Attached how I would like it to behave, it is the output in the default terminal of neovim. neovim term

numToStr commented 3 years ago

Yes, that's expected behavior in FTerm. That's because of this line https://github.com/numToStr/FTerm.nvim/blob/94e767f2f0fdd436c8aceadeae4d3e23166ee1f8/lua/FTerm/terminal.lua#L148

It closes the terminal buffer when the terminal itself exits.

bigjazzsound commented 3 years ago

Are there any plans to add this feature? I would love to be able to use a keymap to run a command and then bring up the terminal when it is done.

numToStr commented 3 years ago

@bigjazzsound Is #27 what you want? If not, could you explain your requirement?

jonathf commented 3 years ago

I guess @bigjazzsound's idea is that after an process is exited, the buffer does not automatically close before a key is pressed. This option gives the user the possibility to re-enter a hidden and terminated buffer to see output and exit code before allowing the buffer to die as well. Correct me if this interpretation is incorrect.

@numToStr, how about adding a setup parameter like close_on_kill = true and adding a conditional guard around your TermClose auto command to allow the users to choose to have it or not?

numToStr commented 3 years ago

@jonathf Yeah, something like close_on_kill = true is also on my mind but I didn't see much interest in this feature so I never implemented that.

I guess if you both @jonathf @bigjazzsound are interested in this then I'll implement that :)

numToStr commented 3 years ago

I have implemented close_on_kill as said. Please test it let me know if you have any suggestions :)

bigjazzsound commented 3 years ago

I tried this out and my terminal closes after the command completes.

local term = require "FTerm.terminal"

local tf = term:new():setup {
  cmd = "terraform plan",
  close_on_kill = false,
}

function _G.__tf()
  tf:toggle()
end

When I run :lua __tf(), the terminal pops up, but has no content except for the cursor, then closes after a few seconds.

jonathf commented 3 years ago

I don't use terraform, but tried it out with just ls and it worked just fine for me. I also tried with = true, and as expected it dies instantly.