Closed saccarosium closed 2 years ago
@saccarosium it sounds like something is configured incorrectly on your side or there is an issue with how you are using TermExec
I just tested TermExec cmd=ls
and this works fine. A user should not have to manually add an enter character.
I'm using it in a command
@saccarosium can you please provide an exact example of what is not working, I can't help based on just a description. It would be best see actual non-functional code
@saccarosium can you please provide an exact example of what is not working, I can't help based on just a description. It would be best see actual non-functional code
Sorry, I wasn't at my computer.
Basically, I want to create a command, called Repl
, that if it is called without any arguments gives me a terminal in a horizontal split, else it opens a split and try to run the argument.
the function
function M.repl(cmd)
if vim.fn.empty(cmd) == 1 then
vim.api.nvim_command("ToggleTerm size=20 direction=horizontal")
else
vim.api.nvim_command("TermExec size=20 cmd='" .. cmd .. "' direction=horizontal")
end
end
the command
command! -nargs=* Repl lua require("sacca.toggleterm").repl(<f-args>)
@saccarosium you should use the Lua API instead to programmatically trigger term exec i.e. require('toggleterm').exec(cmd)
if you read the README or docs this explained there
@akinsho I have tried what you suggest, and gives me the same problem. I also tried to run it manually from vim's command line and with this example command that you gave in the docs: command! -count=1 TermGitPushF lua require'toggleterm'.exec("git push -f", <count>, 12)
.
I don't really know what the issue is… I have also tried in other terminals, but doesn't seem to help.
Some info about my setup:
NVIM v0.7.2
@saccarosium command! -count=1 TermGitPushF lua require'toggleterm'.exec("git push -f", <count>, 12)
defines a command, it doesn't execute one. I genuinely don't know what you are specifically doing that isn't working. This works perfectly fine for me locally. Can you please make sure there are no issues in your shell
I think is a problem with my setup.
I close the issue.
Thanks for you help👍.
Hello @saccarosium,
I currently encounter the same issue, how did you manage to make it work ? What was messing with the plugin in your setup ?
Nope, I didn't really found a solution. I simply stopped to use the plugin.
Ok, I found the issue for me. If you are interested:
bind \n backward-word
in fish config which obviously breaks the carriage return for plugins like toggleterm.This is not an issue related to this plugin.
Hello @saccarosium,
I currently encounter the same issue, how did you manage to make it work ? What was messing with the plugin in your setup ?
I guess the problem has something to do with windows. At first, I made the enter key work, but it had to stay on terminal window, because when I used vim.api.nvim_set_current_win(main_win) the enter didn't work. There is a hack I copied from iron.nvim that solved my problem which is to use vim.defer_fn. Here is an example in my code:
local IPYTHON_TERMINAL_WINDOW = 3
toggleterm.send_lines_to_terminal("visual_lines", false, { args = IPYTHON_TERMINAL_WINDOW })
ipython_terminal = require("toggleterm.terminal").get(IPYTHON_TERMINAL_WINDOW)
ipython_terminal:focus()
local job_id = ipython_terminal.job_id
local enter_in_string = string.char(13)
vim.defer_fn(function()
vim.fn.chansend(job_id, enter_in_string)
end, 150)
Hi, Every time I try to execute a command with
TermExec
the program is not executed. I don't know if it is intentional or not, but if you happen to know how to send enter with the command, would be very appreciated.