Skip to content
This repository has been archived by the owner on Jul 27, 2024. It is now read-only.

Commit

Permalink
Create troubleshooting doc, update contributing and readme with links
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmanzella committed Nov 10, 2022
1 parent 1116957 commit 0d968d8
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
82 changes: 82 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,84 @@ For your contribution to be accepted you will need to sign the [Shopify Contribu
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

## Run Language Server
If you're making changes to the language server and you want to debug, you can run the repo's version of `theme-check-language-server`.

### Setup

Before configuring your IDE, run the following commands in a terminal:

* Make sure you have a `$HOME/bin`
```bash
mkdir -p $HOME/bin
```
* Paste this script to create an executable wrapper in `$HOME/bin/theme-check-language-server` for language server
```bash
cat <<-'EOF' > $HOME/bin/theme-check-language-server
#!/usr/bin/env bash
cd "$HOME/src/github.com/Shopify/theme-check" &> /dev/null
chruby () {
source '/opt/dev/sh/chruby/chruby.sh'
chruby "$@"
}
export THEME_CHECK_DEBUG=true
export THEME_CHECK_DEBUG_LOG_FILE="/tmp/theme-check-debug.log"
touch "$THEME_CHECK_DEBUG_LOG_FILE"
chruby 2.7 &>/dev/null
gem env &>/dev/null
bin/theme-check-language-server
EOF
```
* Make the script executable
```bash
chmod u+x $HOME/bin/theme-check-language-server
```
#### Configure VS Code
* Install the [Shopify Liquid](https://github.com/shopify/theme-check-vscode) plugin
* Add the following to `settings.json`:
```json
"shopifyLiquid.formatterDevPreview": true,
"shopifyLiquid.languageServerPath": "/Users/<YOUR_USERNAME>/bin/theme-check-language-server",
```
#### Configure Vim
If you use `coc.nvim` as your completion engine, add this to your CocConfig:
```json
"languageserver": {
"theme-check": {
"command": "/Users/<YOUR_USERNAME>/bin/theme-check-language-server",
"trace.server": "verbose",
"filetypes": ["liquid", "liquid.html"],
"rootPatterns": [".theme-check.yml", "snippets/*"],
"settings": {
"themeCheck": {
"checkOnSave": true,
"checkOnEnter": true,
"checkOnChange": false
}
}
}
```
### Confirm Setup
* In another terminal from the root of theme check run `tail -f /tmp/theme-check-debug.log` to watch the server logs
* Restart your IDE, confirm the response for initialize in the logs is pointing to the language server in the `$HOME/bin` directory (the version will be different)
```json
"serverInfo": {
"name": "/Users/johndoe/bin/theme-check-language-server",
"version": "1.10.3"
}
```
## Running Tests
```
Expand Down Expand Up @@ -123,3 +201,7 @@ chrome /tmp/fg.svg
What you'll see is an interactive version of the following image:
![flamegraph](docs/flamegraph.svg)
## Troubleshooting
If you run into issues during development, see the [troubleshooting guide](/TROUBLESHOOTING)
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,7 @@ DeprecateLazysizes:
⚠️ **Note:** Quickfixes only work on a freshly checked file. If any of those configurations are turned off, you will need to rerun theme-check in order to apply quickfixes.

In VS Code, these can be set directly in your `settings.json`.

## Contributing

For guidance on contributing, refer to this [doc](/CONTRIBUTING)
50 changes: 50 additions & 0 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Troubleshooting

## Issues with Language Server

### Language server erroring out on startup

The following error can cause language server to crash:
```bash
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
/Users/johndoe/.gem/ruby/3.1.2/gems/bundler-2.2.22/lib/bundler/spec_set.rb:91:in `block in materialize': Could not find ruby-prof-0.18.0 in any of the sources (Bundler::GemNotFound)
```
Confirm the version of theme-check matches the version in the wrapper in `~/bin/theme-language-server`. If it doesn't match the ruby version, run the following from the theme-check directory:

```bash
chruby 3.1.2 #your `~/bin/theme-language-server` ruby version
bundle install
```

### Language server changes not propogating to your IDE

Look at logs for language server and check the response for initialize. If it looks like this, you're pointing to the Shopify CLI and not the language server in the repo:

```json
"serverInfo": {
"name": "/opt/homebrew/bin/shopify",
"version": "1.10.3"
}
```

Check the config for your IDE/completion engine and confirm the Shopify CLI path isn't present (this by default overrides theme-check pointing to the repo's language server). If you're using VS Code this would be in your `settings.json`.

The response for initialize should look like this:

```json
"serverInfo": {
"name": "/Users/johndoe/src/github.com/Shopify/theme-check/bin/theme-check-language-server",
"version": "1.10.3"
}
```

If this isn't an issue, confirm the theme check repo's version of ruby matches the ruby version of your theme. If it doesn't, from the theme-check repo run:
```bash
chruby 3.1.2 #your theme ruby version
bundle install
```

0 comments on commit 0d968d8

Please sign in to comment.