A TOML Linter. Checks for basic syntactic errors in any TOML file.
$ pip install tomllintUsage is self explanatory, simply name the files to lint, or use - to indicate that it should read
from stdin.
usage: tomllint [-h] toml_file [toml_file ...]
positional arguments:
toml_file TOML filenames or "-" for stdin
options:
-h, --help show this help message and exit
To register tomllint with nvim-lint, you'd add
something like this to your ~/.config/nvim/init.lua or other imported file.
require("lint").linters_by_ft.toml = { "tomllint" }
local function parse_tomllint_output(output, bufnr, _linter_cwd)
local diagnostics = {}
for line in output:gmatch("[^\r\n]+") do
local _, lnum, col, description = line:match("(.+):(%d+):(%d+): error: (.+)")
if lnum and description then
table.insert(diagnostics, {
bufnr = bufnr,
lnum = tonumber(lnum) - 1,
col = tonumber(col) - 1,
end_lnum = tonumber(lnum) - 1,
end_col = tonumber(col),
severity = vim.diagnostic.severity.ERROR,
message = description,
})
end
end
return diagnostics
end
require("lint").linters.tomllint = {
cmd = "tomllint",
stdin = true,
append_fname = false,
args = { "-" },
stream = "stderr",
ignore_exitcode = false,
env = nil,
parser = parse_tomllint_output,
}Pickls is a unified LSP that integrates command-line linters
and formatters with editors like Neovim and Zed. Add the following to your
~/.config/pickls/pickls.yaml:
languages:
toml:
linters:
- program: tomllint
args: ["-"]
pattern: '(.*):(\d+):(\d+): error: (.*)'
line_match: 2
start_col_match: 3
description_match: 4
use_stderr: true
use_stdin: truepre-commit is a framework for managing and maintaining multi-language
pre-commit hooks. To use tomllint to check your files when doing a
git commit, add this to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/wbbradley/tomllint
rev: v0.3.2
hooks:
- id: tomllint