Setting a custom path for "ruby.format": "rubocop"
ndbroadbent opened this issue · comments
It looks like the rubocop
for formatOnSave
doesn't use the path from:
"ruby.lint": {
"rubocop": {
"path": "/usr/local/bin"
}
},
(But the lint
step does use /usr/local/bin/rubocop
.)
How can I configure the path for "ruby.format": "rubocop"
?
I've been working on this PR for rubocop-daemon, and have been trying to get my wrapper script to work with VS Code. The script starts a RuboCop server process as a daemon, and then sends commands via netcat
. It's about 20x faster than running the plain rubocop
command (150ms vs 4s), so I would really love to get this working!
My workaround for now is to just override the rubocop
binary with a symlink to my wrapper script:
ln -fs /usr/local/bin/rubocop-daemon-wrapper /Users/ndbroadbent/.rvm/gems/ruby-2.5.3/bin/rubocop
But this is very brittle, and will probably break a lot in the future.
Also it would be great if I could rename the binary. Something like: "ruby.rubocop.binary": " /usr/local/bin/rubocop-daemon-wrapper"
Whoa, I just realized that vscode-ruby
could directly integrate with rubocop-daemon
via TCP connections, instead of needing to start a client process. This would make it even faster. I'm going to start working on this instead, and then I won't need the path option (but that would be nice too.)
I'll add a new rubocop-daemon
option for ruby.format
and ruby.lint
, which will connect to the daemon via TCP, and it will start a new daemon server if it's not already running.
@ndbroadbent Moving over to VS Code from Atom where I was able to configure rubocop-daemon just fine, I'm very excited to try out your changes.
This will work when #405 lands. I've been explicitly testing absolute paths in the configuration (although I'd also love to add first-party support for a TCP connection).
#405 has been merged which should help a lot with RuboCop configuration.
@ndbroadbent would you open a new issue related to getting rubocop-daemon
integrated via a TCP connection? I think that's going to be some work
Hi @wingrunr21, sorry I didn't reply until now! I am just setting up rubocop-daemon-wrapper
again, and I'm still struggling to set the path for rubocop
. This is my settings.json
:
"ruby.lint": {
"rubocop": {
"path": "/usr/local/bin/rubocop-daemon-wrapper"
}
},
"ruby.format": "rubocop"
(I'm trying to run the rubocop wrapper at /usr/local/bin/rubocop-daemon-wrapper/rubocop
.)
Should this work, or do I need to change my settings?
@ndbroadbent How about following settins?
{
"ruby.lint": {
"rubocop": {
"useBundler": true,
"command": "/usr/local/bin/rubocop-daemon-wrapper/rubocop"
}
},
"ruby.format": "rubocop"
}
I think this works well in linting.
But format with rubocop-daemon-wrapper
does'nt(this is reported at #548 ).
It would appear this is an issue again due to the Ruby Language Server move @wingrunr21 :(
vscode-ruby-client
uses the linter configs in the formatter, and allows ruby.lint.rubocop.exe
to override the executable, but the Ruby Language Server no longer does this, and it's unclear if it even could (since the config is passed in, rather than retrieved)
It seems like there's a FormatterConfig interface in the language server, is that connected to the VS Code config? I could send a PR implementing the same command
option as the linter has if it's configurable