The extension exposes two commands via the VSCode Command Palette to view logs:
Ruby: Show Output Channel
- opens output channel for the Ruby extensionRuby: Show Language Server Output Channel
- opens output channel for the language server
VSCode relies on static language grammars to facilitate syntax highlighting. These grammars are stored in the syntaxes
directory in the root of the project.
VSCode has good documentation on how grammars work and how to troubleshoot grammars available here.
If you believe the extension is incorrectly assigning TextMate Scopes, please fix the grammar and open a PR!
Please read over the documentation on Environment Detection in the language server to ensure you understand its features and limitations.
The language server will log all commands it attempts to run as well as any errors that command generates. Each type of command is prefixed with it's type (eg Lint
or Format
). All commands are run with a cwd
of the currently open document. This is important if you attempt to run the command in your own shell.
Note: running commands from the directory of the open document, as opposed to the workspace root, is intentional. This allows people to put multiple linter configuration files in the project. We expect linters to look recursively up the directory tree to find their configuration file.
The one thing to keep in mind is that all of those commands are configured to accept editor content via stdin
and cannot be run verbatim in your terminal.
For example, if you see the following in the logs:
Lint: executing rubocop -s /Users/wingrunr21/someproject/subdir/rubyfile.rb -f json...
That is the language server running rubocop against rubyfile.rb
.
If you'd like to run that command yourself, you can do something similar to the following:
$ cd /Users/wingrunr21/someproject/subdir
$ cat rubyfile.rb | rubocop -s /Users/wingrunr21/someproject/subdir/rubyfile.rb -f json
The file must be piped into rubocop
or other utilities. This methodology is the best representation of how the language server runs these commands. If the command succeeds here but not in the language server, additional steps will be necessary to troubleshoot. Please open an issue.
The legacy lint and formatters do not attempt to detect your Ruby environment. This means that VSCode must be started with the appropriate environment set for it to be able to successfully run your lint and format commands. The easiest way to do this is via your terminal:
$ cd /path/to/my/project
$ rvm/chruby/rbenv/whatever if necessary
$ code .
By doing this, your terminal has configured the environment correct and VSCode will inherit that environment when it starts.