Last active
May 13, 2020 16:02
-
-
Save pfitzseb/37adca96a13c7097631c15e1af4b7409 to your computer and use it in GitHub Desktop.
open nvim when pressing enter on empty prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using REPL | |
using REPL: LineEdit | |
atreplinit() do repl | |
repl.interface = REPL.setup_interface(repl) | |
repl.interface.modes[1].on_enter = function (s) | |
mktemp() do path, io | |
input = chomp(String(take!(copy(LineEdit.buffer(s))))) | |
if isempty(input) | |
run(`nvim $(path)`) | |
sleep(0.1) | |
input = read(io, String) | |
write(LineEdit.buffer(s), chomp(input)) | |
end | |
ast = Base.parse_input_line(String(take!(copy(LineEdit.buffer(s)))), depwarn=false) | |
return !(isa(ast, Expr) && ast.head === :incomplete) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment