Vinter
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.
Features
- Lexical analysis of Vim9 script syntax
- Parsing of Vim9 script constructs
- Detection of common errors and code smells
- Command-line interface for easy integration with editors
Installation
Install the gem:
gem install vinter
Usage
Command Line
Lint a Vim9 script file:
vinter path/to/your/script.vim
Ruby API
require 'vinter'
content = File.read('path/to/your/script.vim')
linter = Vinter::Linter.new
issues = linter.lint(content)
issues.each do |issue|
puts "#{issue[:type]}: #{issue[:message]} at line #{issue[:line]}, column #{issue[:column]}"
end
Supported Rules
The linter includes several built-in rules:
- missing-vim9script-declaration: Checks if Vim9 script files start with the required
vim9scriptdeclaration - prefer-def-over-function: Encourages using
definstead offunctionin Vim9 scripts - missing-type-annotation: Identifies variable declarations without type annotations
- missing-return-type: Identifies functions without return type annotations
Adding Custom Rules
You can extend the linter with your own custom rules:
linter = Vinter::Linter.new
# Define a custom rule
custom_rule = Vinter::Rule.new(
"my-custom-rule",
"Description of what the rule checks"
) do |ast|
issues = []
# Analyze the AST and identify issues
# ...
issues
end
# Register the custom rule
linter.register_rule(custom_rule)
# Run the linter with your custom rule
issues = linter.lint(content)
Vim9 Script Resources
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b my-new-feature - Commit your changes:
git commit -am 'Add some feature' - Push to the branch:
git push origin my-new-feature - Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.