vinter 0.2.0 → 0.4.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/LICENSE +13 -0
- data/README.md +12 -12
- data/bin/vinter +0 -0
- data/lib/vinter/cli.rb +49 -21
- data/lib/vinter/lexer.rb +468 -36
- data/lib/vinter/linter.rb +28 -3
- data/lib/vinter/parser.rb +3808 -577
- data/lib/vinter.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6f99b1ca16b7bbca35229a549ceed21f3cdf9b8bc86a3fedff9b978b18717de
|
4
|
+
data.tar.gz: 2aa4e1df5ae4fc08e78c06cf2107c7192099326b073bf45e45a9532b3fb5d0c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d739b01780f6ce12654b09b701f343e850bd2eb750e705ca608f793e7e9cfef26b226927157ff595dcbb3f62ddbbd4f530439074ef9fdbc9a2cfd075dd78a3da
|
7
|
+
data.tar.gz: 7ec3181349383a4b9667aab046f56099d25f830a07aaa6a6135b8640a25d59e85c2191b3ffbecd263afe703f1f17a986f40f769e458bab532e70f837f9c9a029
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
2
|
+
Version 2, December 2004
|
3
|
+
|
4
|
+
Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
|
5
|
+
|
6
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
7
|
+
copies of this license document, and changing it is allowed as long
|
8
|
+
as the name is changed.
|
9
|
+
|
10
|
+
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
11
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
12
|
+
|
13
|
+
0. You just DO WHAT THE FUCK YOU WANT TO.
|
data/README.md
CHANGED
@@ -2,13 +2,6 @@
|
|
2
2
|
|
3
3
|
A Ruby gem that provides linting capabilities for Vim9 script files. This linter helps identify syntax errors and enforce best practices for for Vim9 script.
|
4
4
|
|
5
|
-
## Features
|
6
|
-
|
7
|
-
- Lexical analysis of Vim9 script syntax
|
8
|
-
- Parsing of Vim9 script constructs
|
9
|
-
- Detection of common errors and code smells
|
10
|
-
- Command-line interface for easy integration with editors
|
11
|
-
|
12
5
|
## Installation
|
13
6
|
|
14
7
|
Install the gem:
|
@@ -17,11 +10,22 @@ Install the gem:
|
|
17
10
|
gem install vinter
|
18
11
|
```
|
19
12
|
|
13
|
+
## Configure
|
14
|
+
Vinter will read config files on the following priority order
|
15
|
+
- User config (`~/.vinter`)
|
16
|
+
- Project config (`path/to/proj/.vinter`)
|
17
|
+
|
18
|
+
```yaml
|
19
|
+
ignore_rules:
|
20
|
+
- missing-vim9script-declaration
|
21
|
+
- prefer-def-over-function
|
22
|
+
```
|
23
|
+
|
20
24
|
## Usage
|
21
25
|
|
22
26
|
### Command Line
|
23
27
|
|
24
|
-
|
28
|
+
Updated vim linter for legacy and vim9script
|
25
29
|
|
26
30
|
```bash
|
27
31
|
vinter path/to/your/script.vim
|
@@ -89,7 +93,3 @@ issues = linter.lint(content)
|
|
89
93
|
3. Commit your changes: `git commit -am 'Add some feature'`
|
90
94
|
4. Push to the branch: `git push origin my-new-feature`
|
91
95
|
5. Submit a pull request
|
92
|
-
|
93
|
-
## License
|
94
|
-
|
95
|
-
This project is licensed under the MIT License - see the LICENSE file for details.
|
data/bin/vinter
CHANGED
File without changes
|
data/lib/vinter/cli.rb
CHANGED
@@ -6,42 +6,70 @@ module Vinter
|
|
6
6
|
|
7
7
|
def run(args)
|
8
8
|
if args.empty?
|
9
|
-
puts "Usage:
|
9
|
+
puts "Usage: vinter [file.vim|directory]"
|
10
10
|
return 1
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
target_path = args[0]
|
14
14
|
|
15
|
-
unless File.exist?(
|
16
|
-
puts "Error: File not found: #{
|
15
|
+
unless File.exist?(target_path)
|
16
|
+
puts "Error: File or directory not found: #{target_path}"
|
17
17
|
return 1
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
vim_files = if File.directory?(target_path)
|
21
|
+
find_vim_files(target_path)
|
22
|
+
else
|
23
|
+
[target_path]
|
24
|
+
end
|
22
25
|
|
23
|
-
if
|
24
|
-
puts "No
|
26
|
+
if vim_files.empty?
|
27
|
+
puts "No .vim files found in #{target_path}"
|
25
28
|
return 0
|
26
|
-
|
27
|
-
|
29
|
+
end
|
30
|
+
|
31
|
+
total_issues = 0
|
32
|
+
error_count = 0
|
33
|
+
|
34
|
+
vim_files.each do |file_path|
|
35
|
+
content = File.read(file_path)
|
36
|
+
issues = @linter.lint(content)
|
37
|
+
total_issues += issues.length
|
38
|
+
|
39
|
+
if issues.empty?
|
40
|
+
puts "No issues found in #{file_path}" if vim_files.length == 1
|
41
|
+
else
|
42
|
+
puts "Found #{issues.length} issues in #{file_path}:" if vim_files.length > 1
|
43
|
+
|
44
|
+
issues.each do |issue|
|
45
|
+
type_str = case issue[:type]
|
46
|
+
when :error then "ERROR"
|
47
|
+
when :warning then "WARNING"
|
48
|
+
when :rule then "RULE(#{issue[:rule]})"
|
49
|
+
else "UNKNOWN"
|
50
|
+
end
|
28
51
|
|
29
|
-
|
30
|
-
|
31
|
-
when :error then "ERROR"
|
32
|
-
when :warning then "WARNING"
|
33
|
-
when :rule then "RULE(#{issue[:rule]})"
|
34
|
-
else "UNKNOWN"
|
35
|
-
end
|
52
|
+
line = issue[:line] || 1
|
53
|
+
column = issue[:column] || 1
|
36
54
|
|
37
|
-
|
38
|
-
|
55
|
+
puts "#{file_path}:#{line}:#{column}: #{type_str}: #{issue[:message]}"
|
56
|
+
end
|
39
57
|
|
40
|
-
|
58
|
+
error_count += 1 if issues.any? { |i| i[:type] == :error }
|
41
59
|
end
|
60
|
+
end
|
42
61
|
|
43
|
-
|
62
|
+
if vim_files.length > 1
|
63
|
+
puts "\nProcessed #{vim_files.length} files, found #{total_issues} total issues"
|
44
64
|
end
|
65
|
+
|
66
|
+
return error_count > 0 ? 1 : 0
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def find_vim_files(directory)
|
72
|
+
Dir.glob(File.join(directory, "**", "*.vim")).sort
|
45
73
|
end
|
46
74
|
end
|
47
75
|
end
|