tree-sitter-muttrc 0.0.3 → 0.0.5

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/CMakeLists.txt DELETED
@@ -1,43 +0,0 @@
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" NAME $ENV{GITHUB_REPOSITORY})
9
- else()
10
- set(HOMEPAGE_URL "")
11
- file(GLOB NAME "${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/*")
12
- string(REGEX REPLACE ".*/tree_sitter_([^/]*)$" "\\1" NAME ${NAME})
13
- endif()
14
- project(
15
- tree-sitter-${NAME}
16
- VERSION ${VERSION}
17
- DESCRIPTION tree-sitter-${NAME}
18
- HOMEPAGE_URL "${HOMEPAGE_URL}")
19
- include_directories(src)
20
- add_library(${NAME} SHARED src/parser.c)
21
- set_target_properties(${NAME} PROPERTIES PREFIX "")
22
- if(DEFINED SKBUILD_DATA_DIR)
23
- set(CMAKE_INSTALL_FULL_LIBDIR ${SKBUILD_DATA_DIR}/lib)
24
- endif()
25
- # https://docs.python.org/3/library/ctypes.html#finding-shared-libraries
26
- if(DEFINED SKBUILD_PLATLIB_DIR)
27
- # it may be better to determine the shared library name at development time, and hardcode that into the wrapper module
28
- configure_file(__init__.py.in ${SKBUILD_PLATLIB_DIR}/tree_sitter_${NAME}/__init__.py)
29
- endif()
30
- if(NOT DEFINED CMAKE_INSTALL_FULL_LIBDIR)
31
- include(GNUInstallDirs)
32
- endif()
33
- install(TARGETS ${NAME} DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/parser)
34
-
35
- set(CPACK_PACKAGE_CONTACT ${HOMEPAGE_URL}/issues)
36
- set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Wu Zhenyu <wuzhenyu@ustc.edu>")
37
- set(CPACK_RPM_PACKAGE_LICENSE GPL3)
38
- set(CPACK_RPM_PACKAGE_URL ${HOMEPAGE_URL})
39
- include(CPack)
40
- set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
41
- set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
42
- set(CPACK_ARCHIVE_THREADS 0)
43
- set(CPACK_THREADS 0)
package/Cargo.toml DELETED
@@ -1,26 +0,0 @@
1
- [package]
2
- name = "tree-sitter-muttrc"
3
- description = "muttrc grammar for the tree-sitter parsing library"
4
- version = "0.0.3"
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/__init__.py.in DELETED
@@ -1,33 +0,0 @@
1
- r"""Tree sitter
2
- ===============
3
- """
4
-
5
- import os
6
- import sysconfig
7
-
8
- from tree_sitter import Language, Parser
9
-
10
- __version__ = "@VERSION@"
11
- NAME = "@NAME@"
12
- DLL = "@CMAKE_SHARED_LIBRARY_SUFFIX@"
13
-
14
- paths = [
15
- os.path.join(
16
- os.path.join(
17
- os.path.join(sysconfig.get_path("data", scheme), "lib"), "parser"
18
- ),
19
- NAME + DLL,
20
- )
21
- for scheme in [
22
- sysconfig.get_preferred_scheme("user"),
23
- sysconfig.get_default_scheme(),
24
- ]
25
- ]
26
- for path in paths:
27
- if os.path.isfile(path):
28
- break
29
- else:
30
- raise FileNotFoundError(paths)
31
- language = Language(path, NAME)
32
- parser = Parser()
33
- parser.set_language(language)
@@ -1,60 +0,0 @@
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
@@ -1,40 +0,0 @@
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
- }
@@ -1,52 +0,0 @@
1
- //! This crate provides muttrc language support for the [tree-sitter][] parsing library.
2
- //!
3
- //! Typically, you will use the [language][language func] function to add this language to a
4
- //! tree-sitter [Parser][], and then use the parser to parse some code:
5
- //!
6
- //! ```
7
- //! let code = "";
8
- //! let mut parser = tree_sitter::Parser::new();
9
- //! parser.set_language(tree_sitter_muttrc::language()).expect("Error loading muttrc grammar");
10
- //! let tree = parser.parse(code, None).unwrap();
11
- //! ```
12
- //!
13
- //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
14
- //! [language func]: fn.language.html
15
- //! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
16
- //! [tree-sitter]: https://tree-sitter.github.io/
17
-
18
- use tree_sitter::Language;
19
-
20
- extern "C" {
21
- fn tree_sitter_muttrc() -> Language;
22
- }
23
-
24
- /// Get the tree-sitter [Language][] for this grammar.
25
- ///
26
- /// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
27
- pub fn language() -> Language {
28
- unsafe { tree_sitter_muttrc() }
29
- }
30
-
31
- /// The content of the [`node-types.json`][] file for this grammar.
32
- ///
33
- /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
34
- pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
35
-
36
- // Uncomment these to include any queries that this grammar contains
37
-
38
- // pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
39
- // pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
40
- // pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
41
- // pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
42
-
43
- #[cfg(test)]
44
- mod tests {
45
- #[test]
46
- fn test_can_load_grammar() {
47
- let mut parser = tree_sitter::Parser::new();
48
- parser
49
- .set_language(super::language())
50
- .expect("Error loading muttrc language");
51
- }
52
- }
package/pyproject.toml DELETED
@@ -1,123 +0,0 @@
1
- [build-system]
2
- requires = ["scikit-build-core"]
3
- build-backend = "scikit_build_core.build"
4
-
5
- [project]
6
- name = "tree-sitter-muttrc"
7
- description = "muttrc grammar for tree-sitter"
8
- readme = "README.md"
9
- # sysconfig.get_preferred_scheme()
10
- requires-python = ">= 3.10"
11
- keywords = ["parsing", "incremental"]
12
- classifiers = [
13
- "Development Status :: 3 - Alpha",
14
- "Intended Audience :: Developers",
15
- "Topic :: Software Development :: Build Tools",
16
- "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
17
- "Operating System :: Microsoft :: Windows",
18
- "Operating System :: POSIX",
19
- "Operating System :: Unix",
20
- "Operating System :: MacOS",
21
- "Programming Language :: Python :: 3 :: Only",
22
- "Programming Language :: Python :: 3",
23
- "Programming Language :: Python :: 3.7",
24
- "Programming Language :: Python :: 3.8",
25
- "Programming Language :: Python :: 3.9",
26
- "Programming Language :: Python :: 3.10",
27
- "Programming Language :: Python :: 3.11",
28
- "Programming Language :: Python :: 3.12",
29
- "Programming Language :: Python :: Implementation :: CPython",
30
- "Programming Language :: Python :: Implementation :: PyPy",
31
- ]
32
- # dynamic = ["version", "dependencies", "optional-dependencies"]
33
- # https://github.com/pypa/twine/issues/753
34
- dynamic = ["version"]
35
- dependencies = ["tree-sitter"]
36
-
37
- [project.optional-dependencies]
38
- dev = ["pytest-cov"]
39
- colorize = ["tree_sitter_lsp"]
40
-
41
- [[project.authors]]
42
- name = "Wu Zhenyu"
43
- email = "wuzhenyu@ustc.edu"
44
-
45
- [project.license]
46
- text = "GPL v3"
47
-
48
- [project.urls]
49
- Homepage = "https://tree-sitter-muttrc.readthedocs.io"
50
- Download = "https://github.com/neomutt/tree-sitter-muttrc/releases"
51
- "Bug Report" = "https://github.com/neomutt/tree-sitter-muttrc/issues"
52
- Source = "https://github.com/neomutt/tree-sitter-muttrc"
53
-
54
- [tool.scikit-build]
55
- experimental = true
56
-
57
- [tool.scikit-build.metadata.version]
58
- provider = "scikit_build_core.metadata.setuptools_scm"
59
-
60
- [tool.scikit-build.sdist]
61
- include = ["py.typed"]
62
-
63
- [tool.scikit-build.wheel]
64
- packages = ["bindings/python/tree_sitter_muttrc"]
65
-
66
- [tool.setuptools.dynamic.dependencies]
67
- file = "requirements.txt"
68
-
69
- # begin: scripts/update-pyproject.toml.pl
70
- [tool.setuptools.dynamic.optional-dependencies.dev]
71
- file = "requirements/dev.txt"
72
- # end: scripts/update-pyproject.toml.pl
73
-
74
- [tool.setuptools_scm]
75
-
76
- [tool.mdformat]
77
- number = true
78
-
79
- [tool.codespell]
80
- ignore-words-list = "crate"
81
-
82
- [tool.doq]
83
- template_path = "templates"
84
-
85
- [tool.ruff]
86
- line-length = 79
87
-
88
- [tool.ruff.lint]
89
- select = [
90
- # pycodestyle
91
- "E",
92
- # pyflakes
93
- "F",
94
- # pyupgrade
95
- "UP",
96
- # flake8-bugbear
97
- "B",
98
- # flake8-simplify
99
- "SIM",
100
- # isort
101
- "I",
102
- ]
103
- ignore = ["D205", "D400"]
104
- preview = true
105
-
106
- [tool.ruff.format]
107
- docstring-code-format = true
108
- preview = true
109
-
110
- [tool.coverage.report]
111
- exclude_lines = [
112
- "if TYPE_CHECKING:",
113
- "if __name__ == .__main__.:",
114
- "\\s*import tomli as tomllib",
115
- ]
116
-
117
- [tool.cibuildwheel]
118
- archs = ["all"]
119
- skip = "*37-* *38-* *39-*"
120
- # https://github.com/pypa/cibuildwheel/issues/287#issuecomment-1937451870
121
- test-skip = "*-win32"
122
- before-test = "pip install -rrequirements.txt -rrequirements/dev.txt"
123
- test-command = "pytest {project}"
@@ -1,53 +0,0 @@
1
- ; Comments
2
- (comment) @comment @spell
3
-
4
- ; General
5
- (int) @number
6
-
7
- (string) @string
8
-
9
- [
10
- (map)
11
- (object)
12
- (composeobject)
13
- (color)
14
- (attribute)
15
- ] @string.special
16
-
17
- (quadoption) @boolean
18
-
19
- (path) @string.special.path
20
-
21
- (regex) @string.regexp
22
-
23
- [
24
- (option)
25
- (command_line_option)
26
- ] @variable.builtin
27
-
28
- (command) @keyword
29
-
30
- (source_directive
31
- (command) @keyword.import)
32
-
33
- (uri) @string.special.url
34
-
35
- (key_name) @type.builtin
36
-
37
- (escape) @string.escape
38
-
39
- (function) @function.call
40
-
41
- ; Literals
42
- [
43
- "<"
44
- ">"
45
- ] @punctuation.bracket
46
-
47
- "," @punctuation.delimiter
48
-
49
- [
50
- "&"
51
- "?"
52
- "*"
53
- ] @punctuation.special
@@ -1,8 +0,0 @@
1
- ((regex) @injection.content
2
- (#set! injection.language "regex"))
3
-
4
- ((shell) @injection.content
5
- (#set! injection.language "bash"))
6
-
7
- ((comment) @injection.content
8
- (#set! injection.language "comment"))
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env -S pip install -r
2
-
3
- tree_sitter_lsp[colorize]
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env -S pip install -r
2
- # For unit test and code coverage rate test.
3
-
4
- pytest-cov
package/requirements.txt DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env -S pip install -r
2
-
3
- tree-sitter
package/scripts/build.sh DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -e
3
- cd "$(dirname "$(readlink -f "$0")")/.."
4
-
5
- tree-sitter generate
6
- cmake -Bbuild -DCMAKE_INSTALL_FULL_LIBDIR="${1:-$HOME/.local/share/nvim/repos/github.com/nvim-treesitter/nvim-treesitter}"
7
- cmake --build build
8
- cmake --install build
@@ -1,2 +0,0 @@
1
- r"""{{name.replace("_", " ").strip().capitalize()}}."""
2
-
package/templates/def.txt DELETED
@@ -1,12 +0,0 @@
1
- r"""{{name.replace("_", " ").strip().capitalize()}}.
2
-
3
- {%for p in params-%}
4
- :param {{p.argument}}:
5
- {%if p.annotation-%}
6
- :type {{p.argument}}: {{p.annotation.strip('"')}}
7
- {%endif-%}
8
- {%endfor-%}
9
- {%if return_type-%}
10
- :rtype: {{return_type}}
11
- {%endif-%}
12
- """
@@ -1 +0,0 @@
1
- r"""{{name.replace("_", " ").strip().capitalize()}}."""
@@ -1,82 +0,0 @@
1
- =======
2
- Example
3
- =======
4
-
5
- bind pager,index \ch<BackSpace> sidebar-toggle-visible
6
- set & allow_ansi ? allow_ansi noallow_ansi
7
- set allow_ansi=yes
8
- set sleep_time = 0
9
- set real_name = $DEBFULLNAME
10
- set ispell = aspell
11
- set query_command = 'mutt_ldap_query.pl %s'
12
- set signature = "echo Best Regards$'\n'$DEBFULLNAME|"
13
- set imap_pass = `pass ls password/$USER`
14
- mailboxes $spool_file $postponed $record $trash \
15
- +[Gmail]/Spam +[Gmail]/Starred
16
- sidebar_unpin *
17
- source ~/.config/neomutt/neomuttrc
18
-
19
- ---
20
-
21
- (file
22
- (bind_directive
23
- (command)
24
- (map)
25
- (map)
26
- (key
27
- (escape)
28
- (key_name))
29
- (function))
30
- (set_directive
31
- (command)
32
- (option)
33
- (option)
34
- (option))
35
- (set_directive
36
- (command)
37
- (option)
38
- (quadoption))
39
- (set_directive
40
- (command)
41
- (option)
42
- (int))
43
- (set_directive
44
- (command)
45
- (option)
46
- (shell))
47
- (set_directive
48
- (command)
49
- (option)
50
- (shell))
51
- (set_directive
52
- (command)
53
- (option)
54
- (string))
55
- (set_directive
56
- (command)
57
- (option)
58
- (shell))
59
- (set_directive
60
- (command)
61
- (option)
62
- (shell))
63
- (mailboxes_directive
64
- (command)
65
- (mailbox
66
- (shell))
67
- (mailbox
68
- (shell))
69
- (mailbox
70
- (shell))
71
- (mailbox
72
- (shell))
73
- (mailbox
74
- (shell))
75
- (mailbox
76
- (shell)))
77
- (sidebar_unpin_directive
78
- (command))
79
- (source_directive
80
- (command)
81
- (path
82
- (shell))))
package/tests/neomuttrc DELETED
@@ -1,18 +0,0 @@
1
- bind pager,index \ch<BackSpace> sidebar-toggle-visible
2
- set & allow_ansi ? allow_ansi noallow_ansi
3
- set allow_ansi=yes sleep_time = 0 ispell = aspell
4
- set real_name = $DEBFULLNAME
5
- set query_command = 'mutt_ldap_query.pl %s'
6
- set signature = "echo Best Regards$'\n'$DEBFULLNAME|"
7
- set imap_pass = `pass ls password/$USER`
8
- mailboxes $spool_file $postponed $record $trash \
9
- +[Gmail]/Spam +[Gmail]/Starred
10
- sidebar_unpin *
11
- source ~/.config/neomutt/neomuttrc
12
-
13
- set my_config = ~/.config/neomutt/neomuttrc
14
- folder-hook 'imaps://imap\..*\.gmail' source $my_config.gmail
15
- # Refer https://neomutt.org/feature/compress#4-%C2%A0neomuttrc
16
- open-hook '\.gz$' "gzip --stdout --decompress '%f' > '%t'"
17
- color body color22 default "(http|https|ftp|news|telnet|finger)://[^ \">\t\r\n]*"
18
- color body green default "[-a-z_0-9.%$]+ (<at>|AT) [-a-z_0-9.]+\\.[-a-z][-a-z]+"
@@ -1,22 +0,0 @@
1
- r"""Test __init__.py."""
2
-
3
- import os
4
-
5
- from tree_sitter_muttrc import parser
6
-
7
-
8
- class Test:
9
- r"""Test."""
10
-
11
- @staticmethod
12
- def test_parser() -> None:
13
- r"""Test parser.
14
-
15
- :rtype: None
16
- """
17
- with open(
18
- os.path.join(os.path.dirname(__file__), "neomuttrc"), "rb"
19
- ) as f:
20
- text = f.read()
21
- tree = parser.parse(text)
22
- assert len(tree.root_node.children)