-
Notifications
You must be signed in to change notification settings - Fork 8
Add rubocop integration #27
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
Conversation
Wow, I'm also thinking rubocop integration!
Hmm, I think it's good to be invoked in the same process.
You meant "how can we enable/disable rubocop?", right? |
I agree with your thought, but I guess it's difficult... Bundler replaces dependencies path. ex)
puts Gem::Specification._all.each(&:gem_dir)
puts require "rubocop" In case of no bundle exec, it can require global gems.
In case of bundle exec, it can't.
So, we have to add rubocop and its dependencies to $LOAD_PATH to use require. Simple solution is to add rubocop to language_server's deps. But in that case, it can't use local managed rubocop... Do you have any good idea? |
Sorry, I meant local rubocop. I assume that the common use case is all things in one Gemfile: gem 'rails'
...
gem 'rubocop'
gem 'language_server' |
I would think the language server would not be installed on a per project basis, as it usually has little to do with an actual project. It makes more sense for it to be installed globally as it is being referenced by a text editor, which may or may not set its current working directory as the currently opened project's directory. As such, it may make sense for it to include Rubocop as a dependency inside language_server and use a global Rubocop executable, but use the local project's Rubocop configuration. Otherwise, there are going to be multiple language_server installations on a user's machine and it becomes difficult for a text editor to keep track of where it needs to be loading the language server's executable unless we have a Ruby LSP specific extension for every editor. Letting it be global allows generic extension's like Sublime's LSP to just use it without having to constantly search for it. |
I agree with @cameronbroe. |
tl;dr I think the language server is installed as same as other tools, such like rubocop, guard, etc. https://github.com/tootsuite/mastodon/blob/8392ddbf87f5522c445573c50e4f21d690172bc0/Gemfile#L105 And if other co-workers or contributors disagree with adding it to Gemfile, you can create local Gemfile. And Ruby version is different between projects. So IMO, it should be installed locally and how to boot the language server will depend on each project. However, I wouldn't like to prevent installing this server globally. |
bb1d908
to
36d74bf
Compare
36d74bf
to
50520da
Compare
@mtsmfm ok, I implemented to try require and run rubocop on LSP process. |
Dockerfile.development
Outdated
ENV LANG=C.UTF-8 \ | ||
BUNDLE_PATH=/vendor/bundle/$RUBY_VERSION \ | ||
BUNDLE_JOBS=4 | ||
ENV PATH=$PATH:/vendor/bundle/$RUBY_VERSION/bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this line?
I guess it's for loading rubocop binary and it isn't needed anymore
bin/setup
Outdated
|
||
bundle install | ||
|
||
# Do any other automated setup that you need to do here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this line?
lib/language_server.rb
Outdated
|
||
on :"textDocument/didChange" do |request:, notifier:, file_store:, project:| | ||
uri = request[:params][:textDocument][:uri] | ||
filePath = uri.match(/^file:\/\/(.*\.rb)/)[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file_store.path_from_remote_uri(uri)
will help us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I think we can pass the content via stdin.
|
||
## Not released | ||
|
||
- rubocop support #27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🙏
I implement rubocop integraion.
Need Conversation: