Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have _good_ tab completions in Clojure REPL?

Good tab completions means dynamically generated using reflection or whatever (that does not require pre-defined list of completions somewhere) and that knows what can and what can't follow in particular place.

Like in (.<TAB> x) I'll get list of methods of x, in (println <TAB>) I get list of local and global definitions, in (Math/<TAB> I get the list of math functions...

For example I like how Tab works in ghci (Haskell) or ipython.

like image 257
Vi. Avatar asked Aug 08 '12 23:08

Vi.


3 Answers

Have a look at reply for a better REPL than the default one. It covers two out of three use cases you mention, leaving the Java instance method completion out.

If you use leiningen v2+ it's the default REPL invoked by the lein repl command.

like image 169
skuro Avatar answered Nov 12 '22 17:11

skuro


It is certainly possible and several of the tools are evolving in that direction. The newest version of clojure includes a "development mode" option that makes building this sort of tool easier; for instance it turns off local clearing to aid in debugging and the intention is for it to be able to eventually export a lot more information about the compilation process for use by IDEs and related tools. This is widely recognized as an area to improve the Clojure ecosystem and from my observations several very smart people are working on it.

like image 39
Arthur Ulfeldt Avatar answered Nov 12 '22 18:11

Arthur Ulfeldt


The current beta version of the Eclipse CounterClockwise REPL has greatly improved code completion, and covers all your cases, including Java completion. Except of course not being a standalone commandline REPL. Clojure being a dynamic language however has it's limitations on completions on type, something that's a lot easier in strongly typed languages like Haskell.

like image 39
NielsK Avatar answered Nov 12 '22 17:11

NielsK