Skip to content

Instantly share code, notes, and snippets.

@pfitzseb
Last active May 13, 2020 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfitzseb/37adca96a13c7097631c15e1af4b7409 to your computer and use it in GitHub Desktop.
Save pfitzseb/37adca96a13c7097631c15e1af4b7409 to your computer and use it in GitHub Desktop.
open nvim when pressing enter on empty prompt
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