Skip to content

Commit

Permalink
Add RuboCop lsp mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikoto2000 committed Aug 18, 2023
1 parent 13fc03c commit 6cf7ce1
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ You can change the directory to install servers by set `g:lsp_settings_servers_d
| Ruby | solargraph | Yes | Yes |
| Ruby | steep | Yes | Yes |
| Ruby | typeprof | Yes | Yes |
| Ruby | rubocop (lsp mode) | Yes | No |
| Rust | rls | Yes | No |
| Rust | rust-analyzer | Yes | Yes |
| Sphinx | esbonio | Yes | Yes |
Expand Down Expand Up @@ -299,6 +300,10 @@ To use older version `golangci-lint`, please run `:LspSettingsGlobalEdit` and pu
}
```

### [rubocop lsp mode (Ruby)](https://docs.rubocop.org/rubocop/usage/lsp.html)

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

## Extra Configurations

Most of the configurations are not required.
Expand Down
18 changes: 18 additions & 0 deletions installer/install-rubocop-lsp-mode.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 rubocop %%* ^

> rubocop-lsp-mode.cmd

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

set -e

cat <<EOF >rubocop-lsp-mode
#!/bin/sh
TARGET_DIR=\$1
shift
cd \${TARGET_DIR}
bundle exec rubocop \$*
EOF

chmod +x rubocop-lsp-mode

echo 'Install Done.'
echo '**You need add rubocop dependencies in Gemfile.**'
11 changes: 11 additions & 0 deletions settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,17 @@
"requires": [
"gem"
]
},
{
"command": "rubocop-lsp-mode",
"url": "https://github.com/rubocop/rubocop",
"description": "A Ruby static code analyzer and formatter, based on the community Ruby style guide.",
"requires": [
"bundle"
],
"root_uri_patterns": [
"Gemfile"
]
}
],
"rust": [
Expand Down
14 changes: 14 additions & 0 deletions settings/rubocop-lsp-mode.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
augroup vim_lsp_settings_rubocop_vim_ls
au!
LspRegisterServer {
\ 'name': 'rubocop-lsp-mode',
\ 'cmd': {server_info->lsp_settings#get('rubocop-lsp-mode', 'cmd', [lsp_settings#exec_path('rubocop-lsp-mode'), lsp#utils#uri_to_path(lsp_settings#root_uri('rubocop-lsp-mode')), '--lsp'])+lsp_settings#get('rubocop-lsp-mode', 'args', [])},
\ 'root_uri':{server_info->lsp_settings#get('rubocop-lsp-mode', 'root_uri', lsp_settings#root_uri('rubocop-lsp-mode'))},
\ 'initialization_options': lsp_settings#get('rubocop-lsp-mode', 'initialization_options', v:null),
\ 'allowlist': lsp_settings#get('rubocop-lsp-mode', 'allowlist', ['ruby']),
\ 'blocklist': lsp_settings#get('rubocop-lsp-mode', 'blocklist', []),
\ 'config': lsp_settings#get('rubocop-lsp-mode', 'config', lsp_settings#server_config('rubocop-lsp-mode')),
\ 'workspace_config': lsp_settings#get('rubocop-lsp-mode', 'workspace_config', {}),
\ 'semantic_highlight': lsp_settings#get('rubocop-lsp-mode', 'semantic_highlight', {}),
\ }
augroup END

0 comments on commit 6cf7ce1

Please sign in to comment.