jpalardy / vim-slime

A vim plugin to give you some slime. (Emacs)
http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
MIT License
1.83k stars 223 forks source link

neovim target TermOpen autocmd interactions with other terminal buffers #420

Open jmbuhr opened 3 months ago

jmbuhr commented 3 months ago

Would you be open to making the creation of this autocommand optional? As it also triggers on other terminal buffers that are not intended as a repl, like e.g. the terminal buffers created by neotest (https://github.com/nvim-neotest/neotest) to run tests or the terminal to run the preview command for quarto-nvim (https://github.com/quarto-dev/quarto-nvim/).

https://github.com/jpalardy/vim-slime/blob/51aaece8f7858358ca365466dec96c53b479e77a/plugin/slime.vim#L43-L49

In the case of neotest, this then leads to

Error detected while processing TermOpen Autocommands for "*"..function slime#targets#neovim#SlimeAddChannel:
line    3:
E900: Invalid channel id

the first time a test is run.

slime#targets#neovim#SlimeAddChannel(expand('<abuf>')) could then be called manually on the creation of terminal intended for receiving code.

jmbuhr commented 3 months ago

Another potential solution is to check if a buffer is hidden in slime#targets#neovim#SlimeAddChannel before let jobid = getbufvar(buf_in, "&channel") and do nothing if this is the case. This prevents the error for plugins that create hidden terminals.

jpalardy commented 3 months ago

@jam1015 ^

jam1015 commented 3 months ago

commented on PR #421, recommending merge.

making this autocommand optional would require slightly in-depth changes. For now I recommend both g:slime_suggest_default = 0 and g:slime_menu_config = 0; that will remove the possibility of buffers that you don't want to send to's being suggested. working on a fix to SlimeClearChannel analogous to the PR.