Skip to content

YARD docs for the Dragonruby API to allow code completion with solargraph LSP

License

Notifications You must be signed in to change notification settings

owenbutler/dragonruby-yard-doc

Repository files navigation

Dragonruby YARD Doc

This repository contains YARD documentation for the main Dragonruby APIs.

Used in conjunction with Solargraph as your LSP, you'll be able to get rich API autocomplete and type support for the Dragonruby APIs.

Examples

vim/neovim

alacritty_BG37G8KCEO.mp4

VSCode

Code.Ldvkejagpw-1.mp4

Prerequisites

  • A CRuby runtime
  • The solargraph gem
  • An editor that can be configured to use the Solargraph LSP:
    • Vim/neovim
    • VS-Code
    • Emacs
    • Zed
    • Sublime Text
    • etc.

Step by Step install

If you confidently work with Ruby, gems and solargraph then the TLDR is:

  • clone this repository to a convenient location
  • configure solargraph to include the checked out repository
include:
- "mygame/app/*.rb"
- "../dragonruby-yard-doc/*.rb"

If you'd like more detailed instructions, read on.

Clone this repository

Clone this repository to a directory that is a peer of your normal dragronruby projects.

For example, if your game project is located at ~/devel/games/myawesomegame, clone this repo to ~/devel/games/dragonruby-yard-doc

$ cd ~/devel/games/
$ git clone git@github.com:owenbutler/dragonruby-yard-doc.git

A CRuby runtime

Dragonruby itself does not require a ruby runtime to work. So, you might be wondering why we need another Ruby installed here? The answer is that the solargraph gem, which we will use as an LSP, does need a ruby runtime.

Windows

Download and run the latest ruby installer from rubyinstaller.org. Choose the one that includes the DevKit.

Or use your favorite package manager. For scoop, scoop install ruby, and follow it's instructions: scoop install msys2 and ridk install. This will start the cli version of the rubyinstaller. Choose the option to install msys2 with the mingw development toolchain.

Linux/Unix

Use the package management system of your distribution or third-party tools (asdf, rbenv or RVM).

MacOS

Use third-party tools (asdf, rbenv or RVM).

The solargraph gem

Once you have a ruby installed, install the solargraph gem:

$ gem install solargraph

Solargraph needs to be configured to include this repo. Create a solargraph config file inside your game directory:

$ cd ~/devel/games/myawesomegame
$ solargraph config

This creates a default .solargraph.yml file in the root of your project dir.

Edit the include section of the config file to include our checked out repo:

include:
- "mygame/app/*.rb"
- "../dragonruby-yard-doc/*.rb"

If you'd like to further configure solargraph, explore the config reference.

Configure your editor to use solargraph LSP

VSCode

VSCode supports running solargraph through an extension.

  • Open the extensions view
  • Search for Solargraph
  • Install the extension

Vim/Neovim

  • Install solargraph LSP via Mason

Emacs

...

Zed

...

Sublime Text

LSP for Sublime Text can be configured to run Solargraph.

  • Install the LSP package using the command palette (Tools > Command Palette):
    • Enter the command Package Control: Install Package
    • Choose the LSP package
  • Add Solargraph to the list of LSP clients in the package's settings (Settings > Package Settings > LSP > Settings):
{
  "clients": {
    "solargraph": {
      "enabled": true,
      "command": [
        "solargraph", "stdio"
      ],
      "selector": "source.ruby",
      "initializationOptions": {
        "diagnostics": true
      }
    }
  }
}

The LSP package supports automatic formatting but doesn't enable it by default. If you'd like to use it:

  • Open a .rb file
  • Open the syntax-specific settings (Settings > Settings - Syntax Specific)
  • Enable format on save:
{
  "lsp_format_on_save": true
}

About

YARD docs for the Dragonruby API to allow code completion with solargraph LSP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages