mirror of
https://github.com/pnx/tree-sitter-dotenv
synced 2026-08-16 01:08:13 +02:00
Compare commits
3 commits
1f5baa64dd
...
c0570dec1d
| Author | SHA1 | Date | |
|---|---|---|---|
| c0570dec1d | |||
| 930ba7b37c | |||
| 72ea51c5a0 |
11 changed files with 146 additions and 7 deletions
|
|
@ -1,7 +1,7 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
|
||||
project(tree-sitter-dotenv
|
||||
VERSION "1.0.0"
|
||||
VERSION "1.0.1"
|
||||
DESCRIPTION "Dotenv grammar for tree-sitter"
|
||||
HOMEPAGE_URL "https://github.com/pnx/tree-sitter-dotenv"
|
||||
LANGUAGES C)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "tree-sitter-dotenv"
|
||||
description = "Dotenv grammar for tree-sitter"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
keywords = ["incremental", "parsing", "tree-sitter", "dotenv"]
|
||||
|
|
|
|||
2
Makefile
generated
2
Makefile
generated
|
|
@ -2,7 +2,7 @@ ifeq ($(OS),Windows_NT)
|
|||
$(error Windows is not supported)
|
||||
endif
|
||||
|
||||
VERSION := 1.0.0
|
||||
VERSION := 1.0.1
|
||||
|
||||
LANGUAGE_NAME := tree-sitter-dotenv
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
To use this parser in neovim, configure [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||
|
||||
For minimal, ready-to-run local test configs (both `main` and legacy `master`), see
|
||||
[test/nvim/README.md](../test/nvim/README.md).
|
||||
|
||||
### nvim-treesitter `main` (new API)
|
||||
|
||||
Use this if you are on the rewritten `main` branch (Neovim 0.12+):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tree-sitter-dotenv",
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"description": "Dotenv grammar for tree-sitter",
|
||||
"repository": "github:pnx/tree-sitter-dotenv",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|||
[project]
|
||||
name = "tree-sitter-dotenv"
|
||||
description = "Dotenv grammar for tree-sitter"
|
||||
version = "1.0.0"
|
||||
version = "1.0.1"
|
||||
keywords = ["incremental", "parsing", "tree-sitter", "dotenv"]
|
||||
classifiers = [
|
||||
"Intended Audience :: Developers",
|
||||
|
|
|
|||
2
src/parser.c
generated
2
src/parser.c
generated
|
|
@ -1329,7 +1329,7 @@ TS_PUBLIC const TSLanguage *tree_sitter_dotenv(void) {
|
|||
.metadata = {
|
||||
.major_version = 1,
|
||||
.minor_version = 0,
|
||||
.patch_version = 0,
|
||||
.patch_version = 1,
|
||||
},
|
||||
};
|
||||
return &language;
|
||||
|
|
|
|||
43
test/nvim/README.md
Normal file
43
test/nvim/README.md
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
# Neovim test configs
|
||||
|
||||
This directory contains minimal Neovim configs for testing `tree-sitter-dotenv` with both
|
||||
legacy and rewritten `nvim-treesitter`.
|
||||
|
||||
## Files
|
||||
|
||||
- `init-main.lua` → `nvim-treesitter` `main` (new API)
|
||||
- `init-master.lua` → `nvim-treesitter` `master` (legacy API)
|
||||
|
||||
## Run
|
||||
|
||||
From the repository root, use isolated app names so test state does not mix:
|
||||
|
||||
```bash
|
||||
NVIM_APPNAME=ts-dotenv-main nvim -u "$(pwd)/test/nvim/init-main.lua"
|
||||
NVIM_APPNAME=ts-dotenv-master nvim -u "$(pwd)/test/nvim/init-master.lua"
|
||||
```
|
||||
|
||||
## Install parser
|
||||
|
||||
Run:
|
||||
|
||||
```vim
|
||||
:TSUpdate
|
||||
:TSInstall dotenv
|
||||
```
|
||||
|
||||
## Verify
|
||||
|
||||
Open a `.env` file and check:
|
||||
|
||||
```vim
|
||||
:echo &filetype
|
||||
```
|
||||
|
||||
Expected output: `dotenv`.
|
||||
|
||||
### Show the syntax tree
|
||||
|
||||
```vim
|
||||
:InspectTree
|
||||
```
|
||||
50
test/nvim/init-main.lua
Normal file
50
test/nvim/init-main.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
local script_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h")
|
||||
local repo_root = vim.fn.fnamemodify(vim.fn.fnamemodify(script_dir, ":h"), ":h")
|
||||
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable",
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "main",
|
||||
lazy = false,
|
||||
config = function (_, opts)
|
||||
require("nvim-treesitter").setup({})
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "TSUpdate",
|
||||
callback = function()
|
||||
require("nvim-treesitter.parsers").dotenv = {
|
||||
install_info = {
|
||||
path = repo_root,
|
||||
},
|
||||
}
|
||||
end,
|
||||
})
|
||||
|
||||
vim.filetype.add({
|
||||
filename = { [".env"] = "dotenv" },
|
||||
pattern = { [".env%..+"] = "dotenv" },
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "dotenv",
|
||||
callback = function()
|
||||
pcall(vim.treesitter.start)
|
||||
end,
|
||||
})
|
||||
end
|
||||
},
|
||||
})
|
||||
|
||||
43
test/nvim/init-master.lua
Normal file
43
test/nvim/init-master.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
local script_dir = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h")
|
||||
local repo_root = vim.fn.fnamemodify(vim.fn.fnamemodify(script_dir, ":h"), ":h")
|
||||
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
"git",
|
||||
"clone",
|
||||
"--filter=blob:none",
|
||||
"https://github.com/folke/lazy.nvim.git",
|
||||
"--branch=stable",
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
branch = "master",
|
||||
lazy = false,
|
||||
build = ":TSUpdate",
|
||||
opts = {
|
||||
highlight = { enable = true },
|
||||
},
|
||||
config = function(_, opts)
|
||||
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
parser_config.dotenv = {
|
||||
install_info = {
|
||||
url = repo_root,
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
},
|
||||
filetype = "dotenv",
|
||||
}
|
||||
|
||||
vim.filetype.add({
|
||||
filename = { [".env"] = "dotenv" },
|
||||
pattern = { [".env%..+"] = "dotenv" },
|
||||
})
|
||||
end
|
||||
},
|
||||
})
|
||||
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
}
|
||||
],
|
||||
"metadata": {
|
||||
"version": "1.0.0",
|
||||
"version": "1.0.1",
|
||||
"license": "MIT",
|
||||
"description": "Dotenv grammar for tree-sitter",
|
||||
"authors": [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue