-
Notifications
You must be signed in to change notification settings - Fork 145
VSCode Stubs Setup
This assumes you have the extension source code in it's own project directory and that you have configured SketchUp to load the extension directly from that location.
You will also need a standalone version of Ruby installed on your system.
For Windows the easiest way is to use the Ruby Windows Installer from rubyinstaller.org.
Mac comes with a version of Ruby installed, but it's usually an older version that require sudo
to install gems. To get an up to date version of Ruby running on mac use RVM.
Next we can set up Visual Studio Code.
Before continuing, make sure you have the following VSCode extension installed.
From the command line you need to install a couple of gems to your standalone installation of Ruby:
- Yard: github.com/lsegal/yard)
- Solargraph: github.com/castwide/solargraph)
- SketchUp Ruby API Stubs: github.com/SketchUp/ruby-api-stubs
gem install yard
gem install solargraph
gem install sketchup-api-stubs
yard gems sketchup-api-stubs
Start with opening the VSCode settings for your current project.
File » Settings (Ctrl+,)
(Make sure to select Workspace Settings)
Set solargraph.diagnostics
to true
:
.vscode/settings.json
{
"solargraph.diagnostics": true
}
Then create a .solargraph.yml
file in the root of your project:
.solargraph.yml
# To allow solargraph to resolve the require paths correctly, add the path
# to the Tools directory of one of your SketchUp installations.
# You also want to add the path to where you have the extension's sources.
# (In this example it would be in a `src` directory relative to .solargraph.yml)
require_paths:
- "C:/Program Files/SketchUp/SketchUp 2018/Tools"
- src
# This will load the stubs for the SketchUp API.
require:
- sketchup-api-stubs
# Exclude files that doesn't need to be parsed. Avoids noise and improve performance.
exclude:
- /build/**/*
- /ThirdParty/**/*
If everything is set up correctly then you should now get auto-complete assistance for the SketchUp Ruby API. Solargraph will use YARD comments to help infer the type of method arguments.