kanayago 0.5.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +35 -0
- data/README.md +119 -8
- data/ext/kanayago/kanayago.c +7 -0
- data/ext/kanayago/kanayago.h +2 -0
- data/images/coc-kanayago-demo.png +0 -0
- data/images/vscode-kanayago-demo.png +0 -0
- data/lib/kanayago/lsp/diagnostics.rb +15 -10
- data/lib/kanayago/version.rb +1 -1
- data/lib/kanayago.rb +5 -4
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 70152c7596a4203fee587c54a35ab9c959346881525adceaff93a00ebc13c8c8
|
|
4
|
+
data.tar.gz: c2da754698c773ed1d0e23fa3566c96feb204cf63123d3c561c750ef8c0db75c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 497bfbc8020190f5c356728c6f36769978a93a288be653fc929269b619ac1b3e0575b5d3cfeda9f9fe750c0b59edd4a21e86c9ffe1b89fca1847f55b38e28ec4
|
|
7
|
+
data.tar.gz: 368c35402d3575d61c81893b834866d96ccd8c99162193ae212636984b049f8ab443e6a639a0e9d160a58083514477babf0d334f4f08a134569f531343eae1fc
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0]
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Add official editor plugins for LSP integration
|
|
14
|
+
- VSCode extension: `vscode-kanayago` available on Visual Studio Marketplace
|
|
15
|
+
- coc.nvim extension: `coc-kanayago` installable via `:CocInstall coc-kanayago`
|
|
16
|
+
- Add screenshots and integration guides to README for both plugins
|
|
17
|
+
- Add Emacs integration guide to README
|
|
18
|
+
- Add lsp-mode configuration example for `init.el`
|
|
19
|
+
- Document how to register Kanayago LSP server and enable it for Ruby files
|
|
20
|
+
- Add Helix editor integration guide to README
|
|
21
|
+
- Add configuration example for `~/.config/helix/languages.toml`
|
|
22
|
+
- Document how to use Kanayago LSP with Helix editor
|
|
23
|
+
- Add Zed editor integration guide to README
|
|
24
|
+
- Add official Zed extension `zed-kanayago` available on Zed Extensions marketplace
|
|
25
|
+
- Document how to install and use Kanayago LSP with Zed editor
|
|
26
|
+
- Add manual installation guide for development purposes
|
|
27
|
+
- Add `script_lines` support to parser for accurate line information
|
|
28
|
+
- Enable `rb_ruby_parser_set_script_lines()` in parser to capture source code lines
|
|
29
|
+
- Add `script_lines` attribute to `ParseResult` class
|
|
30
|
+
- Expose script_lines array containing each line of parsed source code
|
|
31
|
+
- Use script_lines for accurate character range calculation in LSP diagnostics
|
|
32
|
+
|
|
33
|
+
### Fixed
|
|
34
|
+
- Fix LSP diagnostics to report accurate error line numbers
|
|
35
|
+
- Update error message pattern matching to support both `main:LINE:` and `(eval):LINE:` formats
|
|
36
|
+
- Remove incorrect `-1` offset that was causing errors to be reported one line above the actual error location
|
|
37
|
+
- Parser already returns 0-based line numbers, matching LSP protocol requirements
|
|
38
|
+
- Clean up error messages by removing redundant `main:LINE:` prefix from diagnostic messages
|
|
39
|
+
- Add comprehensive test cases for error line detection in multi-line source code
|
|
40
|
+
- Fix LSP diagnostics not showing underlines in VSCode
|
|
41
|
+
- Use `script_lines` to calculate accurate line length for diagnostic range end position
|
|
42
|
+
- Set proper character range (`end.character`) to display red squiggly lines on entire error line
|
|
43
|
+
- Previously, `start` and `end` positions were identical (both at character 0), preventing underlines from appearing
|
|
44
|
+
|
|
10
45
|
## [0.5.0]
|
|
11
46
|
|
|
12
47
|
### Added
|
data/README.md
CHANGED
|
@@ -31,7 +31,7 @@ Finally, build `Kanayago` gem and install it.
|
|
|
31
31
|
|
|
32
32
|
```console
|
|
33
33
|
bundle exec rake build
|
|
34
|
-
gem install pkg/kanayago-0.
|
|
34
|
+
gem install pkg/kanayago-0.6.0.gem
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
## Usage
|
|
@@ -47,25 +47,62 @@ $ kanayago --lsp
|
|
|
47
47
|
|
|
48
48
|
This starts an LSP server that communicates via stdin/stdout. You can integrate it with LSP-compliant editors like VSCode, Vim, Emacs, etc.
|
|
49
49
|
|
|
50
|
-
#### VSCode Integration
|
|
50
|
+
#### VSCode Integration
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Install the official VSCode extension from the marketplace:
|
|
53
|
+
|
|
54
|
+
1. Open VSCode and search for "VSCode Kanayago" in the Extensions view
|
|
55
|
+
2. Click Install
|
|
56
|
+
|
|
57
|
+
**Configuration:**
|
|
53
58
|
|
|
54
59
|
```json
|
|
55
60
|
{
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"ruby.languageServerPath": "kanayago",
|
|
59
|
-
"ruby.languageServerArgs": ["--lsp"]
|
|
61
|
+
"kanayago.serverPath": "kanayago",
|
|
62
|
+
"kanayago.trace.server": "off"
|
|
60
63
|
}
|
|
61
64
|
```
|
|
62
65
|
|
|
63
66
|
Now VSCode will show syntax errors in real-time as you type Ruby code.
|
|
64
67
|
|
|
65
|
-
|
|
68
|
+

|
|
69
|
+
|
|
70
|
+
#### Vim/Neovim with coc.nvim Integration
|
|
71
|
+
|
|
72
|
+
##### Using coc-kanayago Extension (Recommended)
|
|
73
|
+
|
|
74
|
+
Install the official coc.nvim extension:
|
|
75
|
+
|
|
76
|
+
```vim
|
|
77
|
+
:CocInstall coc-kanayago
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Configuration:**
|
|
66
81
|
|
|
67
82
|
Add the following to your `coc-settings.json` (`:CocConfig` in Vim):
|
|
68
83
|
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"coc-kanayago.enable": true,
|
|
87
|
+
"coc-kanayago.command": "kanayago"
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Diagnostic Navigation:**
|
|
92
|
+
|
|
93
|
+
The extension supports standard coc.nvim diagnostic keybindings:
|
|
94
|
+
- Next diagnostic: `<space>dn`
|
|
95
|
+
- Previous diagnostic: `<space>dp`
|
|
96
|
+
- Show diagnostic info: `<space>di`
|
|
97
|
+
|
|
98
|
+
See [coc-kanayago](https://github.com/S-H-GAMELINKS/coc-kanayago) for more details.
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
##### Manual LSP Configuration
|
|
103
|
+
|
|
104
|
+
Alternatively, you can configure the LSP server manually in your `coc-settings.json`:
|
|
105
|
+
|
|
69
106
|
```json
|
|
70
107
|
{
|
|
71
108
|
"languageserver": {
|
|
@@ -81,6 +118,80 @@ Add the following to your `coc-settings.json` (`:CocConfig` in Vim):
|
|
|
81
118
|
|
|
82
119
|
Now Vim/Neovim with coc.nvim will show syntax errors in real-time as you edit Ruby files.
|
|
83
120
|
|
|
121
|
+
#### Emacs Integration
|
|
122
|
+
|
|
123
|
+
If you're using Emacs with lsp-mode, add the following configuration to your `init.el`:
|
|
124
|
+
|
|
125
|
+
```elisp
|
|
126
|
+
(require 'lsp-mode)
|
|
127
|
+
|
|
128
|
+
;; Register Kanayago LSP server
|
|
129
|
+
(lsp-register-client
|
|
130
|
+
(make-lsp-client
|
|
131
|
+
:new-connection (lsp-stdio-connection '("kanayago" "--lsp"))
|
|
132
|
+
:major-modes '(ruby-mode enh-ruby-mode)
|
|
133
|
+
:server-id 'kanayago-lsp
|
|
134
|
+
:priority 10))
|
|
135
|
+
|
|
136
|
+
;; Enable lsp-mode for Ruby files
|
|
137
|
+
(add-hook 'ruby-mode-hook #'lsp-deferred)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Kanayago will automatically check your Ruby code for syntax errors and display diagnostics in real-time.
|
|
141
|
+
|
|
142
|
+
#### Helix Integration
|
|
143
|
+
|
|
144
|
+
Add the following configuration to your `~/.config/helix/languages.toml`:
|
|
145
|
+
|
|
146
|
+
```toml
|
|
147
|
+
[[language]]
|
|
148
|
+
name = "ruby"
|
|
149
|
+
language-servers = ["kanayago"]
|
|
150
|
+
|
|
151
|
+
[language-server.kanayago]
|
|
152
|
+
command = "kanayago"
|
|
153
|
+
args = ["--lsp"]
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
If you already have a Ruby language configuration, you can add `"kanayago"` to your existing language-servers array:
|
|
157
|
+
|
|
158
|
+
```toml
|
|
159
|
+
[[language]]
|
|
160
|
+
name = "ruby"
|
|
161
|
+
language-servers = ["kanayago", "solargraph"] # Use alongside other LSPs
|
|
162
|
+
|
|
163
|
+
[language-server.kanayago]
|
|
164
|
+
command = "kanayago"
|
|
165
|
+
args = ["--lsp"]
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Now Helix will show syntax errors in real-time as you edit Ruby files.
|
|
169
|
+
|
|
170
|
+
#### Zed Integration
|
|
171
|
+
|
|
172
|
+
Install the official Zed extension from the marketplace:
|
|
173
|
+
|
|
174
|
+
1. Open Zed and go to Extensions (`cmd/ctrl + shift + x`)
|
|
175
|
+
2. Search for "Kanayago"
|
|
176
|
+
3. Click Install
|
|
177
|
+
|
|
178
|
+
**Manual Installation:**
|
|
179
|
+
|
|
180
|
+
If you prefer to install manually or for development purposes:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
git clone https://github.com/S-H-GAMELINKS/zed-kanayago.git
|
|
184
|
+
cd zed-kanayago
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Then follow the [Zed extension development guide](https://zed.dev/docs/extensions) for installation.
|
|
188
|
+
|
|
189
|
+
**Requirements:**
|
|
190
|
+
- Kanayago must be installed and available in your PATH
|
|
191
|
+
- Zed will automatically start the LSP server when opening Ruby files
|
|
192
|
+
|
|
193
|
+
See [zed-kanayago](https://github.com/S-H-GAMELINKS/zed-kanayago) for more details.
|
|
194
|
+
|
|
84
195
|
### Command Line Interface
|
|
85
196
|
|
|
86
197
|
Kanayago provides a CLI for syntax checking:
|
data/ext/kanayago/kanayago.c
CHANGED
|
@@ -520,6 +520,9 @@ kanayago_parse(VALUE self, VALUE source)
|
|
|
520
520
|
// Enable error tolerant parser
|
|
521
521
|
rb_ruby_parser_error_tolerant(parser_params);
|
|
522
522
|
|
|
523
|
+
// Enable script_lines to get source lines from AST
|
|
524
|
+
rb_ruby_parser_set_script_lines(parser_params);
|
|
525
|
+
|
|
523
526
|
VALUE vast = rb_parser_compile_string(vparser, "main", source, 0);
|
|
524
527
|
|
|
525
528
|
rb_ast_t *ast = rb_ruby_ast_data_get(vast);
|
|
@@ -528,9 +531,13 @@ kanayago_parse(VALUE self, VALUE source)
|
|
|
528
531
|
// Get error_buffer from parser_params using accessor function
|
|
529
532
|
VALUE error_buffer = rb_ruby_parser_error_buffer_get(parser_params);
|
|
530
533
|
|
|
534
|
+
// Get script_lines from AST and convert to Ruby array
|
|
535
|
+
VALUE script_lines = rb_parser_build_script_lines_from(ast->body.script_lines);
|
|
536
|
+
|
|
531
537
|
VALUE result = rb_hash_new();
|
|
532
538
|
rb_hash_aset(result, ID2SYM(rb_intern("ast")), ast_node);
|
|
533
539
|
rb_hash_aset(result, ID2SYM(rb_intern("error")), error_buffer);
|
|
540
|
+
rb_hash_aset(result, ID2SYM(rb_intern("script_lines")), script_lines);
|
|
534
541
|
|
|
535
542
|
return result;
|
|
536
543
|
}
|
data/ext/kanayago/kanayago.h
CHANGED
|
@@ -13,6 +13,8 @@ VALUE rb_node_imaginary_literal_val(const NODE *);
|
|
|
13
13
|
VALUE rb_node_str_string_val(const NODE *);
|
|
14
14
|
VALUE rb_node_sym_string_val(const NODE *);
|
|
15
15
|
VALUE rb_ruby_parser_error_buffer_get(rb_parser_t *);
|
|
16
|
+
void rb_ruby_parser_set_script_lines(rb_parser_t *);
|
|
17
|
+
VALUE rb_parser_build_script_lines_from(rb_parser_ary_t *);
|
|
16
18
|
|
|
17
19
|
// Add extern for Kanayago
|
|
18
20
|
extern const rb_data_type_t ruby_parser_data_type;
|
|
Binary file
|
|
Binary file
|
|
@@ -14,7 +14,7 @@ module Kanayago
|
|
|
14
14
|
if result.invalid?
|
|
15
15
|
# Extract error information from SyntaxError
|
|
16
16
|
error = result.error
|
|
17
|
-
diagnostic = create_diagnostic(error)
|
|
17
|
+
diagnostic = create_diagnostic(error, result.script_lines)
|
|
18
18
|
diagnostics << diagnostic
|
|
19
19
|
end
|
|
20
20
|
|
|
@@ -23,36 +23,41 @@ module Kanayago
|
|
|
23
23
|
|
|
24
24
|
private
|
|
25
25
|
|
|
26
|
-
def create_diagnostic(error)
|
|
26
|
+
def create_diagnostic(error, script_lines)
|
|
27
27
|
# Try to extract line and column from error message
|
|
28
28
|
# SyntaxError message format: "syntax error, unexpected ..."
|
|
29
29
|
# or with location: "(eval):2: syntax error, unexpected ..."
|
|
30
|
-
range = extract_range_from_error(error)
|
|
30
|
+
range = extract_range_from_error(error, script_lines)
|
|
31
31
|
|
|
32
32
|
{
|
|
33
33
|
range: range,
|
|
34
34
|
severity: LanguageServer::Protocol::Constant::DiagnosticSeverity::ERROR,
|
|
35
35
|
source: 'Kanayago',
|
|
36
|
-
message: error.message
|
|
36
|
+
message: error.message.sub(/main:\d+:\s*/, '')
|
|
37
37
|
}
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def extract_range_from_error(error)
|
|
40
|
+
def extract_range_from_error(error, script_lines)
|
|
41
41
|
# Try to extract line number from error message
|
|
42
|
-
# Format: "(eval):LINE: message" or just "message"
|
|
42
|
+
# Format: "main:LINE: message" or "(eval):LINE: message" or just "message"
|
|
43
43
|
message = error.message
|
|
44
44
|
|
|
45
|
-
if message =~
|
|
46
|
-
line = ::Regexp.last_match(1).to_i
|
|
45
|
+
if message =~ /(?:main|\(eval\)):(\d+):/
|
|
46
|
+
line = ::Regexp.last_match(1).to_i # Already 0-based or use as-is
|
|
47
|
+
|
|
48
|
+
end_character = script_lines[line].chomp.length
|
|
49
|
+
|
|
47
50
|
{
|
|
48
51
|
start: { line: line, character: 0 },
|
|
49
|
-
end: { line: line, character:
|
|
52
|
+
end: { line: line, character: end_character }
|
|
50
53
|
}
|
|
51
54
|
else
|
|
52
55
|
# Default to line 0 if we can't extract line number
|
|
56
|
+
end_character = script_lines[0].chomp.length
|
|
57
|
+
|
|
53
58
|
{
|
|
54
59
|
start: { line: 0, character: 0 },
|
|
55
|
-
end: { line: 0, character:
|
|
60
|
+
end: { line: 0, character: end_character }
|
|
56
61
|
}
|
|
57
62
|
end
|
|
58
63
|
end
|
data/lib/kanayago/version.rb
CHANGED
data/lib/kanayago.rb
CHANGED
|
@@ -15,11 +15,12 @@ require_relative 'kanayago/constant_node'
|
|
|
15
15
|
# Parse Ruby code with Ruby's Parser(Universal Parser)
|
|
16
16
|
module Kanayago
|
|
17
17
|
class ParseResult
|
|
18
|
-
attr_reader :ast, :error
|
|
18
|
+
attr_reader :ast, :error, :script_lines
|
|
19
19
|
|
|
20
|
-
def initialize(ast, error)
|
|
20
|
+
def initialize(ast, error, script_lines)
|
|
21
21
|
@ast = ast
|
|
22
22
|
@error = error
|
|
23
|
+
@script_lines = script_lines
|
|
23
24
|
end
|
|
24
25
|
|
|
25
26
|
def invalid?
|
|
@@ -32,8 +33,8 @@ module Kanayago
|
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
def self.parse(source)
|
|
35
|
-
kanayago_parse(source) in { ast:, error: }
|
|
36
|
+
kanayago_parse(source) in { ast:, error:, script_lines: }
|
|
36
37
|
|
|
37
|
-
ParseResult.new(ast, error)
|
|
38
|
+
ParseResult.new(ast, error, script_lines)
|
|
38
39
|
end
|
|
39
40
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kanayago
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- S-H-GAMELINKS
|
|
@@ -55,6 +55,8 @@ files:
|
|
|
55
55
|
- ext/kanayago/string_node.h
|
|
56
56
|
- ext/kanayago/variable_node.c
|
|
57
57
|
- ext/kanayago/variable_node.h
|
|
58
|
+
- images/coc-kanayago-demo.png
|
|
59
|
+
- images/vscode-kanayago-demo.png
|
|
58
60
|
- lib/kanayago.rb
|
|
59
61
|
- lib/kanayago/call_node.rb
|
|
60
62
|
- lib/kanayago/cli.rb
|