commit 2c743d5652eb2868b0c9c88ca2686d60b7c7afbf Author: James Spencer Date: Fri Sep 29 15:32:15 2023 +0100 feat: linting and diagnostics diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..cf1bad6 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,10 @@ +require: + - standard + - standard-custom + - standard-performance + - rubocop-performance + +inherit_gem: + standard: config/base.yml + standard-custom: config/base.yml + standard-performance: config/base.yml diff --git a/.solargraph.yml b/.solargraph.yml new file mode 100644 index 0000000..e907e39 --- /dev/null +++ b/.solargraph.yml @@ -0,0 +1,17 @@ +--- +include: +- "**/*.rb" +exclude: +- spec/**/* +- test/**/* +- vendor/**/* +- ".bundle/**/*" +require: [] +domains: [] +reporters: +- rubocop +- require_not_found +- typecheck +require_paths: [] +plugins: [] +max_files: 5000 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..f1885af --- /dev/null +++ b/Gemfile @@ -0,0 +1,7 @@ +source "https://rubygems.org" + +group :development do + gem "rdoc" + gem "rubocop" + gem "solargraph" +end diff --git a/README.md b/README.md new file mode 100644 index 0000000..ecb9d5f --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Ruby Starter + +A super simple Ruby starter project. + +Rubocop and Solargraph are included for linting and code completion, respectively and are configured to be used with [Zed](https://zed.dev/). + +## Prerequisites + +- [Ruby](https://www.ruby-lang.org/en/documentation/installation/) +- [Bundler](https://bundler.io/) +- [StandardRB](https://github.com/standardrb/standard) + +## Setup + +1. Clone this repository +2. Install dependencies: `bundle install` +3. Write awesome code + +## Usage with Zed + +Zed is a rough-around-the-edges editor in Beta. It's not very configurable yet, +so we're locked into using Solargraph as our language server. Solargraph is +only officially compatible with [Rubocop](https://rubocop.org/) _(ACAB)_ for linting, but we use our ruleset of choice, [StandardRB] by configuring it in `.rubocop.yml`. + +For now, make sure that StandardRB is installed globally, as Zed can't yet reach +into your local Gem's, as far as we are aware. + +Solargraph is configured in `.solargraph.yml` to use robocop, but to enable +inline diagnostics and formatting on save you must add the following to your Zed +`settings.json`: + +```json +{ + "lsp": { + "solargraph": { + "initialization_options": { + "diagnostics": true, + "formatting": true, + } + } + } +} +``` + +## Documentation + +If you'd like to generate some user-friendly documentation, you can run +`rake` on the command line to generate some HTML docs in the `rdoc` directory, made up of your comments and some metadata from your code. diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..5499a7e --- /dev/null +++ b/Rakefile @@ -0,0 +1,9 @@ +require "rdoc/task" +task default: [:rdoc] + +Rake::RDocTask.new do |rdoc| + rdoc.rdoc_dir = "rdoc" + rdoc.title = "rdoc" + rdoc.options << "--line-numbers" << "--inline-source" + rdoc.rdoc_files.include("**/*.rb") +end