tree-sitter-dotenv

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2026 License: MIT

README

tree-sitter-dotenv

tree-sitter grammar for dotenv

Installation

Neovim

To use this parser in neovim, you need to configure nvim-treesitter

Add this to nvim-treesitter's config function:

config = function(_, opts)
    local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
    
    -- Tell treesitter where dotenv parser is located
    parser_config.dotenv = {
        install_info = {
            url = "https://github.com/pnx/tree-sitter-dotenv",
            branch = "main",
            files = { "src/parser.c", "src/scanner.c" },
        },
        filetype = "dotenv",
    }

    -- Associate .env files as "dotenv"
    vim.filetype.add({
        pattern = {
            ['%.env'] = 'dotenv',
            ['%.env%..+'] = 'dotenv',
        },
    })
end
Syntax highlighting

In order for neovim to know how to color the text, a highlights.scm file is needed. Copy highlights.scm from this repo to your nvim config under queries/dotenv/highlights.scm

Author

Henrik Hautakoski henrik.hautakoski@gmail.com

Directories

Path Synopsis
bindings
go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL