Skip to main content

A simple TOML linter.

Project description

tomllint

A TOML Linter. Checks for basic syntactic errors in any TOML file.

Installation

$ pip install tomllint

Usage

Usage 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

Neovim Integration

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 Integration

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: true

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomllint-0.3.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tomllint-0.3.2-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file tomllint-0.3.2.tar.gz.

File metadata

  • Download URL: tomllint-0.3.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tomllint-0.3.2.tar.gz
Algorithm Hash digest
SHA256 9dd525378654b4f88b55ffb89381823b93e08625f4d037b86a7f7fb3dc82c3b8
MD5 01b8b7434a4926301931efb3fded3396
BLAKE2b-256 f46a0d58a8f535c70d5cb562b716f139afe09ba466aaaf2e632755e93e6124a3

See more details on using hashes here.

File details

Details for the file tomllint-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: tomllint-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tomllint-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c36e8c848a376ecffc1560e582898b831bfe71120f7c6529c6ec74e4cb1d6a19
MD5 bf54402ffa8521e61c567eb1e7ff8da0
BLAKE2b-256 83e7121442ce80308f5c038180bcdc0d789f823eb05effd9c32523c506afaf27

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page