Awesome
linters
Linters for https://github.com/rxi/lite
Available linters
- linter_ameba - Uses ameba for crystal files
- linter_dscanner - Uses dscanner for d files
- linter_eslint - Uses eslint for javascript files
- linter_flake8 - Uses flake8 for python files
- linter_gocompiler - Uses the go vet command to display compilation errors in golang files
- linter_golint - Uses golint for golang files
- linter_jshint - Uses jshint linter for javascript files
- linter_luacheck - Uses luacheck for lua files
- linter_teal - Uses tl check for teal files
- linter_nim - Uses nim check for nim files
- linter_php - Uses built-in php binary -l flag for php files
- linter_pylint - Uses pylint for python files
- linter_revive - Uses revive for golang files (golint modern alt)
- linter_selene - Uses selene for lua files
- linter_shellcheck - Uses shellcheck linter for shell script files
- linter_standard - Uses standard linter for javascript files
- linter_zig - Uses
zig ast-check
for linting zig files
Demo
Example of linting a file.
Instructions
- To install any linter first copy the
linter.lua
file to the folderdata/plugins/
of the lite editor which has the needed foundation for the linters. - Copy the specific linters you want to use to the same folder.
- Make sure you have the commands needed for each linter to use them.
- If you want to configure options in some of the linters you can edit your
data/user/init.lua
local config = require "core.config"
local insert = table.insert
-- [[ Each linter will load the arguments from a table in config.<linter_name>_args ]]
-- Mark global as known to the linter
insert(config.luacheck_args, "--new-globals=love")
-- Add error reporting in fuctions which exceed cyclomatic complexity
insert(config.luacheck_args, "--max-cyclomatic-complexity=4")
-- Add warnings if lines pass a maximum length
insert(config.luacheck_args, "--max-line-length=80")
Linter Fields
file_patterns {String} - List of patterns to match the files to which the linter is run.
warning_pattern String | Function - Matches the line, column and the description for each warning(In this order). If the matching is complex and cannot be addressed with a pattern directly a function can be used.
warning_pattern_order {line=Int, col=Int, message=Int} [optional] - Allows us to change what is expected from the pattern when the order of the elements in the warning is not line -> col -> message.
column_starts_at_zero Bool [optional] - Is useful for some linters which have the column number starting at zero instead of starting at one.
command String - Command that is run to execute the linter. It can receive a $FILENAME name in the middle of the command which will be replaced with the name of the file which is being edited when the linter is run.
deduplicate Bool [optional] - Prevent duplicated warnings. Only needed in specific cases because some linters work with whole packages instead of a specific file and report the same warning for the same file multiple times.
args {String} - Arguments to be passed to the linter in the command line call. Will replace the $ARGS in the command. Usually this table comes from config.<linter>_args. This is done so the user can add it's own specific configurations to the linter in his own user file.
expected_exitcodes {Int} - Exit codes expected when the linter doesn't crash so we can report when there is an unexpected crash.
Configurations
The base linter code also allows some configurations that apply to all linters.
You can set them in you user file - data/user/init.lua
.
The available configurations are:
- linter_box_line_limit - Number of columns in the warning box. (default: 80)
- linter_scan_interval - Seconds between checks for results in the linter file. (default: 0.1)
- warning_font - Font to be used inside the warning box. (default: style.font)
- linter_trigger - Select how the linter is activated. (default: "save", options: ["save", "keypress"])
Example configuration:
config.warning_font = renderer.font.load(EXEDIR .. "/data/fonts/monospace.ttf", 13.5 * SCALE)
config.linter_trigger = "keypress"