An open API service indexing awesome lists of open source software.

https://github.com/tomoasleep/yoda

Experimental: Static Analyzer and Language Server for Ruby
https://github.com/tomoasleep/yoda

autocompletion language-server ruby yard

Last synced: 3 months ago
JSON representation

Experimental: Static Analyzer and Language Server for Ruby

Awesome Lists containing this project

README

          

# Yoda [![Test](https://github.com/tomoasleep/yoda/actions/workflows/test.yml/badge.svg)](https://github.com/tomoasleep/yoda/actions/workflows/test.yml)

Yoda is a Language Server (http://langserver.org/) for Ruby.
Yoda infers signatures of your Ruby program and its dependencies from various data sources (RBS and YARD documentation) and provides autocompletion and code analysis (go-to-definition, code information, etc...).

**Note: Yoda is alpha version. Please use with caution. Contributions are welcome!**

## Supporting Features

Yoda provides these features by analyzing Ruby code and its dependencies in Gemfile.lock with YARD.

* Code completion (method, constant, variables, etc...)
* Comment completion (YARD tag, types)
* Hover code information (method, constant, etc...)
* Go to definition (method, constant, require file, etc...)

![](https://github.com/tomoasleep/yoda/blob/master/images/method-complete.png)

![](https://github.com/tomoasleep/yoda/blob/master/images/hover-method.png)

## Install VSCode Extension (Recommended)

Yoda can be available as VSCode extension at: https://marketplace.visualstudio.com/items?itemName=tomoasleep.yoda
On launch of VSCode, Yoda will be installed automatically.

## Other installation methods

### Install language server gem

Yoda is hosted on RubyGems.

```
gem install yoda-language-server
```

See `Instation of Editor Plugin` section to install Yoda on your editor.

Yoda can be also used as a cli tool.

```
$ yoda setup # You must run this command first for your each project.
$ yoda infer path-to-your-code:line_num:char_num # Show information of the code at the specified position.
$ yoda complete :: # Show completion at the specified position.
```

### Install Editor Plugin

#### Atom

```
apm install tomoasleep/yoda
```

#### VSCode (from source code)

```
rake vscode:install
```

#### Vim/NeoVim

Please use language server client such as [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim).
Here is a configuration example for LanguageClient-neovim.

```vim
let g:LanguageClient_serverCommands = {
\ 'ruby': ['yoda', 'server'],
\ }
```

#### Emacs

TBW

## Internal

### YARD utilization

Yoda figures structures of your source codes and library codes with YARD.
Yoda intepret YARD tags such as `@return` tags and `@param` tags and infer code types from these information.

### Indexing

Yoda built index files for fast inference under `/.yoda` at startup.
These index files contains structures of external sources (gems and standard libraries).
Your project codes are parsed at startup but does not stored in indexes.

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/tomoasleep/yoda.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).