OhMyREPL.jl
OhMyREPL.jl copied to clipboard
Typing closing bracket gives extra bracket when package loaded from startup file
Typing []
gives []]
This used to work.
Does this only happen if OhMyREPL is loaded at startup?
Yes it only happens if loaded at startup.
The problem is that Pkg overwrites our keybinding for ]
when the Pkg REPL loads (after OhMyREPL)...
I have the same issue. ~~The same behavior occurs with double quotes: typing ""
gives """
when loaded at startup. Same with curly braces.~~
I can only repro with []
.
My bad, nevermind.
Pretty hacky but for now I'm working around this by adding the following after using OhMyREPL
in my startup.jl
:
@async begin
# reinstall keybindings to work around https://github.com/KristofferC/OhMyREPL.jl/issues/166
sleep(1)
OhMyREPL.Prompt.insert_keybindings()
end
@ssfrr's solution no longer seems to work for me?
@ssfrr's solution seems to be working now, thanks! Maybe this should be added to the README?
This issue also affects vim-slime plug-in (to send block of code to julia REPL for evaluation). Without ssfrr's hack, an extra ']' is appended to any line of code that has a '[' upon vim-slime transfer. This causes arrays and list comprehension syntax to be corrupted by the appended bracket. But if ssfrr's hack is added to the startup.jl after OhMyREPL, the appended ']' no longer appears on vim-slime transfer to julia REPL.
# startup.jl
# to automate adding OhMyREPL package to REPL on startup
atreplinit() do repl
try
@eval using OhMyREPL
catch e
@warn "error while importing OhMyREPL" e
end
@async begin
# reinstall keybindings to work around https://github.com/KristofferC/OhMyREPL.jl/issues/166
sleep(1)
OhMyREPL.Prompt.insert_keybindings()
end
end
This issue also affects vim-slime plug-in (to send block of code to julia REPL for evaluation). Without ssfrr's hack, an extra ']' is appended to any line of code that has a '[' upon vim-slime transfer. This causes arrays and list comprehension syntax to be corrupted by the appended bracket. But if ssfrr's hack is added to the startup.jl after OhMyREPL, the appended ']' no longer appears on vim-slime transfer to julia REPL.
Do you use vim-slime with tmux? If so, I think it's because slime doesn't use bracketed paste by default. See https://github.com/jpalardy/vim-slime/pull/254 and #224.
@carlocab Am I correct in saying that your fix to this problem was reverted in vim-slime? I am using tmux + vim-slime and facing the same issue. Did you find a workaround?
It was reverted, yes. I haven't managed to look into a workaround -- I don't use vim-slime much lately, so the issue hasn't bothered me so much.
I think the idea would be to only selectively activate bracketed paste with tmux, but I'm not sure what the best way to do that is yet.
It doesn't only happen if in startup.jl for me. The bodge doesn't work for me.
While typing []
for me gives []
but any multiline copy-pasting involving [
will fail, ie
eqs = [D(x) ~ σ*(y-x),
D(y) ~ x*(ρ-z)-y,
D(z) ~ x*y - β*z]
gives
julia> eqs = [D(x) ~ σ*(y-x),]
1-element Vector{Equation}:
Differential(t)(x(t)) ~ σ*((y(t)) - (x(t)))
julia> D(y) ~ x*(ρ-z)-y,
D(z) ~ x*y - β*z]
ERROR: syntax: extra token "]" after end of expression
While typing [] for me gives [] but any multiline copy-pasting involving [ will fail, ie
This is (likely) an issue with Windows, you can turn off the bracket completion: https://kristofferc.github.io/OhMyREPL.jl/latest/features/bracket_complete/#Settings.
This is (likely) an issue with Windows, you can turn off the bracket completion: https://kristofferc.github.io/OhMyREPL.jl/latest/features/bracket_complete/#Settings.
No I am on macOS observing same behavior with ]
not closing. Using OhMyREPL.
The ssfrr hack above fixes the problem
The workaround above again no longer works for me. macOS, iTerm2, Julia 1.8.1. My startup.jl
contains:
atreplinit() do repl
try
@info "importing OhMyREPL (incl. fzf)"
@eval using OhMyREPL
@async begin
# reinstall keybindings to work around https://github.com/KristofferC/OhMyREPL.jl/issues/166
sleep(1)
OhMyREPL.Prompt.insert_keybindings()
OhMyREPL.enable_autocomplete_brackets(false)
end
catch e
@error "error while importing OhMyREPL" e
end
end
Is there any chance of disabling bracket autocompletion by default?
@dpo I have the same system configuration, but my startup is doing:
using OhMyREPL
@async begin
# reinstall keybindings to work around https://github.com/KristofferC/OhMyREPL.jl/issues/166
sleep(1)
OhMyREPL.Prompt.insert_keybindings()
end
This doesn't include graceful failure or logging (I have to pass --startup-file=no
if I use an environment without OhMyREPL or deal with the error), but it seems to be working for me.
@iamed2 Thank you for the response.
I thought the atreplinit() ...
bit was necessary. I got it from the docs. I hadn't noticed before that the @async
bit was outside the try ... catch
. I tried moving mine out, but the problem persists.
I have OhMyREPL in my global environment. Indeed, removing atreplinit() ...
works. So I'm now even more confused. However, if I also have an atreplinit()
bit where I import other packages, the dreaded bracket autocompletion returns.
My config works fine with Julia 1.7. It's with Julia 1.8 that it seems to break.
I can just confirm that enable_autocomplete_brackets(false)
has no effect / errors inside the async
block in startup.jl
.
However, insert_keybindings does not seem to be necessary anymore to avoid the ]]
.
Currently on julia 1.8.3
I have in my startup.jl
try
println("Starting OhMyREPL...")
using OhMyREPL
catch e
@warn "Error initializing OhMyREPL" exception=(e, catch_backtrace())
end
@async begin
while !isdefined(Base, :active_repl) sleep(0.1) end
OhMyREPL.Prompt.insert_keybindings()
end
and it currently works, I switched to a sleeping while loop waiting to have a handle for the active repl, instead of just sleep(1)
which seemd a bit too arbitrary for my tastes.
@ghyatzo I tried with and without OhMyREPL.enable_autocomplete_brackets(false)
inside your @async
block, but neither works for me.
Should this issue be closed by https://github.com/KristofferC/OhMyREPL.jl/pull/297 ?