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

Error raised after trigger send if there is no neovim terminal opened #427

Closed jiz4oh closed 2 months ago

jiz4oh commented 2 months ago
image

reproduce steps:

  1. nvim test.coffee
  2. call :SlimeSendCurrentLine

only occured when exists the _EscapeText_{&filetype} function

jpalardy commented 2 months ago

cc @jam1015

jam1015 commented 2 months ago

I'm not able to reproduce this using a minimal config:

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable", -- latest stable release
    lazypath,
  })
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup(
  {
    {
      "jpalardy/vim-slime",
      init = function()
        vim.g.slime_target = "neovim"
        vim.g.slime_no_mappings = true
        vim.g.slime_input_pid = false
        vim.g.slime_suggest_default = true
        vim.g.slime_menu_config = false
      end
    },
  }

)

I run nvim --clean -u ./minimal.lua test.coffee and then :SlimeSendCurrentLine with no terminal open and just get the Terminal not found. warning message (I get it twice, this is a bug that will take some refactoring to fix, but that isn't relevant here). The text is successfully sent when I open a terminal.

Also tested on an example python file which also has an _EscapeText_python function and had no problems.

Maybe try adding your personal config piece by piece to the minimal config to see what causes the errors.

jiz4oh commented 2 months ago

Hi @jam1015, I think it's not able to reproduce due to the _EscapeText_{&filetype} is loaded by a ftplugin, and thefiletype is not set if you run nvim --clean -u ./minimal.lua test.coffee, so the reproduce steps with the minimal config is

  1. nvim --clean -u ./minimal.lua test.coffee
  2. :set ft=coffee
  3. :SlimeSendCurrentLine

and the reason is if the _EscapeText_{&filetype} return an array with more than one elememts, e.g. _EscapeText_coffee, the s:SlimeDispatch function will be executed multiple times. seems like the b:slime_config is removed by first time and the second and following executation will raise error

jam1015 commented 2 months ago

addressed by https://github.com/jpalardy/vim-slime/pull/428

jpalardy commented 2 months ago

@jiz4oh let us know if that works for you

jiz4oh commented 2 months ago

@jam1015 thanks for your quick response, it's ok now @jpalardy