Skip to content

DanBradbury/vinter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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:

  1. missing-vim9script-declaration: Checks if Vim9 script files start with the required vim9script declaration
  2. prefer-def-over-function: Encourages using def instead of function in Vim9 scripts
  3. missing-type-annotation: Identifies variable declarations without type annotations
  4. 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

  1. Fork the repository
  2. Create a feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

About

vim9script linter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages