Neovim/slime/tmux and bracketed-paste

Hi, I am just getting started in julia.
I usually avoid repl based settings, but I see that this doesn’t really work for julia.
My local laptop is really weak, so I usually jump trough three ssh connections and work on a remote server. That works great with neovim and I am generally quite happy with neovim, so I would not like to move to vscode, even though that seems to be the preferred julia solution.
Instead I was wondering if someone could help me to get my neovim setup working for julia?

Using slime and tmux, I can keep a julia repl running in one pane and just send things using vim-slime from another pane. It works for smaller testcases, and since following the python repl instructions by setting up bracketed-paste (see vim-slime/ftplugin/python at main · jpalardy/vim-slime · GitHub), it does work for smaller testsets, which include a few empty lines.
However, trying to run a larger testset does give me

ERROR: syntax: invalid iteration specification
Stacktrace:
 [1] top-level scope

I did look through a couple of seemingly related posts like here: Bracketed paste mode parsing issue in VSCode REPL · Issue #43201 · JuliaLang/julia · GitHub
I do feel like the julia repl has some logic to recognize copy&paste input and it seems to have a timer for receiving input, so the bracketed-paste end signal might take to long to arrive for larger testcases?

These are my julia plugins for neovim, I do use the default neovim lsp

    Plug 'JuliaEditorSupport/julia-vim'
    Plug 'jpalardy/vim-slime'
    Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}

I don’t use things like OhMyRepl.jl, and some quick test also didn’t seem to help,
but I am happy to change my julia setup if that helps.

Looking at the ~/.slime_paste buffer that holds the last send text it does indeed look like there is an issue with the block sending. The buffer file only contains the lower half of my testcase, so I assume it is sending my testset in multiple blocks? The julia repl still shows the whole testcase as one single block/command/history entry, but I guess the bracketed-paste special symbols get messed up?

Just for completeness, the testcase does work fine if I just run
julia --project dot.jl

~/.slime_paste
➜  Enzyme.jl git:(axpy) cat ~/.slime_paste 
            fdm, (x, y) -> fun(n, x, inc, y, inc), one(Float32), x, y
            )
            @show inc
            ret = autodiff(
                ReverseWithPrimal,
                fun,
                Tret,
                Const(n),
                x_annot,
                Const(inc),
                y_annot,
                Const(inc),
            )
            dval, val = ret

            @test all(isnothing, dval)
            @test val ≈ vexp
            @test ∂xcopy ≈ dexp[1] * !(Tx <: Const || Tret <: Const) + ∂x
            @test ∂ycopy ≈ dexp[2] * !(Ty <: Const || Tret <: Const) + ∂y
        end
    end
end%    
Full Testcase
julia> @testset "BLAS rules" begin                                                                                                                                                                                                                                                                                                                                                                                                      
           fdm = central_fdm(5, 1)                                                                                                                                                                                                                                                                                                                                                                                                      
           RTs = (Float32, Float64)  
           n = 10

           fun = BLAS.dot

           #Enzyme.API.print!(true)
           @testset "reverse" begin

               @testset for Tret in (Active,),
                   Tx in (Const,),
                   Ty in (Duplicated,),
                   pfun in (identity,),
                   #T in (Float32,),
                   (sz, inc) in ((10, 1), ((2, 20), -2)),

                   Tx <: Const && Ty <: Const && !(Tret <: Const) && continue

                   x, ∂x = ntuple(_ -> randn(Float32, sz), 2)
                   y, ∂y = ntuple(_ -> randn(Float32, sz), 2)
                   ∂z = randn(Float32)
                   xcopy, ycopy, ∂xcopy, ∂ycopy = map(copy, (x, y, ∂x, ∂y))

                   x_annot =
                       Tx <: Const ? Const(pfun(x)) : Duplicated(pfun(xcopy), pfun(∂xcopy))
                   y_annot =
                       Ty <: Const ? Const(pfun(y)) : Duplicated(pfun(ycopy), pfun(∂ycopy))

                   vexp = fun(n, x, inc, y, inc)
                   dexp = FiniteDifferences.j′vp(
                       fdm, (x, y) -> fun(n, x, inc, y, inc), one(Float32), x, y
                   )
                   @show inc
                   ret = autodiff(
                       ReverseWithPrimal,
                       fun,
                       Tret,
                       Const(n),
                       x_annot,
                       Const(inc),
                       y_annot,
                       Const(inc),
                   )
                   dval, val = ret

                   @test all(isnothing, dval)
                   @test val ≈ vexp
                   @test ∂xcopy ≈ dexp[1] * !(Tx <: Const || Tret <: Const) + ∂x
                   @test ∂ycopy ≈ dexp[2] * !(Ty <: Const || Tret <: Const) + ∂y
               end
           end
       end
ERROR: syntax: invalid iteration specification
Stacktrace:
 [1] top-level scope
   @ none:1


Well it turns out that while getting the small testcase fixed using the bracketed pasting mode I did modify the large testcase without noticing, so it was actually invalid julia at the end of the day. So I did fix the actual slime issue a long time ago without noticing. sigh

2 Likes