Skip to content

Commit

Permalink
Fix type completor section of README (#820)
Browse files Browse the repository at this point in the history
* Add missing table of content for type-based-completor

* Update how to enable TypeCompletor section

Add link to ruby/repl_type_completor
Add how to install, (gem install, Gemfile)
Add environment variable description

* Fix how to enable type completor description

Co-authored-by: Stan Lo <stan001212@gmail.com>

* Add `group: :test` to sample Gemfile description in README

---------

Co-authored-by: Stan Lo <stan001212@gmail.com>
  • Loading branch information
tompng and st0012 authored Dec 23, 2023
1 parent 2d5a1af commit c2f90c4
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ The `irb` command from your shell will start the interpreter.
- [Debugging with IRB](#debugging-with-irb)
- [More about `debug.gem`](#more-about-debuggem)
- [Advantages Over `debug.gem`'s Console](#advantages-over-debuggems-console)
- [Type Based Completion](#type-based-completion)
- [How to Enable IRB::TypeCompletor](#how-to-enable-irbtypecompletor)
- [Advantage over Default IRB::RegexpCompletor](#advantage-over-default-irbregexpcompletor)
- [Difference between Steep's Completion](#difference-between-steeps-completion)
- [Configuration](#configuration)
- [Environment Variables](#environment-variables)
- [Documentation](#documentation)
Expand Down Expand Up @@ -242,15 +246,33 @@ IRB's default completion `IRB::RegexpCompletor` uses Regexp. IRB has another exp

### How to Enable IRB::TypeCompletor

To enable IRB::TypeCompletor, run IRB with `--type-completor` option
Install [ruby/repl_type_completor](https://github.com/ruby/repl_type_completor/) with:
```
$ gem install repl_type_completor
```
Or add these lines to your project's Gemfile.
```ruby
gem 'irb'
gem 'repl_type_completor', group: [:development, :test]
```

Now you can use type based completion by:

Running IRB with the `--type-completor` option
```
$ irb --type-completor
```
Or write the code below to IRB's rc-file.

Or writing this line to IRB's rc-file (e.g. `~/.irbrc`)
```ruby
IRB.conf[:COMPLETOR] = :type # default is :regexp
```
You also need `gem repl_type_completor` to use this feature.

Or setting the environment variable `IRB_COMPLETOR`
```ruby
ENV['IRB_COMPLETOR'] = 'type'
IRB.start
```

To check if it's enabled, type `irb_info` into IRB and see the `Completion` section.
```
Expand Down

0 comments on commit c2f90c4

Please sign in to comment.