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.
Installation
Install the gem:
gem install vinter
Configure
Vinter will read config files on the following priority order
- User config (
~/.vinter) - Project config (
path/to/proj/.vinter)
ignore_rules:
- missing-vim9script-declaration
- prefer-def-over-function
Usage
Command Line
Updated vim linter for legacy and vim9script
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