Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruby Sorbet #710

Merged
merged 6 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ You can change the directory to install servers by set `g:lsp_settings_servers_d
| Ruby | steep | Yes | Yes |
| Ruby | typeprof | Yes | Yes |
| Ruby | rubocop (lsp mode) | Yes | No |
| Ruby | sorbet | Yes | No |
| Rust | rls | Yes | No |
| Rust | rust-analyzer | Yes | Yes |
| Sphinx | esbonio | Yes | Yes |
Expand Down Expand Up @@ -305,6 +306,12 @@ To use older version `golangci-lint`, please run `:LspSettingsGlobalEdit` and pu

To use rubocop-lsp-mode, you need to install rubocop in your Ruby project using bundler.

### [sorbet (Ruby)](https://sorbet.org/docs/vscode)

To use sorbet, you need to install rubocop in your Ruby project using bundler.
Also, [Watchman](https://facebook.github.io/watchman/) is required to watch file changes.
For more details, please see [Sorbet](https://sorbet.org/docs/vscode#installing-and-enabling-the-sorbet-extension) and [Watchman](https://facebook.github.io/watchman/docs/install.html) documentations.

## Extra Configurations

Most of the configurations are not required.
Expand Down
18 changes: 18 additions & 0 deletions installer/install-sorbet.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@echo off

echo @echo off ^

setlocal ^

set TARGET_DIR=%%1 ^

shift ^

cd %%TARGET_DIR%% ^

bundle exec srb typecheck %%* ^

> sorbet.cmd

echo Install Done.
echo **You need add sorbet dependencies in Gemfile.**
17 changes: 17 additions & 0 deletions installer/install-sorbet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

set -e

cat <<EOF >sorbet
#!/bin/sh

TARGET_DIR=\$1
shift
cd \${TARGET_DIR}
bundle exec srb typecheck \$*
EOF

chmod +x sorbet

echo 'Install Done.'
echo '**You need add sorbet dependencies in Gemfile.**'
11 changes: 11 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1346,6 +1346,17 @@
"root_uri_patterns": [
"Gemfile"
]
},
{
"command": "sorbet",
"url": "https://sorbet.org/",
"description": "Sorbet is a fast, powerful type checker designed for Ruby.",
"requires": [
"bundle"
],
"root_uri_patterns": [
"Gemfile"
]
}
],
"rust": [
Expand Down
24 changes: 24 additions & 0 deletions settings/sorbet.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function! Vim_lsp_get_watchman_flag()
if executable('watchman')
return ''
endif

" cf. https://sorbet.org/docs/vscode#installing-and-enabling-the-sorbet-extension
echo "To watch file changes, watchman is required for sorbet-lsp"

Check failure on line 7 in settings/sorbet.vim

View workflow job for this annotation

GitHub Actions / runner / vint

[vint] reported by reviewdog 🐶 Prefer single quoted strings (see Google VimScript Style Guide (Strings)) Raw Output: settings/sorbet.vim:7:8: Prefer single quoted strings (see Google VimScript Style Guide (Strings))
return '--disable-watchman'
endfunction

augroup vim_lsp_settings_sorbet
au!
LspRegisterServer {
\ 'name': 'sorbet',
\ 'cmd': {server_info->lsp_settings#get('sorbet', 'cmd', [lsp_settings#exec_path('sorbet'), lsp#utils#uri_to_path(lsp_settings#root_uri('sorbet')), '--lsp', Vim_lsp_get_watchman_flag()])+lsp_settings#get('sorbet', 'args', [])},
\ 'root_uri':{server_info->lsp_settings#get('sorbet', 'root_uri', lsp_settings#root_uri('sorbet'))},
\ 'initialization_options': lsp_settings#get('sorbet', 'initialization_options', v:null),
\ 'allowlist': lsp_settings#get('sorbet', 'allowlist', ['ruby']),
\ 'blocklist': lsp_settings#get('sorbet', 'blocklist', []),
\ 'config': lsp_settings#get('sorbet', 'config', lsp_settings#server_config('sorbet')),
\ 'workspace_config': lsp_settings#get('sorbet', 'workspace_config', {}),
\ 'semantic_highlight': lsp_settings#get('sorbet', 'semantic_highlight', {}),
\ }
augroup END
Loading