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.
Install the gem:
gem install vinter
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
Updated vim linter for legacy and vim9script
vinter path/to/your/script.vim
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
The linter includes several built-in rules:
- missing-vim9script-declaration: Checks if Vim9 script files start with the required
vim9script
declaration - prefer-def-over-function: Encourages using
def
instead offunction
in Vim9 scripts - missing-type-annotation: Identifies variable declarations without type annotations
- missing-return-type: Identifies functions without return type annotations
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)
- 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