rfmt 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75dece5f16cef2420a328e75f674416858eef7871c99a6aec1136c73f4b3b44c
4
- data.tar.gz: f514b13a111e7113ed68beb1a1443b7815f8b11d47deee454ef352acf3e5ec7d
3
+ metadata.gz: 7db146878fe1bbf37f4211f11ded67e98ebfb1830989a4fb64fbe1cc51a72fc7
4
+ data.tar.gz: bb87cfab19f7513ddd99b939c03286827687a5da6071c317390dc990924dbe05
5
5
  SHA512:
6
- metadata.gz: 3a3575ed8e1e35770b6ac016521ee131fc1cf92b065c16ae91418a1835e7ab6695f30b9f1bb09c2b45c24801ae9427490ae835fffca228137c18ca1299416bf2
7
- data.tar.gz: a5459089d49f7b905e565a3289dae2076df6a3d472a1332c0cca8f15ebab8d712a571e202b7053fcbbaeb85431d2f14f586e272e70966a0eeec1b72002e3fe4a
6
+ metadata.gz: 2018f31f65afd41842a51e21290448a753784b840dd67f9d8e7e41d223f509227143b18a15309b4a3cf19543b8638ce28045d0c1a68cf97dda8781811b058657
7
+ data.tar.gz: 888d036c08f29f166d1089a2cce27d9c456d57c83fbbd1c518142bdfaa15b32c551ab1ccda12c97bd48c9ddf63f57545ef47b6cbdcf8a774f8ea4eb1e17d1729
data/CHANGELOG.md CHANGED
@@ -1,10 +1,25 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [1.1.0] - 2025-12-12
4
+
5
+ ### Added
6
+ - Editor integration (Ruby LSP support)
7
+ - Required/Optional keyword parameter node type support
8
+
9
+ ### Fixed
10
+ - Migration file superclass corruption (ActiveRecord::Migration[8.1] etc.)
11
+
12
+ ### Changed
13
+ - Removed unused scripts and test files (reduced Ruby code by ~38%)
14
+
3
15
  ## [1.0.0] - 2025-12-11
4
16
 
5
17
  ### Breaking Changes
6
18
  - First stable release (v1.0.0)
7
19
 
20
+ ### Added
21
+ - Neovim integration: format-on-save support with autocmd configuration
22
+
8
23
  ### Changed
9
24
  - Set JSON as default output format
10
25
  - Updated Japanese documentation
data/README.md CHANGED
@@ -10,6 +10,7 @@ A Ruby code formatter written in Rust
10
10
  [Installation](#installation) •
11
11
  [Usage](#usage) •
12
12
  [Features](#features) •
13
+ [Editor Integration](#editor-integration) •
13
14
  [Documentation](#documentation) •
14
15
  [Contributing](#contributing)
15
16
 
@@ -273,6 +274,33 @@ class User < ApplicationRecord
273
274
  end
274
275
  ```
275
276
 
277
+ ## Editor Integration
278
+
279
+ ### Neovim
280
+
281
+ Format Ruby files on save using autocmd:
282
+
283
+ ```lua
284
+ -- ~/.config/nvim/init.lua
285
+
286
+ vim.api.nvim_create_autocmd("BufWritePre", {
287
+ pattern = { "*.rb", "*.rake", "Gemfile", "Rakefile" },
288
+ callback = function()
289
+ local filepath = vim.fn.expand("%:p")
290
+ local result = vim.fn.system({ "rfmt", filepath })
291
+ if vim.v.shell_error == 0 then
292
+ vim.cmd("edit!")
293
+ end
294
+ end,
295
+ })
296
+ ```
297
+
298
+ ### Coming Soon
299
+
300
+ - **VS Code** - Extension in development
301
+ - **RubyMine** - Plugin in development
302
+ - **Zed** - Extension in development
303
+
276
304
  ## Development
277
305
 
278
306
  ### Setup
@@ -66,6 +66,8 @@ pub enum NodeType {
66
66
  OptionalParameterNode,
67
67
  RestParameterNode,
68
68
  KeywordParameterNode,
69
+ RequiredKeywordParameterNode,
70
+ OptionalKeywordParameterNode,
69
71
  KeywordRestParameterNode,
70
72
  BlockParameterNode,
71
73
 
@@ -102,6 +104,8 @@ impl NodeType {
102
104
  "optional_parameter_node" => Self::OptionalParameterNode,
103
105
  "rest_parameter_node" => Self::RestParameterNode,
104
106
  "keyword_parameter_node" => Self::KeywordParameterNode,
107
+ "required_keyword_parameter_node" => Self::RequiredKeywordParameterNode,
108
+ "optional_keyword_parameter_node" => Self::OptionalKeywordParameterNode,
105
109
  "keyword_rest_parameter_node" => Self::KeywordRestParameterNode,
106
110
  "block_parameter_node" => Self::BlockParameterNode,
107
111
  _ => Self::Unknown(s.to_string()),
@@ -660,6 +660,8 @@ impl Emitter {
660
660
  | NodeType::OptionalParameterNode
661
661
  | NodeType::RestParameterNode
662
662
  | NodeType::KeywordParameterNode
663
+ | NodeType::RequiredKeywordParameterNode
664
+ | NodeType::OptionalKeywordParameterNode
663
665
  | NodeType::KeywordRestParameterNode
664
666
  | NodeType::BlockParameterNode
665
667
  )
@@ -27,16 +27,25 @@ module Rfmt
27
27
  when Prism::ConstantReadNode
28
28
  sc.name.to_s
29
29
  when Prism::ConstantPathNode
30
- # Try full_name first, fall back to name
30
+ # Try full_name first, fall back to slice for original source
31
31
  if sc.respond_to?(:full_name)
32
32
  sc.full_name.to_s
33
- elsif sc.respond_to?(:name)
34
- sc.name.to_s
33
+ elsif sc.respond_to?(:slice)
34
+ sc.slice
35
35
  else
36
- sc.to_s
36
+ sc.location.slice
37
37
  end
38
+ when Prism::CallNode
39
+ # Handle cases like ActiveRecord::Migration[8.1]
40
+ # Use slice to get the original source text
41
+ sc.slice
38
42
  else
39
- sc.to_s
43
+ # Fallback: try to get original source text
44
+ if sc.respond_to?(:slice)
45
+ sc.slice
46
+ else
47
+ sc.location.slice
48
+ end
40
49
  end
41
50
  end
42
51
 
data/lib/rfmt/rfmt.so CHANGED
Binary file
data/lib/rfmt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rfmt
4
- VERSION = '1.0.0'
4
+ VERSION = '1.1.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfmt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fujitani sora
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-11 00:00:00.000000000 Z
11
+ date: 2025-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys
@@ -41,8 +41,6 @@ files:
41
41
  - exe/rfmt
42
42
  - ext/rfmt/Cargo.toml
43
43
  - ext/rfmt/extconf.rb
44
- - ext/rfmt/spec/config_spec.rb
45
- - ext/rfmt/spec/spec_helper.rb
46
44
  - ext/rfmt/src/ast/mod.rs
47
45
  - ext/rfmt/src/config/mod.rs
48
46
  - ext/rfmt/src/emitter/mod.rs
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe 'Configuration' do
6
- describe 'configuration system integration' do
7
- it 'can load YAML configuration' do
8
- require 'tempfile'
9
- require 'yaml'
10
-
11
- config = {
12
- 'version' => '1.0',
13
- 'formatting' => {
14
- 'line_length' => 120,
15
- 'indent_width' => 4,
16
- 'indent_style' => 'tabs',
17
- 'quote_style' => 'single'
18
- }
19
- }
20
-
21
- Tempfile.create(['test_config', '.yml']) do |file|
22
- file.write(YAML.dump(config))
23
- file.flush
24
-
25
- loaded_config = YAML.load_file(file.path)
26
- expect(loaded_config['formatting']['line_length']).to eq(120)
27
- expect(loaded_config['formatting']['indent_width']).to eq(4)
28
- expect(loaded_config['formatting']['indent_style']).to eq('tabs')
29
- expect(loaded_config['formatting']['quote_style']).to eq('single')
30
- end
31
- end
32
-
33
- it 'validates configuration values' do
34
- # Configuration validation is tested in Rust tests
35
- # 11 Rust tests verify all validation logic
36
- expect(true).to be true
37
- end
38
- end
39
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/setup'
4
- require 'rfmt'
5
-
6
- RSpec.configure do |config|
7
- config.expect_with :rspec do |expectations|
8
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
9
- end
10
-
11
- config.mock_with :rspec do |mocks|
12
- mocks.verify_partial_doubles = true
13
- end
14
-
15
- config.shared_context_metadata_behavior = :apply_to_host_groups
16
- end