tree-sitter-muttrc 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cmake-format.yaml +2 -0
- package/.cmakelintrc +1 -0
- package/.github/FUNDING.yml +6 -0
- package/.github/workflows/main.yml +152 -0
- package/.gitlint +5 -0
- package/.pre-commit-config.yaml +112 -0
- package/.yamllint.yaml +8 -0
- package/CMakeLists.txt +38 -0
- package/Cargo.toml +26 -0
- package/README.md +83 -0
- package/binding.gyp +16 -0
- package/bindings/node/binding.cc +28 -0
- package/bindings/node/index.js +19 -0
- package/bindings/python/tree_sitter_muttrc/__init__.py +42 -0
- package/bindings/python/tree_sitter_muttrc/__main__.py +60 -0
- package/bindings/python/tree_sitter_muttrc/py.typed +0 -0
- package/bindings/rust/build.rs +40 -0
- package/bindings/rust/lib.rs +52 -0
- package/grammar.js +520 -0
- package/package.json +28 -0
- package/pyproject.toml +124 -0
- package/queries/highlights.scm +53 -0
- package/queries/injections.scm +8 -0
- package/requirements/colorize.txt +3 -0
- package/requirements/dev.txt +4 -0
- package/requirements.txt +3 -0
- package/scripts/build.sh +8 -0
- package/src/grammar.json +3905 -0
- package/src/node-types.json +7353 -0
- package/src/parser.c +20578 -0
- package/src/tree_sitter/parser.h +224 -0
- package/templates/class.txt +2 -0
- package/templates/def.txt +12 -0
- package/templates/noarg.txt +1 -0
- package/test/corpus/example.txt +82 -0
- package/tests/neomuttrc +20 -0
- package/tests/test___init__.py +22 -0
package/.cmakelintrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
filter=-whitespace/indent,-linelength,-readability/wonkycase
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
---
|
|
2
|
+
patreon: user?u=83975719
|
|
3
|
+
custom:
|
|
4
|
+
- "https://user-images.githubusercontent.com/32936898/199681341-1c5cfa61-4411-4b67-b268-7cd87c5867bb.png"
|
|
5
|
+
- "https://user-images.githubusercontent.com/32936898/199681363-1094a0be-85ca-49cf-a410-19b3d7965120.png"
|
|
6
|
+
- "https://user-images.githubusercontent.com/32936898/199681368-c34c2be7-e0d8-43ea-8c2c-d3e865da6aeb.png"
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
"on":
|
|
3
|
+
push:
|
|
4
|
+
paths-ignore:
|
|
5
|
+
- "**.md"
|
|
6
|
+
pull_request:
|
|
7
|
+
paths-ignore:
|
|
8
|
+
- "**.md"
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
# https://github.com/softprops/action-gh-release/issues/236
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
|
|
15
|
+
env:
|
|
16
|
+
CMAKE_GENERATOR: Ninja
|
|
17
|
+
PYTHONUTF8: "1"
|
|
18
|
+
python-version: 3.x
|
|
19
|
+
cache: pip
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
test:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v4
|
|
26
|
+
- uses: actions/setup-node@v4
|
|
27
|
+
with:
|
|
28
|
+
node-version: latest
|
|
29
|
+
registry-url: https://registry.npmjs.org
|
|
30
|
+
- name: Install dependencies
|
|
31
|
+
run: |
|
|
32
|
+
npm install
|
|
33
|
+
- name: Test
|
|
34
|
+
run: |
|
|
35
|
+
npm test
|
|
36
|
+
|
|
37
|
+
deploy-npm:
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
needs: test
|
|
40
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
- uses: actions/setup-node@v4
|
|
44
|
+
with:
|
|
45
|
+
node-version: latest
|
|
46
|
+
registry-url: https://registry.npmjs.org
|
|
47
|
+
- name: Publish
|
|
48
|
+
env:
|
|
49
|
+
NODE_AUTH_TOKEN: ${{secrets.NODE_AUTH_TOKEN}}
|
|
50
|
+
run: |
|
|
51
|
+
npm publish
|
|
52
|
+
|
|
53
|
+
deploy-cargo:
|
|
54
|
+
runs-on: ubuntu-latest
|
|
55
|
+
needs: test
|
|
56
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
57
|
+
steps:
|
|
58
|
+
- uses: actions/checkout@v4
|
|
59
|
+
- uses: ructions/toolchain@v1
|
|
60
|
+
with:
|
|
61
|
+
toolchain: nightly
|
|
62
|
+
- name: Publish
|
|
63
|
+
run: |
|
|
64
|
+
cargo publish --token ${{secrets.CARGO_TOKEN}}
|
|
65
|
+
|
|
66
|
+
build-wheels-and-test:
|
|
67
|
+
needs: test
|
|
68
|
+
strategy:
|
|
69
|
+
fail-fast: false
|
|
70
|
+
matrix:
|
|
71
|
+
include:
|
|
72
|
+
- runs-on: ubuntu-latest
|
|
73
|
+
skip: "manylinux"
|
|
74
|
+
- runs-on: ubuntu-latest
|
|
75
|
+
skip: "musllinux"
|
|
76
|
+
- runs-on: macos-latest
|
|
77
|
+
skip: ""
|
|
78
|
+
- runs-on: windows-latest
|
|
79
|
+
skip: ""
|
|
80
|
+
runs-on: ${{matrix.runs-on}}
|
|
81
|
+
steps:
|
|
82
|
+
- uses: actions/checkout@v4
|
|
83
|
+
- uses: docker/setup-qemu-action@v3
|
|
84
|
+
if: runner.os == 'Linux'
|
|
85
|
+
- uses: pypa/cibuildwheel@v2.16
|
|
86
|
+
env:
|
|
87
|
+
CIBW_SKIP: "*-${{matrix.skip}}_*"
|
|
88
|
+
- uses: actions/upload-artifact@v4
|
|
89
|
+
with:
|
|
90
|
+
name: artifact-${{matrix.runs-on}}-${{matrix.skip}}
|
|
91
|
+
path: |
|
|
92
|
+
wheelhouse/*.whl
|
|
93
|
+
|
|
94
|
+
build:
|
|
95
|
+
needs:
|
|
96
|
+
- build-wheels-and-test
|
|
97
|
+
runs-on: ubuntu-latest
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/checkout@v4
|
|
100
|
+
- uses: actions/setup-python@v4
|
|
101
|
+
with:
|
|
102
|
+
python-version: ${{env.python-version}}
|
|
103
|
+
cache: ${{env.cache}}
|
|
104
|
+
- name: Install dependencies
|
|
105
|
+
run: |
|
|
106
|
+
pip install build
|
|
107
|
+
- name: Build sdist
|
|
108
|
+
run: python -m build -s
|
|
109
|
+
- uses: actions/upload-artifact@v4
|
|
110
|
+
if: "! startsWith(github.ref, 'refs/tags/')"
|
|
111
|
+
with:
|
|
112
|
+
name: artifact-sdist
|
|
113
|
+
path: |
|
|
114
|
+
dist/*
|
|
115
|
+
- uses: actions/download-artifact@v4
|
|
116
|
+
with:
|
|
117
|
+
pattern: artifact-*
|
|
118
|
+
merge-multiple: true
|
|
119
|
+
path: dist
|
|
120
|
+
- uses: softprops/action-gh-release@v1
|
|
121
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
122
|
+
with:
|
|
123
|
+
# body_path: build/CHANGELOG.md
|
|
124
|
+
files: |
|
|
125
|
+
dist/*
|
|
126
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
127
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
128
|
+
with:
|
|
129
|
+
password: ${{secrets.PYPI_API_TOKEN}}
|
|
130
|
+
|
|
131
|
+
deploy-aur:
|
|
132
|
+
needs: build
|
|
133
|
+
runs-on: ubuntu-latest
|
|
134
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
135
|
+
steps:
|
|
136
|
+
- uses: Freed-Wu/update-aur-package@v1.0.11
|
|
137
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
138
|
+
with:
|
|
139
|
+
package_name: python-tree-sitter-muttrc
|
|
140
|
+
ssh_private_key: ${{secrets.AUR_SSH_PRIVATE_KEY}}
|
|
141
|
+
|
|
142
|
+
deploy-nur:
|
|
143
|
+
needs: build
|
|
144
|
+
runs-on: ubuntu-latest
|
|
145
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
146
|
+
steps:
|
|
147
|
+
- name: Trigger Workflow
|
|
148
|
+
run: >
|
|
149
|
+
curl -X POST -d '{"ref": "main"}'
|
|
150
|
+
-H "Accept: application/vnd.github.v3+json"
|
|
151
|
+
-H "Authorization: Bearer ${{secrets.GH_TOKEN}}"
|
|
152
|
+
https://api.github.com/repos/Freed-Wu/nur-packages/actions/workflows/version.yml/dispatches
|
package/.gitlint
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
exclude: ^(templates|src)/.*
|
|
3
|
+
|
|
4
|
+
repos:
|
|
5
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
6
|
+
rev: v4.5.0
|
|
7
|
+
hooks:
|
|
8
|
+
- id: check-added-large-files
|
|
9
|
+
- id: fix-byte-order-marker
|
|
10
|
+
- id: check-case-conflict
|
|
11
|
+
- id: check-shebang-scripts-are-executable
|
|
12
|
+
- id: check-merge-conflict
|
|
13
|
+
- id: trailing-whitespace
|
|
14
|
+
- id: mixed-line-ending
|
|
15
|
+
- id: end-of-file-fixer
|
|
16
|
+
- id: detect-private-key
|
|
17
|
+
- id: check-symlinks
|
|
18
|
+
- id: check-ast
|
|
19
|
+
- id: debug-statements
|
|
20
|
+
- id: requirements-txt-fixer
|
|
21
|
+
- id: check-xml
|
|
22
|
+
- id: check-yaml
|
|
23
|
+
- id: check-toml
|
|
24
|
+
- id: check-json
|
|
25
|
+
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
|
26
|
+
rev: v1.5.4
|
|
27
|
+
hooks:
|
|
28
|
+
- id: remove-crlf
|
|
29
|
+
- repo: https://github.com/codespell-project/codespell
|
|
30
|
+
rev: v2.2.6
|
|
31
|
+
hooks:
|
|
32
|
+
- id: codespell
|
|
33
|
+
additional_dependencies:
|
|
34
|
+
- tomli
|
|
35
|
+
- repo: https://github.com/jorisroovers/gitlint
|
|
36
|
+
rev: v0.19.1
|
|
37
|
+
hooks:
|
|
38
|
+
- id: gitlint
|
|
39
|
+
args:
|
|
40
|
+
- --msg-filename
|
|
41
|
+
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
|
|
42
|
+
rev: 2.7.3
|
|
43
|
+
hooks:
|
|
44
|
+
- id: editorconfig-checker
|
|
45
|
+
- repo: https://github.com/jumanjihouse/pre-commit-hooks
|
|
46
|
+
rev: 3.0.0
|
|
47
|
+
hooks:
|
|
48
|
+
- id: check-mailmap
|
|
49
|
+
# https://github.com/koalaman/shellcheck/issues/2909
|
|
50
|
+
- id: shellcheck
|
|
51
|
+
exclude_types:
|
|
52
|
+
- zsh
|
|
53
|
+
- repo: https://github.com/rhysd/actionlint
|
|
54
|
+
rev: v1.6.26
|
|
55
|
+
hooks:
|
|
56
|
+
- id: actionlint
|
|
57
|
+
- repo: https://github.com/adrienverge/yamllint
|
|
58
|
+
rev: v1.34.0
|
|
59
|
+
hooks:
|
|
60
|
+
- id: yamllint
|
|
61
|
+
- repo: https://github.com/executablebooks/mdformat
|
|
62
|
+
rev: 0.7.17
|
|
63
|
+
hooks:
|
|
64
|
+
- id: mdformat
|
|
65
|
+
additional_dependencies:
|
|
66
|
+
- mdformat-pyproject
|
|
67
|
+
- mdformat-gfm
|
|
68
|
+
- mdformat-myst
|
|
69
|
+
- mdformat-toc
|
|
70
|
+
- mdformat-deflist
|
|
71
|
+
- mdformat-beautysh
|
|
72
|
+
- mdformat-ruff
|
|
73
|
+
- ruff
|
|
74
|
+
- mdformat-config
|
|
75
|
+
- mdformat-web
|
|
76
|
+
- repo: https://github.com/DavidAnson/markdownlint-cli2
|
|
77
|
+
rev: v0.12.1
|
|
78
|
+
hooks:
|
|
79
|
+
- id: markdownlint-cli2
|
|
80
|
+
additional_dependencies:
|
|
81
|
+
- markdown-it-texmath
|
|
82
|
+
- repo: https://github.com/scop/pre-commit-shfmt
|
|
83
|
+
rev: v3.8.0-1
|
|
84
|
+
hooks:
|
|
85
|
+
- id: shfmt
|
|
86
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
87
|
+
rev: v0.2.1
|
|
88
|
+
hooks:
|
|
89
|
+
- id: ruff
|
|
90
|
+
- id: ruff-format
|
|
91
|
+
- repo: https://github.com/kumaraditya303/mirrors-pyright
|
|
92
|
+
rev: v1.1.350
|
|
93
|
+
hooks:
|
|
94
|
+
- id: pyright
|
|
95
|
+
- repo: https://github.com/cmake-lint/cmake-lint
|
|
96
|
+
rev: 1.4.2
|
|
97
|
+
hooks:
|
|
98
|
+
- id: cmakelint
|
|
99
|
+
- repo: https://github.com/cheshirekow/cmake-format-precommit
|
|
100
|
+
rev: v0.6.13
|
|
101
|
+
hooks:
|
|
102
|
+
- id: cmake-format
|
|
103
|
+
additional_dependencies:
|
|
104
|
+
- pyyaml
|
|
105
|
+
- id: cmake-lint
|
|
106
|
+
additional_dependencies:
|
|
107
|
+
- pyyaml
|
|
108
|
+
|
|
109
|
+
ci:
|
|
110
|
+
skip:
|
|
111
|
+
- shellcheck
|
|
112
|
+
- pyright
|
package/.yamllint.yaml
ADDED
package/CMakeLists.txt
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.10)
|
|
2
|
+
string(REGEX MATCH [[[0-9](\.[0-9])*]] VERSION "$ENV{GITHUB_REF_NAME}")
|
|
3
|
+
if(NOT VERSION)
|
|
4
|
+
set(VERSION 0.0.0.0)
|
|
5
|
+
endif()
|
|
6
|
+
if(ENV{GITHUB_REPOSITORY})
|
|
7
|
+
set(HOMEPAGE_URL "https://github.com/$ENV{GITHUB_REPOSITORY}")
|
|
8
|
+
string(REGEX REPLACE ".*/tree-sitter-([^/]*)$" "\\1" LANGUAGE $ENV{GITHUB_REPOSITORY})
|
|
9
|
+
else()
|
|
10
|
+
set(HOMEPAGE_URL "")
|
|
11
|
+
file(GLOB LANGUAGE "${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/*")
|
|
12
|
+
string(REGEX REPLACE ".*/tree_sitter_([^/]*)$" "\\1" LANGUAGE ${LANGUAGE})
|
|
13
|
+
endif()
|
|
14
|
+
project(
|
|
15
|
+
tree-sitter-${LANGUAGE}
|
|
16
|
+
VERSION ${VERSION}
|
|
17
|
+
DESCRIPTION tree-sitter-${LANGUAGE}
|
|
18
|
+
HOMEPAGE_URL "${HOMEPAGE_URL}")
|
|
19
|
+
include_directories(src)
|
|
20
|
+
add_library(${LANGUAGE} SHARED src/parser.c)
|
|
21
|
+
set_target_properties(${LANGUAGE} PROPERTIES PREFIX "")
|
|
22
|
+
if(DEFINED SKBUILD_DATA_DIR)
|
|
23
|
+
set(CMAKE_INSTALL_FULL_LIBDIR ${SKBUILD_DATA_DIR}/lib)
|
|
24
|
+
endif()
|
|
25
|
+
if(NOT DEFINED CMAKE_INSTALL_FULL_LIBDIR)
|
|
26
|
+
include(GNUInstallDirs)
|
|
27
|
+
endif()
|
|
28
|
+
install(TARGETS ${LANGUAGE} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/parser)
|
|
29
|
+
|
|
30
|
+
set(CPACK_PACKAGE_CONTACT ${HOMEPAGE_URL}/issues)
|
|
31
|
+
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Wu Zhenyu <wuzhenyu@ustc.edu>")
|
|
32
|
+
set(CPACK_RPM_PACKAGE_LICENSE GPL3)
|
|
33
|
+
set(CPACK_RPM_PACKAGE_URL ${HOMEPAGE_URL})
|
|
34
|
+
include(CPack)
|
|
35
|
+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
|
36
|
+
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
|
|
37
|
+
set(CPACK_ARCHIVE_THREADS 0)
|
|
38
|
+
set(CPACK_THREADS 0)
|
package/Cargo.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "tree-sitter-muttrc"
|
|
3
|
+
description = "muttrc grammar for the tree-sitter parsing library"
|
|
4
|
+
version = "0.0.1"
|
|
5
|
+
keywords = ["incremental", "parsing", "muttrc"]
|
|
6
|
+
categories = ["parsing", "text-editors"]
|
|
7
|
+
repository = "https://github.com/Freed-Wu/tree-sitter-muttrc"
|
|
8
|
+
edition = "2018"
|
|
9
|
+
license = "GPL-3.0-or-later"
|
|
10
|
+
|
|
11
|
+
build = "bindings/rust/build.rs"
|
|
12
|
+
include = [
|
|
13
|
+
"bindings/rust/*",
|
|
14
|
+
"grammar.js",
|
|
15
|
+
"queries/*",
|
|
16
|
+
"src/*",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[lib]
|
|
20
|
+
path = "bindings/rust/lib.rs"
|
|
21
|
+
|
|
22
|
+
[dependencies]
|
|
23
|
+
tree-sitter = "~0.20.10"
|
|
24
|
+
|
|
25
|
+
[build-dependencies]
|
|
26
|
+
cc = "1.0"
|
package/README.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# tree-sitter-muttrc
|
|
2
|
+
|
|
3
|
+
[](https://results.pre-commit.ci/latest/github/neomutt/tree-sitter-muttrc/main)
|
|
4
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/actions)
|
|
5
|
+
[](https://codecov.io/gh/neomutt/tree-sitter-muttrc)
|
|
6
|
+
[](https://deepsource.io/gh/neomutt/tree-sitter-muttrc)
|
|
7
|
+
|
|
8
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/releases)
|
|
9
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/releases/latest)
|
|
10
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/issues)
|
|
11
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/issues?q=is%3Aissue+is%3Aclosed)
|
|
12
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/pulls)
|
|
13
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/pulls?q=is%3Apr+is%3Aclosed)
|
|
14
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/discussions)
|
|
15
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/milestones)
|
|
16
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/network/members)
|
|
17
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/stargazers)
|
|
18
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/watchers)
|
|
19
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/graphs/contributors)
|
|
20
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/graphs/commit-activity)
|
|
21
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/commits)
|
|
22
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/releases/latest)
|
|
23
|
+
|
|
24
|
+
[](https://github.com/neomutt/tree-sitter-muttrc/blob/main/LICENSE)
|
|
25
|
+
[](https://github.com/neomutt/tree-sitter-muttrc)
|
|
26
|
+
[](https://github.com/neomutt/tree-sitter-muttrc)
|
|
27
|
+
[](https://github.com/neomutt/tree-sitter-muttrc)
|
|
28
|
+
[](https://github.com/neomutt/tree-sitter-muttrc)
|
|
29
|
+
[](https://github.com/neomutt/tree-sitter-muttrc)
|
|
30
|
+
[](https://github.com/neomutt/tree-sitter-muttrc)
|
|
31
|
+
|
|
32
|
+
[](https://pypi.org/project/tree-sitter-muttrc/#description)
|
|
33
|
+
[](https://pypi.org/project/tree-sitter-muttrc/#history)
|
|
34
|
+
[](https://pypi.org/project/tree-sitter-muttrc/#files)
|
|
35
|
+
[](https://pypi.org/project/tree-sitter-muttrc/#files)
|
|
36
|
+
[](https://pypi.org/project/tree-sitter-muttrc/#files)
|
|
37
|
+
[](https://pypi.org/project/tree-sitter-muttrc/#files)
|
|
38
|
+
|
|
39
|
+
[](https://www.npmjs.com/package/tree-sitter-muttrc)
|
|
40
|
+
|
|
41
|
+
[](https://crates.io/crates/tree-sitter-muttrc)
|
|
42
|
+
|
|
43
|
+
[(neo)muttrc grammar](https://neomutt.org/man/neomuttrc) for
|
|
44
|
+
[tree-sitter](https://github.com/tree-sitter/tree-sitter).
|
|
45
|
+
|
|
46
|
+
It can be used by:
|
|
47
|
+
|
|
48
|
+
- Syntax highlight
|
|
49
|
+
- editors
|
|
50
|
+
- [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter): for
|
|
51
|
+
[neovim](https://github.com/neovim/neovim)
|
|
52
|
+
- [tree-sitter-langs](https://github.com/emacs-tree-sitter/tree-sitter-langs):
|
|
53
|
+
for [emacs](https://www.gnu.org/software/emacs/)
|
|
54
|
+
- [kak-tree-sitter](https://github.com/phaazon/kak-tree-sitter): for
|
|
55
|
+
[kakoune](https://kakoune.org/)
|
|
56
|
+
- [helix](https://helix-editor.com/)
|
|
57
|
+
- [zed](https://zed.dev)
|
|
58
|
+
- [atom](https://github.com/atom/atom)
|
|
59
|
+
- [syntax-highlighter](https://github.com/EvgeniyPeshkov/syntax-highlighter):
|
|
60
|
+
for [VS Code](https://github.com/microsoft/vscode)
|
|
61
|
+
- pagers
|
|
62
|
+
- [syncat](https://github.com/foxfriends/syncat)
|
|
63
|
+
- [`tree-sitter highlight`](https://tree-sitter.github.io/tree-sitter/syntax-highlighting):
|
|
64
|
+
Make sure `/the/parent/directory/of/this/repo` in `parser-directories` of
|
|
65
|
+
your `~/.config/tree-sitter/config.json`
|
|
66
|
+
- Language servers
|
|
67
|
+
- [muttrc-language-server](https://github.com/neomutt/mutt-language-server)
|
|
68
|
+
- [vscode-anycode](https://github.com/microsoft/vscode-anycode)
|
|
69
|
+
- [Navigating code on GitHub](https://docs.github.com/en/repositories/working-with-files/using-files/navigating-code-on-github):
|
|
70
|
+
supported by [semantic](https://github.com/github/semantic)
|
|
71
|
+
- Libraries
|
|
72
|
+
- [tree-sitter-muttrc](https://www.npmjs.com/package/tree-sitter-muttrc):
|
|
73
|
+
for node
|
|
74
|
+
- [tree-sitter-muttrc](https://crates.io/crates/tree-sitter-muttrc):
|
|
75
|
+
for rust
|
|
76
|
+
- [tree-sitter-muttrc](https://pypi.org/project/tree-sitter-muttrc):
|
|
77
|
+
for python
|
|
78
|
+
- [tree-sitter-languages](https://github.com/grantjenks/py-tree-sitter-languages):
|
|
79
|
+
for python
|
|
80
|
+
|
|
81
|
+
## Related Projects
|
|
82
|
+
|
|
83
|
+
- [neomutt.vim](https://github.com/neomutt/neomutt.vim): vim syntax
|
package/binding.gyp
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{ # noqa: B018 # type: ignore
|
|
2
|
+
"targets": [
|
|
3
|
+
{
|
|
4
|
+
"target_name": "tree_sitter_muttrc_binding",
|
|
5
|
+
"include_dirs": ["<!(node -e \"require('nan')\")", "src"],
|
|
6
|
+
"sources": [
|
|
7
|
+
"bindings/node/binding.cc",
|
|
8
|
+
"src/parser.c",
|
|
9
|
+
# If your language uses an external scanner, add it here.
|
|
10
|
+
],
|
|
11
|
+
"cflags_c": [
|
|
12
|
+
"-std=c99",
|
|
13
|
+
],
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#include "tree_sitter/parser.h"
|
|
2
|
+
#include <node.h>
|
|
3
|
+
#include "nan.h"
|
|
4
|
+
|
|
5
|
+
using namespace v8;
|
|
6
|
+
|
|
7
|
+
extern "C" TSLanguage * tree_sitter_muttrc();
|
|
8
|
+
|
|
9
|
+
namespace {
|
|
10
|
+
|
|
11
|
+
NAN_METHOD(New) {}
|
|
12
|
+
|
|
13
|
+
void Init(Local<Object> exports, Local<Object> module) {
|
|
14
|
+
Local<FunctionTemplate> tpl = Nan::New<FunctionTemplate>(New);
|
|
15
|
+
tpl->SetClassName(Nan::New("Language").ToLocalChecked());
|
|
16
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
17
|
+
|
|
18
|
+
Local<Function> constructor = Nan::GetFunction(tpl).ToLocalChecked();
|
|
19
|
+
Local<Object> instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked();
|
|
20
|
+
Nan::SetInternalFieldPointer(instance, 0, tree_sitter_muttrc());
|
|
21
|
+
|
|
22
|
+
Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("muttrc").ToLocalChecked());
|
|
23
|
+
Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
NODE_MODULE(tree_sitter_muttrc_binding, Init)
|
|
27
|
+
|
|
28
|
+
} // namespace
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
try {
|
|
2
|
+
module.exports = require("../../build/Release/tree_sitter_muttrc_binding");
|
|
3
|
+
} catch (error1) {
|
|
4
|
+
if (error1.code !== 'MODULE_NOT_FOUND') {
|
|
5
|
+
throw error1;
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
module.exports = require("../../build/Debug/tree_sitter_muttrc_binding");
|
|
9
|
+
} catch (error2) {
|
|
10
|
+
if (error2.code !== 'MODULE_NOT_FOUND') {
|
|
11
|
+
throw error2;
|
|
12
|
+
}
|
|
13
|
+
throw error1
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
module.exports.nodeTypeInfo = require("../../src/node-types.json");
|
|
19
|
+
} catch (_) {}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
r"""Tree sitter
|
|
2
|
+
===============
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sysconfig
|
|
7
|
+
|
|
8
|
+
from tree_sitter import Language, Parser
|
|
9
|
+
|
|
10
|
+
from . import __name__ as NAME
|
|
11
|
+
|
|
12
|
+
NAME = NAME.split("_")[-1]
|
|
13
|
+
DLL = sysconfig.get_config_var("SHLIB_SUFFIX")
|
|
14
|
+
if DLL is None:
|
|
15
|
+
DLL = ".dll"
|
|
16
|
+
|
|
17
|
+
try:
|
|
18
|
+
from ._version import __version__, __version_tuple__ # type: ignore
|
|
19
|
+
except ImportError: # for setuptools-generate
|
|
20
|
+
__version__ = "rolling"
|
|
21
|
+
__version_tuple__ = (0, 0, 0, __version__, "")
|
|
22
|
+
|
|
23
|
+
paths = [
|
|
24
|
+
os.path.join(
|
|
25
|
+
os.path.join(
|
|
26
|
+
os.path.join(sysconfig.get_path("data", scheme), "lib"), "parser"
|
|
27
|
+
),
|
|
28
|
+
NAME + DLL,
|
|
29
|
+
)
|
|
30
|
+
for scheme in [
|
|
31
|
+
sysconfig.get_preferred_scheme("user"),
|
|
32
|
+
sysconfig.get_default_scheme(),
|
|
33
|
+
]
|
|
34
|
+
]
|
|
35
|
+
for path in paths:
|
|
36
|
+
if os.path.isfile(path):
|
|
37
|
+
break
|
|
38
|
+
else:
|
|
39
|
+
raise FileNotFoundError(paths)
|
|
40
|
+
language = Language(path, NAME)
|
|
41
|
+
parser = Parser()
|
|
42
|
+
parser.set_language(language)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
r"""This module can be called by
|
|
2
|
+
`python -m <https://docs.python.org/3/library/__main__.html>`_.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from argparse import ArgumentParser, RawDescriptionHelpFormatter
|
|
6
|
+
from contextlib import suppress
|
|
7
|
+
from datetime import datetime
|
|
8
|
+
|
|
9
|
+
from . import __name__ as NAME
|
|
10
|
+
from . import __version__
|
|
11
|
+
|
|
12
|
+
NAME = NAME.replace("_", "-")
|
|
13
|
+
VERSION = rf"""{NAME} {__version__}
|
|
14
|
+
Copyright (C) {datetime.now().year}
|
|
15
|
+
Written by Wu Zhenyu
|
|
16
|
+
"""
|
|
17
|
+
EPILOG = """
|
|
18
|
+
Report bugs to <wuzhenyu@ustc.edu>.
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_parser() -> ArgumentParser:
|
|
23
|
+
r"""Get a parser for unit test."""
|
|
24
|
+
parser = ArgumentParser(
|
|
25
|
+
epilog=EPILOG, formatter_class=RawDescriptionHelpFormatter
|
|
26
|
+
)
|
|
27
|
+
parser.add_argument("--version", version=VERSION, action="version")
|
|
28
|
+
parser.add_argument(
|
|
29
|
+
"files", nargs="*", help="convert file to S expression"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
with suppress(ImportError):
|
|
33
|
+
import shtab
|
|
34
|
+
|
|
35
|
+
shtab.add_argument_to(parser)
|
|
36
|
+
|
|
37
|
+
return parser
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def main() -> None:
|
|
41
|
+
r"""Parse arguments and provide shell completions."""
|
|
42
|
+
parser = get_parser()
|
|
43
|
+
args = parser.parse_args()
|
|
44
|
+
from . import parser
|
|
45
|
+
|
|
46
|
+
for file in args.files:
|
|
47
|
+
with open(file, "rb") as f:
|
|
48
|
+
text = f.read()
|
|
49
|
+
tree = parser.parse(text)
|
|
50
|
+
sexp = tree.root_node.sexp()
|
|
51
|
+
try:
|
|
52
|
+
from tree_sitter_lsp.utils import pygmentize
|
|
53
|
+
|
|
54
|
+
pygmentize(sexp, "lisp")
|
|
55
|
+
except ImportError:
|
|
56
|
+
print(sexp)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
if __name__ == "__main__":
|
|
60
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
fn main() {
|
|
2
|
+
let src_dir = std::path::Path::new("src");
|
|
3
|
+
|
|
4
|
+
let mut c_config = cc::Build::new();
|
|
5
|
+
c_config.include(&src_dir);
|
|
6
|
+
c_config
|
|
7
|
+
.flag_if_supported("-Wno-unused-parameter")
|
|
8
|
+
.flag_if_supported("-Wno-unused-but-set-variable")
|
|
9
|
+
.flag_if_supported("-Wno-trigraphs");
|
|
10
|
+
let parser_path = src_dir.join("parser.c");
|
|
11
|
+
c_config.file(&parser_path);
|
|
12
|
+
|
|
13
|
+
// If your language uses an external scanner written in C,
|
|
14
|
+
// then include this block of code:
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
let scanner_path = src_dir.join("scanner.c");
|
|
18
|
+
c_config.file(&scanner_path);
|
|
19
|
+
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
c_config.compile("parser");
|
|
23
|
+
println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap());
|
|
24
|
+
|
|
25
|
+
// If your language uses an external scanner written in C++,
|
|
26
|
+
// then include this block of code:
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
let mut cpp_config = cc::Build::new();
|
|
30
|
+
cpp_config.cpp(true);
|
|
31
|
+
cpp_config.include(&src_dir);
|
|
32
|
+
cpp_config
|
|
33
|
+
.flag_if_supported("-Wno-unused-parameter")
|
|
34
|
+
.flag_if_supported("-Wno-unused-but-set-variable");
|
|
35
|
+
let scanner_path = src_dir.join("scanner.cc");
|
|
36
|
+
cpp_config.file(&scanner_path);
|
|
37
|
+
cpp_config.compile("scanner");
|
|
38
|
+
println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap());
|
|
39
|
+
*/
|
|
40
|
+
}
|