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

Issue to send multiple lines with recent versions of vim-slime #429

Closed ismael-lajaaiti closed 2 months ago

ismael-lajaaiti commented 2 months ago

Hello, I encountered an error when sending multiple lines with the recent version of vim-slime. I use vim slime with tmux on MacOS (Sonoma v14.4.1), generally to send chunks of Julia or R code.

The Issue

For instance, if I try to send the following paragraph with SlimeSendParagraph

a = 1
b = 2

Here is what happens in the Julia terminal

ERROR: ParseError:
# Error @ REPL[2]:1:6
a = 1b = 2
#    └ ── unknown unicode character '\0'
Stacktrace:
 [1] top-level scope

I get a similar error while sending the same code in an R terminal.

After some time trying to find the source of the issue, I found out that reverting to an older version of vim-slime (e.g., commit 150ab45) solved the issue. So I assume that this is due to a recent breaking change in vim-slime, but I wouldn't able to point which one.

My vim-slime configuration (LazyVim)

Here is my configuration, let me know if you need any other information.

return {
    {
        "jpalardy/vim-slime",
--        commit = "150ab45",
        keys = {
            { "<leader>sc", "<cmd>SlimeConfig<cr>",            desc = "Configure Slime" },
            { "<leader>sp", "<Plug>SlimeParagraphSend<cr>))",  desc = "Send paragraph and move" },
            { "<leader>sP", "<Plug>SlimeParagraphSend<cr>k",   desc = "Send paragraph" },
            { "<leader>sl", "<Plug>SlimeLineSend<cr>",         desc = "Send line and move" },
            { "<leader>sL", "<Plug>SlimeLineSend<cr>k",        desc = "Send line" },
            { "<leader>sr", "<Plug>SlimeRegionSend<cr>k",      mode = { "v" },                  desc = "Send region visually selected." },
            { "<leader>sa", "ggVG<Plug>SlimeRegionSend<cr>gg", desc = "Send all buffer." },
        },
        config = function()
            -- vim.keymap.set("v", "<leader>sr", "<Plug>SlimeRegionSend")
            vim.g.slime_target = "tmux"
            vim.g.slime_default_config = {
                socket_name = vim.api.nvim_eval('get(split($TMUX, ","), 0)'),
                target_pane = '{bottom-right}',
            }
            vim.g.slime_dont_ask_default = 1
            vim.g.slime_bracketed_paste = 1
        end,
    },
}
ppalmes commented 2 months ago

I have the same problem using vundle. i had to git pull manually and revert to old commit because recent commits from March causes issue with newline. it is not easy to identify that the recent changes caused it because it behaves differently with different file extensions. in those with sh extension, it adds "^@" at the end of each line. for region send, it concatenates multiple line. just really buggy and never had an issue with this. i'm using vim in mac. it seems that the changes are not well tested. can you at least create a testing branch instead of making changes direct to the main branch?

jam1015 commented 2 months ago

The commit that causes this bug is this one: https://github.com/jpalardy/vim-slime/commit/9a283f2057656f318e0ec6d66a1bce1e8da5e8f6

Looking for a way to fix it.

jpalardy commented 2 months ago

confirmed ^

I'll revert the commit if I don't find a quick fix

jpalardy commented 2 months ago

how about this? be64ea6f29754b321b9fa1f1d724b0010d959979

ismael-lajaaiti commented 2 months ago

Seems to work well again on my side, thank you 🙏

ppalmes commented 2 months ago

yeah, it works now. thanks!

jpalardy commented 2 months ago

sorry for the inconvenience — and thanks for reporting 👍