erg-lang / erg

A statically typed language compatible with Python
http://erg-lang.org
Apache License 2.0
2.7k stars 55 forks source link

Input completion in REPL #493

Open mtshiba opened 8 months ago

mtshiba commented 8 months ago

Improving the usability of the REPL is an important task. IRB (interactive ruby) etc. have implemented a feature that completes REPL input in real time, and I think Erg can do the same thing.

スクリーンショット 2024-03-18 22 01 42

Erg already has a Language Server, so the REPL can act like a language client. Alternatively, REPL can directly access the ELS API to obtain the input completion list without implementing LSP. After that, I think we will need to implement a feature that monitors console input in real time and refreshes the screen every time the completion list is updated. I think it can be implemented using a TUI library (e.g. https://github.com/ratatui-org/ratatui) or it may be possible to implement it with crossterm, which is already a dependency of Erg.