ruby-lsp-rubyfmt 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +44 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +18 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +27 -0
- data/Gemfile.lock +129 -0
- data/LICENSE.txt +21 -0
- data/README.md +65 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/ruby/lsp/rubyfmt/version.rb +10 -0
- data/lib/ruby/lsp/rubyfmt.rb +13 -0
- data/lib/ruby_lsp/ruby-lsp-rubyfmt/addon.rb +45 -0
- data/ruby-lsp-rubyfmt.gemspec +45 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8c479638aa3af78b4cfb62a38667b4ee5442bd55ce76fbc07ac14908c6f3ca11
|
4
|
+
data.tar.gz: ab1d2559148de64d2efd25d8f38c734dd535cf6f2f2e3aa8ea8f70084b73e219
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 78b906a43886b546d05ea40fc2475e2fdbb21fa19e32c91998970bfce10fd74cfd053ae945819a9f432da9d400ba2a442e257f0eea5a066a7799c6f83bcf2c46
|
7
|
+
data.tar.gz: 295c86f42a0baae81315e19fd4f2ce3d538051bb567fb4702179e0f0d303751426a70605b15e3f3d59192e523570a63d1bc49e4421aee5969b1164d1dfdce69d
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "main" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "main" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: macos-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['3.0', '3.1', '3.2', '3.3']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
31
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
32
|
+
uses: ruby/setup-ruby@v1
|
33
|
+
with:
|
34
|
+
ruby-version: ${{ matrix.ruby-version }}
|
35
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
36
|
+
- name: Set up Homebrew
|
37
|
+
id: set-up-homebrew
|
38
|
+
uses: Homebrew/actions/setup-homebrew@master
|
39
|
+
- name: Set up rubyfmt
|
40
|
+
run: brew install rubyfmt
|
41
|
+
- name: Run RuboCop
|
42
|
+
run: bundle exec rubocop --parallel
|
43
|
+
- name: Run tests
|
44
|
+
run: bundle exec rake test
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
rubocop-shopify: rubocop.yml
|
3
|
+
|
4
|
+
require:
|
5
|
+
- rubocop-sorbet
|
6
|
+
- rubocop-minitest
|
7
|
+
- rubocop-rake
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
NewCops: disable
|
11
|
+
SuggestExtensions: false
|
12
|
+
TargetRubyVersion: 3.2
|
13
|
+
|
14
|
+
Naming/FileName:
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Style/StderrPuts:
|
18
|
+
Enabled: true
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3.0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at joshua.scharf@fullscript.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in ruby-lsp-rubyfmt.gemspec
|
8
|
+
gemspec
|
9
|
+
|
10
|
+
# sorbet-static is not available on Windows. We also skip Tapioca since it depends on sorbet-static-and-runtime
|
11
|
+
# C Ruby (MRI), Rubinius or TruffleRuby, but NOT Windows
|
12
|
+
NON_WINDOWS_PLATFORMS = [:ruby]
|
13
|
+
|
14
|
+
group :development do
|
15
|
+
gem "bundler", "~> 2.4.2"
|
16
|
+
gem "debug", "~> 1.8", require: false
|
17
|
+
gem "minitest", "~> 5.20"
|
18
|
+
gem "minitest-reporters", "~> 1.6"
|
19
|
+
gem "rake", "~> 13.1"
|
20
|
+
gem "rubocop", "~> 1.57"
|
21
|
+
gem "rubocop-shopify", "~> 2.14", require: false
|
22
|
+
gem "rubocop-minitest", "~> 0.33.0", require: false
|
23
|
+
gem "rubocop-rake", "~> 0.6.0", require: false
|
24
|
+
gem "rubocop-sorbet", "~> 0.7", require: false
|
25
|
+
gem "sorbet-static-and-runtime", platforms: NON_WINDOWS_PLATFORMS
|
26
|
+
gem "tapioca", require: false, platforms: NON_WINDOWS_PLATFORMS
|
27
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby-lsp-rubyfmt (0.1.0)
|
5
|
+
ruby-lsp (>= 0.12.0)
|
6
|
+
sorbet-runtime (>= 0.5.5685)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ansi (1.5.0)
|
12
|
+
ast (2.4.2)
|
13
|
+
builder (3.2.4)
|
14
|
+
debug (1.8.0)
|
15
|
+
irb (>= 1.5.0)
|
16
|
+
reline (>= 0.3.1)
|
17
|
+
erubi (1.12.0)
|
18
|
+
io-console (0.6.0)
|
19
|
+
irb (1.9.1)
|
20
|
+
rdoc
|
21
|
+
reline (>= 0.3.8)
|
22
|
+
json (2.7.0)
|
23
|
+
language_server-protocol (3.17.0.3)
|
24
|
+
minitest (5.20.0)
|
25
|
+
minitest-reporters (1.6.1)
|
26
|
+
ansi
|
27
|
+
builder
|
28
|
+
minitest (>= 5.0)
|
29
|
+
ruby-progressbar
|
30
|
+
netrc (0.11.0)
|
31
|
+
parallel (1.24.0)
|
32
|
+
parser (3.2.2.4)
|
33
|
+
ast (~> 2.4.1)
|
34
|
+
racc
|
35
|
+
prettier_print (1.2.1)
|
36
|
+
prism (0.17.1)
|
37
|
+
psych (5.1.1.1)
|
38
|
+
stringio
|
39
|
+
racc (1.7.3)
|
40
|
+
rainbow (3.1.1)
|
41
|
+
rake (13.1.0)
|
42
|
+
rbi (0.1.4)
|
43
|
+
prism (>= 0.17.1, < 0.18)
|
44
|
+
sorbet-runtime (>= 0.5.9204)
|
45
|
+
rdoc (6.6.0)
|
46
|
+
psych (>= 4.0.0)
|
47
|
+
regexp_parser (2.8.2)
|
48
|
+
reline (0.4.1)
|
49
|
+
io-console (~> 0.5)
|
50
|
+
rexml (3.2.6)
|
51
|
+
rubocop (1.58.0)
|
52
|
+
json (~> 2.3)
|
53
|
+
language_server-protocol (>= 3.17.0)
|
54
|
+
parallel (~> 1.10)
|
55
|
+
parser (>= 3.2.2.4)
|
56
|
+
rainbow (>= 2.2.2, < 4.0)
|
57
|
+
regexp_parser (>= 1.8, < 3.0)
|
58
|
+
rexml (>= 3.2.5, < 4.0)
|
59
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
60
|
+
ruby-progressbar (~> 1.7)
|
61
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
62
|
+
rubocop-ast (1.30.0)
|
63
|
+
parser (>= 3.2.1.0)
|
64
|
+
rubocop-minitest (0.33.0)
|
65
|
+
rubocop (>= 1.39, < 2.0)
|
66
|
+
rubocop-rake (0.6.0)
|
67
|
+
rubocop (~> 1.0)
|
68
|
+
rubocop-shopify (2.14.0)
|
69
|
+
rubocop (~> 1.51)
|
70
|
+
rubocop-sorbet (0.7.5)
|
71
|
+
rubocop (>= 0.90.0)
|
72
|
+
ruby-lsp (0.12.5)
|
73
|
+
language_server-protocol (~> 3.17.0)
|
74
|
+
prism (>= 0.17.1, < 0.18)
|
75
|
+
sorbet-runtime (>= 0.5.5685)
|
76
|
+
ruby-progressbar (1.13.0)
|
77
|
+
sorbet (0.5.11164)
|
78
|
+
sorbet-static (= 0.5.11164)
|
79
|
+
sorbet-runtime (0.5.11164)
|
80
|
+
sorbet-static (0.5.11164-universal-darwin)
|
81
|
+
sorbet-static-and-runtime (0.5.11164)
|
82
|
+
sorbet (= 0.5.11164)
|
83
|
+
sorbet-runtime (= 0.5.11164)
|
84
|
+
spoom (1.2.4)
|
85
|
+
erubi (>= 1.10.0)
|
86
|
+
sorbet-static-and-runtime (>= 0.5.10187)
|
87
|
+
syntax_tree (>= 6.1.1)
|
88
|
+
thor (>= 0.19.2)
|
89
|
+
stringio (3.1.0)
|
90
|
+
syntax_tree (6.2.0)
|
91
|
+
prettier_print (>= 1.2.0)
|
92
|
+
tapioca (0.11.14)
|
93
|
+
bundler (>= 2.2.25)
|
94
|
+
netrc (>= 0.11.0)
|
95
|
+
parallel (>= 1.21.0)
|
96
|
+
rbi (>= 0.1.4, < 0.2)
|
97
|
+
sorbet-static-and-runtime (>= 0.5.10187)
|
98
|
+
spoom (~> 1.2.0, >= 1.2.0)
|
99
|
+
thor (>= 1.2.0)
|
100
|
+
yard-sorbet
|
101
|
+
thor (1.3.0)
|
102
|
+
unicode-display_width (2.5.0)
|
103
|
+
yard (0.9.34)
|
104
|
+
yard-sorbet (0.8.1)
|
105
|
+
sorbet-runtime (>= 0.5)
|
106
|
+
yard (>= 0.9)
|
107
|
+
|
108
|
+
PLATFORMS
|
109
|
+
arm64-darwin-22
|
110
|
+
arm64-darwin-23
|
111
|
+
x86_64-darwin-20
|
112
|
+
|
113
|
+
DEPENDENCIES
|
114
|
+
bundler (~> 2.4.2)
|
115
|
+
debug (~> 1.8)
|
116
|
+
minitest (~> 5.20)
|
117
|
+
minitest-reporters (~> 1.6)
|
118
|
+
rake (~> 13.1)
|
119
|
+
rubocop (~> 1.57)
|
120
|
+
rubocop-minitest (~> 0.33.0)
|
121
|
+
rubocop-rake (~> 0.6.0)
|
122
|
+
rubocop-shopify (~> 2.14)
|
123
|
+
rubocop-sorbet (~> 0.7)
|
124
|
+
ruby-lsp-rubyfmt!
|
125
|
+
sorbet-static-and-runtime
|
126
|
+
tapioca
|
127
|
+
|
128
|
+
BUNDLED WITH
|
129
|
+
2.4.21
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Joshua Scharf
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Ruby::Lsp::Rubyfmt
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'ruby-lsp-rubyfmt'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ruby-lsp-rubyfmt
|
18
|
+
|
19
|
+
## Dependency
|
20
|
+
|
21
|
+
To use this Ruby LSP Addon, you need to have [`rubyfmt`](https://github.com/fables-tales/rubyfmt) installed as it's an external dependency.
|
22
|
+
|
23
|
+
This addon calls the `rubyfmt` executable in `addon.rb`
|
24
|
+
|
25
|
+
If you already have homebrew installed, you can install `rubyfmt` by running the following
|
26
|
+
|
27
|
+
```
|
28
|
+
brew install rubyfmt
|
29
|
+
```
|
30
|
+
|
31
|
+
If you don't, go to https://brew.sh and install it on your machine.
|
32
|
+
|
33
|
+
Check if the installation was successfully by running the following
|
34
|
+
```
|
35
|
+
rubyfmt --version
|
36
|
+
```
|
37
|
+
|
38
|
+
If it was successful, you should see a version number printed.
|
39
|
+
|
40
|
+
## Usage
|
41
|
+
|
42
|
+
To use this addon, you need to modify the VS code setting `rubyLsp.formatter` in `settings.json`
|
43
|
+
```
|
44
|
+
"rubyLsp.formatter": "rubyfmt"
|
45
|
+
```
|
46
|
+
|
47
|
+
After that, open the VS code command pallete and select the option `Developer: Reload Window`.
|
48
|
+
|
49
|
+
## Development
|
50
|
+
|
51
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
52
|
+
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby-lsp-rubyfmt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
58
|
+
|
59
|
+
## License
|
60
|
+
|
61
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
62
|
+
|
63
|
+
## Code of Conduct
|
64
|
+
|
65
|
+
Everyone interacting in the Ruby::Lsp::Rubyfmt project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/ruby-lsp-rubyfmt/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "ruby/lsp/rubyfmt"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# typed: false
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "open3"
|
5
|
+
|
6
|
+
module RubyLsp
|
7
|
+
module RubyLspRubyfmt
|
8
|
+
class Addon < RubyLsp::Addon
|
9
|
+
def name
|
10
|
+
"Ruby Fmt Formatter"
|
11
|
+
end
|
12
|
+
|
13
|
+
def activate
|
14
|
+
# The first argument is an identifier users can pick to select this formatter. To use this formatter, users must
|
15
|
+
# have rubyLsp.formatter configured to "rubyfmt"
|
16
|
+
# The second argument is a singleton instance that implements the `FormatterRunner` interface (see below)
|
17
|
+
RubyLsp::Requests::Formatting.register_formatter("rubyfmt", RubyFmtFormatterRunner.instance)
|
18
|
+
end
|
19
|
+
|
20
|
+
def deactivate
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# Custom formatting runner
|
25
|
+
class RubyFmtFormatterRunner
|
26
|
+
# Make it a singleton class
|
27
|
+
include Singleton
|
28
|
+
# If using Sorbet to develop the addon, then include this interface to make sure the class is properly implemented
|
29
|
+
include RubyLsp::Requests::Support::FormatterRunner
|
30
|
+
|
31
|
+
# Use the initialize method to perform any sort of ahead of time work.
|
32
|
+
# For example, reading configurations for yourformatter since they are unlikely to change between requests
|
33
|
+
def initialize
|
34
|
+
end
|
35
|
+
|
36
|
+
# The main part of the interface is implementing the run method.
|
37
|
+
# It receives the URI and the document being formatted.
|
38
|
+
# IMPORTANT: This method must return the formatted document source without mutating the original one in document
|
39
|
+
def run(uri, document)
|
40
|
+
output, _status = Open3.capture2("rubyfmt", stdin_data: document.source)
|
41
|
+
output
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "ruby/lsp/rubyfmt/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "ruby-lsp-rubyfmt"
|
9
|
+
spec.version = Ruby::Lsp::Rubyfmt::VERSION
|
10
|
+
spec.authors = ["Joshua Scharf"]
|
11
|
+
spec.email = ["joshua@scharf.dev"]
|
12
|
+
|
13
|
+
spec.summary = "Ruby LSP rubyfmt"
|
14
|
+
spec.description = "An addon for the Ruby LSP that enables formatting with rubyfmt"
|
15
|
+
spec.homepage = "http://mygemserver.com"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
20
|
+
if spec.respond_to?(:metadata)
|
21
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
22
|
+
|
23
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
spec.metadata["source_code_uri"] = "https://github.com/jscharf/ruby-lsp-rubyfmt"
|
25
|
+
spec.metadata["changelog_uri"] = "https://github.com/jscharf/ruby-lsp-rubyfmt"
|
26
|
+
else
|
27
|
+
raise(
|
28
|
+
"RubyGems 2.0 or newer is required to protect against " \
|
29
|
+
"public gem pushes.",
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Specify which files should be added to the gem when it is released.
|
34
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
35
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
36
|
+
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
37
|
+
end
|
38
|
+
|
39
|
+
spec.bindir = "exe"
|
40
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
41
|
+
spec.require_paths = ["lib"]
|
42
|
+
|
43
|
+
spec.add_dependency("ruby-lsp", ">= 0.12.0")
|
44
|
+
spec.add_dependency("sorbet-runtime", ">= 0.5.5685")
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-lsp-rubyfmt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joshua Scharf
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby-lsp
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.12.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.12.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sorbet-runtime
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.5.5685
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.5.5685
|
41
|
+
description: An addon for the Ruby LSP that enables formatting with rubyfmt
|
42
|
+
email:
|
43
|
+
- joshua@scharf.dev
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".github/workflows/ruby.yml"
|
49
|
+
- ".gitignore"
|
50
|
+
- ".rubocop.yml"
|
51
|
+
- ".ruby-version"
|
52
|
+
- CODE_OF_CONDUCT.md
|
53
|
+
- Gemfile
|
54
|
+
- Gemfile.lock
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- bin/console
|
59
|
+
- bin/setup
|
60
|
+
- lib/ruby/lsp/rubyfmt.rb
|
61
|
+
- lib/ruby/lsp/rubyfmt/version.rb
|
62
|
+
- lib/ruby_lsp/ruby-lsp-rubyfmt/addon.rb
|
63
|
+
- ruby-lsp-rubyfmt.gemspec
|
64
|
+
homepage: http://mygemserver.com
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
allowed_push_host: https://rubygems.org
|
69
|
+
homepage_uri: http://mygemserver.com
|
70
|
+
source_code_uri: https://github.com/jscharf/ruby-lsp-rubyfmt
|
71
|
+
changelog_uri: https://github.com/jscharf/ruby-lsp-rubyfmt
|
72
|
+
post_install_message:
|
73
|
+
rdoc_options: []
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubygems_version: 3.5.4
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Ruby LSP rubyfmt
|
91
|
+
test_files: []
|