A simple, fast, and modern linter for Karate API testing framework .feature files.
This plugin provides real-time linting for common errors and style issues in Karate feature files directly within Vim/Neovim.
- Modern Real-time Diagnostics: Uses Vim's built-in
textpropandsignsfor stable, non-intrusive feedback as you type. Errors and warnings are marked with gutter icons (>>andW>) and highlighted directly in your code. - Comprehensive Rules: Checks for syntax errors, style conventions, and logical problems.
- Finds Unused Variables: Warns about variables defined with
* defthat are never used in the file. - High Performance: Uses
ripgrepandawkfor fast, whole-file analysis when available, with a seamless fallback to pure Vimscript otherwise. - Auto-formatting: Optionally formats the file on save (
gg=G), if no errors are detected. - Configurable: Most rules and their severity levels can be easily customized.
Install using vim-plug:
" Make sure you have ripgrep and awk for the best performance
Plug 'Propaz/karate_linter'Then run :PlugInstall in Vim.
You can customize the linter by adding let g:variable_name = value to your vimrc or init.vim.
g:karate_linter_auto_format_on_save: Enable auto-formatting on save.- Default:
1(enabled)
- Default:
For each rule, you can enable/disable it (_rule) and set its severity level (_level).
Severity can be KarateLintError (uses Error highlight group) or KarateLintWarn (uses Todo highlight group).
-
Max line length:
g:karate_linter_max_line_length: Max characters per line. Set to0to disable. Note: this check is byte-based for maximum compatibility.g:karate_linter_max_line_length_level: Severity.- Defaults:
120,'KarateLintWarn'
-
Tabs: Disallow tab characters.
g:karate_linter_tabs_rule:1or0.g:karate_linter_tabs_level: Severity.- Defaults:
1,'KarateLintError'
-
Trailing whitespace:
g:karate_linter_trailing_space_rule:1or0.g:karate_linter_trailing_space_level: Severity.- Defaults:
1,'KarateLintError'
-
Use
Andinstead ofBut:g:karate_linter_and_but_rule:1or0.g:karate_linter_and_but_level: Severity.- Defaults:
1,'KarateLintWarn'
-
Space after Gherkin keyword: (
Given,When, etc.)g:karate_linter_no_space_after_keyword_rule:1or0.g:karate_linter_no_space_after_keyword_level: Severity.- Defaults:
1,'KarateLintError'
-
Scenario OutlinewithoutExamples:g:karate_linter_missing_examples_rule:1or0.g:karate_linter_missing_examples_level: Severity.- Defaults:
1,'KarateLintError'
-
ExampleswithoutScenario Outline:g:karate_linter_orphaned_examples_rule:1or0.g:karate_linter_orphaned_examples_level: Severity.- Defaults:
1,'KarateLintError'
-
callreadinstead ofcall read:g:karate_linter_call_read_space_rule:1or0.g:karate_linter_call_read_space_level: Severity.- Defaults:
1,'KarateLintError'
-
Unused variable: (
* def myVar = ...)g:karate_linter_unused_variable_rule:1or0.g:karate_linter_unused_variable_level: Severity.- Defaults:
1,'KarateLintWarn'
-
Unclosed
read()function:g:karate_linter_unclosed_read_rule:1or0.g:karate_linter_unclosed_read_level: Severity.- Defaults:
1,'KarateLintError'
-
Unclosed docstring (
"""):g:karate_linter_unclosed_docstring_rule:1or0.g:karate_linter_unclosed_docstring_level: Severity.- Defaults:
1,'KarateLintError'
-
Missing
Featureblock:g:karate_linter_missing_feature_rule:1or0.g:karate_linter_missing_feature_level: Severity.- Defaults:
1,'KarateLintWarn'
-
Missing
Scenarioblock:g:karate_linter_missing_scenario_rule:1or0.g:karate_linter_missing_scenario_level: Severity.- Defaults:
1,'KarateLintWarn'
-
Missing
Backgroundblock:g:karate_linter_missing_background_rule:1or0.g:karate_linter_missing_background_level: Severity.- Defaults:
1,'KarateLintWarn'
When an issue is detected, the line will be highlighted, and a sign will appear in the gutter (the column with line numbers).
>>for errorsW>for warnings
You can also run :KarateLintCheck to get a full report in the location list (:lopen).
Consider a .feature file with a Scenario Outline missing an Examples block. The linter would highlight the problematic line and place an error icon (>>) in the gutter next to it.
The linter uses standard Vim highlight groups for errors and warnings:
KarateLintErrorlinks to theErrorhighlight group.KarateLintWarnlinks to theTodohighlight group.
The signs use these same highlight groups for their colors. You can customize these in your vimrc to match your preferred color scheme. For example:
" Customize error highlights
highlight Error ctermfg=white ctermbg=red guifg=white guibg=red
" Customize warning highlights
highlight Todo ctermfg=black ctermbg=yellow guifg=black guibg=yellowYou can also change the signs themselves:
sign define KarateLintError text=E!
sign define KarateLintWarn text=W!Contributions are welcome! If you find a bug, have a feature request, or want to contribute code, please feel free to:
- Open an issue: Report bugs or suggest new features on the GitHub Issues page.
- Submit a pull request: If you've implemented a fix or a new feature, please open a pull request. Ensure your code adheres to the existing style and conventions.
This project is licensed under the MIT License - see the LICENSE.md file for details.