feat: update treesitter to v22

This commit is contained in:
Maciej Jur 2024-04-30 23:42:30 +02:00
parent d87069c17d
commit 700a93a5ee
Signed by: kamov
GPG key ID: 191CBFF5F72ECAFD
4 changed files with 211 additions and 242 deletions

133
Cargo.lock generated
View file

@ -77,9 +77,9 @@ checksum = "c59e92b5a388f549b863a7bea62612c09f24c8393560709a54558a9abdfb3b9c"
[[package]]
name = "cc"
version = "1.0.90"
version = "1.0.96"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5"
checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd"
[[package]]
name = "cfg-if"
@ -521,6 +521,12 @@ dependencies = [
"hashbrown 0.13.2",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.153"
@ -555,6 +561,16 @@ version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "npezza93-tree-sitter-haskell"
version = "0.15.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd44dfc09a37bafbed1c28622c662be9b8fb1aaaad0444688370eae11e3d54b0"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "num-traits"
version = "0.2.18"
@ -883,25 +899,19 @@ dependencies = [
"hayagriva",
"hypertext",
"katex",
"npezza93-tree-sitter-haskell",
"once_cell",
"pulldown-cmark",
"regex",
"serde",
"tree-sitter",
"tree-sitter-astro",
"tree-sitter-css",
"tree-sitter-haskell",
"tree-sitter-highlight",
"tree-sitter-html",
"tree-sitter-javascript",
"tree-sitter-md",
"tree-sitter-python",
"tree-sitter-query",
"tree-sitter-regex",
"tree-sitter-rust",
"tree-sitter-scheme",
"tree-sitter-toml",
"tree-sitter-typescript",
"tree-sitter-scss",
]
[[package]]
@ -1012,68 +1022,31 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tree-sitter"
version = "0.20.10"
version = "0.22.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e747b1f9b7b931ed39a548c1fae149101497de3c1fc8d9e18c62c1a66c683d3d"
checksum = "688200d842c76dd88f9a7719ecb0483f79f5a766fb1c100756d5d8a059abc71b"
dependencies = [
"cc",
"regex",
]
[[package]]
name = "tree-sitter-astro"
version = "0.0.1"
source = "git+https://github.com/virchau13/tree-sitter-astro.git?rev=e924787e12e8a03194f36a113290ac11d6dc10f3#e924787e12e8a03194f36a113290ac11d6dc10f3"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-css"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3306ddefa1d2681adda2613d11974ffabfbeb215e23235da6c862f3493a04fd"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-haskell"
version = "0.14.0"
source = "git+https://github.com/tree-sitter/tree-sitter-haskell?rev=1da347c88599faad7964e63facead5d163ac7dba#1da347c88599faad7964e63facead5d163ac7dba"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-highlight"
version = "0.20.1"
version = "0.22.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "042342584c5a7a0b833d9fc4e2bdab3f9868ddc6c4b339a1e01451c6720868bc"
checksum = "9442daef896b114ed618a5e11c9ba9663796ab3600e544d57f2dc980fa0d2d78"
dependencies = [
"lazy_static",
"regex",
"thiserror",
"tree-sitter",
]
[[package]]
name = "tree-sitter-html"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "017822b6bd42843c4bd67fabb834f61ce23254e866282dd93871350fd6b7fa1d"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-javascript"
version = "0.20.4"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d015c02ea98b62c806f7329ff71c383286dfc3a7a7da0cc484f6e42922f73c2c"
checksum = "26eca1925fd9518f9439ea122e3f3395abb3fcfc4b0841ef94eeef934871ec59"
dependencies = [
"cc",
"tree-sitter",
@ -1081,9 +1054,9 @@ dependencies = [
[[package]]
name = "tree-sitter-md"
version = "0.1.7"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c20d3ef8d202430b644a307e6299d84bf8ed87fa1b796e4638f8805a595060c"
checksum = "d9c3cfd068f2527250bbd8ff407431164e12b17863e7eafb76e311dd3f96965a"
dependencies = [
"cc",
"tree-sitter",
@ -1091,9 +1064,9 @@ dependencies = [
[[package]]
name = "tree-sitter-python"
version = "0.20.4"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c93b1b1fbd0d399db3445f51fd3058e43d0b4dcff62ddbdb46e66550978aa5"
checksum = "b4066c6cf678f962f8c2c4561f205945c84834cce73d981e71392624fdc390a9"
dependencies = [
"cc",
"tree-sitter",
@ -1101,19 +1074,8 @@ dependencies = [
[[package]]
name = "tree-sitter-query"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d4374ba146382b2c9a50290e79283b5035544912c0e1387e3ff08e6137f4cb4"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-regex"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efb5a53e9c990757895476216796b170fd81e4d173d08f8b082279c4e6ff8c5c"
version = "0.2.1"
source = "git+https://github.com/tree-sitter-grammars/tree-sitter-query?rev=608c01187fb9f525a1e4cf585bb63d73dea280b7#608c01187fb9f525a1e4cf585bb63d73dea280b7"
dependencies = [
"cc",
"tree-sitter",
@ -1121,38 +1083,19 @@ dependencies = [
[[package]]
name = "tree-sitter-rust"
version = "0.20.4"
version = "0.21.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0832309b0b2b6d33760ce5c0e818cb47e1d72b468516bfe4134408926fa7594"
checksum = "277690f420bf90741dea984f3da038ace46c4fe6047cba57a66822226cde1c93"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-scheme"
version = "0.2.0"
source = "git+https://github.com/6cdh/tree-sitter-scheme?rev=af0fd1fa452cb2562dc7b5c8a8c55551c39273b9#af0fd1fa452cb2562dc7b5c8a8c55551c39273b9"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-toml"
version = "0.20.0"
name = "tree-sitter-scss"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca517f578a98b23d20780247cc2688407fa81effad5b627a5a364ec3339b53e8"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-typescript"
version = "0.20.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8bc1d2c24276a48ef097a71b56888ac9db63717e8f8d0b324668a27fd619670"
checksum = "33909a9ca86390ebbf3461e9949c4bbe2767d2d024b486306d27616641d4ba24"
dependencies = [
"cc",
"tree-sitter",

View file

@ -21,20 +21,20 @@ serde = { version = "1.0.197", features = ["derive"] }
pulldown-cmark = { git = "https://github.com/pulldown-cmark/pulldown-cmark.git", branch = "branch_0.11" }
# Treesitter
tree-sitter = "0.20.10"
tree-sitter-highlight = "0.20.1"
tree-sitter = "0.22"
tree-sitter-highlight = "0.22"
# Treesitter languages
tree-sitter-astro = { git = "https://github.com/virchau13/tree-sitter-astro.git", rev = "e924787e12e8a03194f36a113290ac11d6dc10f3" }
tree-sitter-css = "0.20.0"
tree-sitter-haskell = { git = "https://github.com/tree-sitter/tree-sitter-haskell", rev = "1da347c88599faad7964e63facead5d163ac7dba" }
tree-sitter-html = "0.20.0"
tree-sitter-javascript = "0.20.3"
tree-sitter-md = "0.1.7"
tree-sitter-query = "0.1.0"
tree-sitter-python = "0.20.4"
tree-sitter-regex = "0.20.0"
tree-sitter-rust = "0.20.4"
tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "af0fd1fa452cb2562dc7b5c8a8c55551c39273b9" }
tree-sitter-toml = "0.20.0"
tree-sitter-typescript = "0.20.5"
# tree-sitter-astro = { git = "https://github.com/virchau13/tree-sitter-astro.git", rev = "e924787e12e8a03194f36a113290ac11d6dc10f3" }
# tree-sitter-css = "0.20.0"
# tree-sitter-haskell = { git = "https://github.com/tree-sitter/tree-sitter-haskell", rev = "1da347c88599faad7964e63facead5d163ac7dba" }
npezza93-tree-sitter-haskell = "0.15.1"
tree-sitter-javascript = "0.21"
tree-sitter-md = "0.2"
tree-sitter-python = "0.21"
tree-sitter-query = { git = "https://github.com/tree-sitter-grammars/tree-sitter-query", rev = "608c01187fb9f525a1e4cf585bb63d73dea280b7" }
# tree-sitter-regex = "0.20.0"
tree-sitter-rust = "0.21"
tree-sitter-scss = "1"
# tree-sitter-toml = "0.20.0"
# tree-sitter-typescript = "0.20.5"

View file

@ -1,10 +1,11 @@
/// Source: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/CONTRIBUTING.md
pub const NAMES: &[&str] = &[
// Identifiers
"variable", // various variable names
"variable.builtin", // built-in variable names (e.g. `this`)
"variable.parameter", // parameters of a function
"variable.member", // object and struct fields
"variable", // various variable names
"variable.builtin", // built-in variable names (e.g. `this`)
"variable.parameter", // parameters of a function
"variable.parameter.builtin", // special parameters (e.g. `_`, `it`)
"variable.member", // object and struct fields
"constant", // constant identifiers
"constant.builtin", // built-in constant values
@ -35,9 +36,9 @@ pub const NAMES: &[&str] = &[
"type", // type or class definitions and annotations
"type.builtin", // built-in types
"type.definition", // identifiers in type definitions (e.g. `typedef <type> <identifier>` in C)
"type.qualifier", // type qualifiers (e.g. `const`)
"attribute", // attribute annotations (e.g. Python decorators)
"attribute.builtin", // builtin annotations (e.g. `@property` in Python)
"property", // the key in key/value pairs
// Functions
@ -58,61 +59,68 @@ pub const NAMES: &[&str] = &[
"keyword.function", // keywords that define a function (e.g. `func` in Go, `def` in Python)
"keyword.operator", // operators that are English words (e.g. `and` / `or`)
"keyword.import", // keywords for including modules (e.g. `import` / `from` in Python)
"keyword.storage", // modifiers that affect storage in memory or life-time
"keyword.type", // keywords describing composite types (e.g. `struct`, `enum`)
"keyword.modifier", // keywords modifying other constructs (e.g. `const`, `static`, `public`)
"keyword.repeat", // keywords related to loops (e.g. `for` / `while`)
"keyword.return", // keywords like `return` and `yield`
"keyword.debug", // keywords related to debugging
"keyword.exception", // keywords related to exceptions (e.g. `throw` / `catch`)
"keyword.conditional", // keywords related to conditionals (e.g. `if` / `else`)
"keyword.conditional.ternary", // ternary operator (e.g. `?` / `:`)
"keyword.conditional", // keywords related to conditionals (e.g. `if` / `else`)
"keyword.conditional.ternary", // ternary operator (e.g. `?` / `:`)
"keyword.directive", // various preprocessor directives & shebangs
"keyword.directive.define", // preprocessor definition directives
// Punctuation
"punctuation.delimiter", // delimiters (e.g. `;` / `.` / `,`)
"punctuation.bracket", // brackets (e.g. `()` / `{}` / `[]`)
"punctuation.special", // special symbols (e.g. `{}` in string interpolation)
"punctuation.delimiter", // delimiters (e.g. `;` / `.` / `,`)
"punctuation.bracket", // brackets (e.g. `()` / `{}` / `[]`)
"punctuation.special", // special symbols (e.g. `{}` in string interpolation)
// Comments
"comment", // line and block comments
"comment.documentation", // comments documenting code
"comment", // line and block comments
"comment.documentation", // comments documenting code
"comment.error", // error-type comments (e.g. `ERROR`, `FIXME`, `DEPRECATED:`)
"comment.warning", // warning-type comments (e.g. `WARNING:`, `FIX:`, `HACK:`)
"comment.todo", // todo-type comments (e.g. `TODO:`, `WIP:`, `FIXME:`)
"comment.note", // note-type comments (e.g. `NOTE:`, `INFO:`, `XXX`)
"comment.error", // error-type comments (e.g. `ERROR`, `FIXME`, `DEPRECATED:`)
"comment.warning", // warning-type comments (e.g. `WARNING:`, `FIX:`, `HACK:`)
"comment.todo", // todo-type comments (e.g. `TODO:`, `WIP:`, `FIXME:`)
"comment.note", // note-type comments (e.g. `NOTE:`, `INFO:`, `XXX`)
// Markup
"markup.strong", // bold text
"markup.italic", // italic text
"markup.strikethrough", // struck-through text
"markup.underline", // underlined text (only for literal underline markup!)
"markup.strong", // bold text
"markup.italic", // italic text
"markup.strikethrough", // struck-through text
"markup.underline", // underlined text (only for literal underline markup!)
"markup.heading", // headings, titles (including markers)
"markup.heading", // headings, titles (including markers)
"markup.heading.1", // top-level heading
"markup.heading.2", // section heading
"markup.heading.3", // subsection heading
"markup.heading.4", // and so on
"markup.heading.5", // and so forth
"markup.heading.6", // six levels ought to be enough for anybody
"markup.quote", // block quotes
"markup.math", // math environments (e.g. `$ ... $` in LaTeX)
"markup.environment", // environments (e.g. in LaTeX)
"markup.quote", // block quotes
"markup.math", // math environments (e.g. `$ ... $` in LaTeX)
"markup.link", // text references, footnotes, citations, etc.
"markup.link.label", // link, reference descriptions
"markup.link.url", // URL-style links
"markup.link", // text references, footnotes, citations, etc.
"markup.link.label", // link, reference descriptions
"markup.link.url", // URL-style links
"markup.raw", // literal or verbatim text (e.g. inline code)
"markup.raw.block", // literal or verbatim text as a stand-alone block
// (use priority 90 for blocks with injections)
"markup.raw", // literal or verbatim text (e.g. inline code)
"markup.raw.block", // literal or verbatim text as a stand-alone block
// (use priority 90 for blocks with injections)
"markup.list", // list markers
"markup.list.checked", // checked todo-style list markers
"markup.list.unchecked", // unchecked todo-style list markers
"markup.list", // list markers
"markup.list.checked", // checked todo-style list markers
"markup.list.unchecked", // unchecked todo-style list markers
"diff.plus", // added text (for diff files)
"diff.minus", // deleted text (for diff files)
"diff.delta", // changed text (for diff files)
"diff.plus", // added text (for diff files)
"diff.minus", // deleted text (for diff files)
"diff.delta", // changed text (for diff files)
"tag", // XML-style tag names (and similar)
"tag.attribute", // XML-style tag attributes
"tag.delimiter", // XML-style tag delimiters
"tag", // XML-style tag names (and similar)
"tag.builtin", // builtin tag names (e.g. HTML5 tags)
"tag.attribute", // XML-style tag attributes
"tag.delimiter", // XML-style tag delimiters
];

View file

@ -24,66 +24,70 @@ pub static EXTENSIONS: Lazy<HashMap<&'static str, &'static str>> = Lazy::new(||
("md", "markdown"),
("mdx", "markdown"),
("py", "python"),
("query", "scheme"),
("scm", "scheme"),
("scss", "css"),
("ts", "typescript")
("query", "query"),
// ("scm", "scheme"),
("scss", "scss"),
("ts", "javascript"),
("typescript", "javascript")
])
});
fn config_for(
lang: Language,
name: &str,
highlights: &str,
injections: &str,
locals: &str,
) -> HighlightConfiguration {
let mut config = HighlightConfiguration::new(lang, highlights, injections, locals).unwrap();
let mut config = HighlightConfiguration::new(lang, name, highlights, injections, locals).unwrap();
config.configure(captures::NAMES);
config
}
pub static CONFIGS: Lazy<HashMap<&'static str, HighlightConfiguration>> = Lazy::new(|| {
HashMap::from([
(
"astro",
config_for(
tree_sitter_astro::language(),
query!("astro/highlights"),
query!("astro/injections"),
"",
)
),
(
"css",
config_for(
tree_sitter_css::language(),
query!("css/highlights"),
"",
"",
)
),
// (
// "astro",
// config_for(
// tree_sitter_astro::language(),
// query!("astro/highlights"),
// query!("astro/injections"),
// "",
// )
// ),
// (
// "css",
// config_for(
// tree_sitter_css::language(),
// query!("css/highlights"),
// "",
// "",
// )
// ),
(
"haskell",
config_for(
tree_sitter_haskell::language(),
tree_sitter_haskell::HIGHLIGHTS_QUERY,
"",
tree_sitter_haskell::LOCALS_QUERY,
)
),
(
"html",
config_for(
tree_sitter_html::language(),
tree_sitter_html::HIGHLIGHTS_QUERY,
tree_sitter_html::INJECTIONS_QUERY,
npezza93_tree_sitter_haskell::language(),
"haskell",
npezza93_tree_sitter_haskell::HIGHLIGHTS_QUERY,
"",
npezza93_tree_sitter_haskell::LOCALS_QUERY,
)
),
// (
// "html",
// config_for(
// tree_sitter_html::language(),
// tree_sitter_html::HIGHLIGHTS_QUERY,
// tree_sitter_html::INJECTIONS_QUERY,
// "",
// )
// ),
(
"javascript",
config_for(
tree_sitter_javascript::language(),
"javascript",
&format!("{} {}",
query!("ecma/highlights"),
tree_sitter_javascript::HIGHLIGHT_QUERY,
@ -96,6 +100,7 @@ pub static CONFIGS: Lazy<HashMap<&'static str, HighlightConfiguration>> = Lazy::
"jsx",
config_for(
tree_sitter_javascript::language(),
"jsx",
&format!("{} {} {}",
query!("ecma/highlights"),
tree_sitter_javascript::HIGHLIGHT_QUERY,
@ -109,6 +114,7 @@ pub static CONFIGS: Lazy<HashMap<&'static str, HighlightConfiguration>> = Lazy::
"markdown",
config_for(
tree_sitter_md::language(),
"markdown",
tree_sitter_md::HIGHLIGHT_QUERY_BLOCK,
tree_sitter_md::INJECTION_QUERY_BLOCK,
"",
@ -118,80 +124,92 @@ pub static CONFIGS: Lazy<HashMap<&'static str, HighlightConfiguration>> = Lazy::
"python",
config_for(
tree_sitter_python::language(),
tree_sitter_python::HIGHLIGHT_QUERY,
"python",
tree_sitter_python::HIGHLIGHTS_QUERY,
"",
"",
)
),
(
"regex",
"query",
config_for(
tree_sitter_regex::language(),
query!("regex/highlights"),
"",
tree_sitter_query::language(),
"query",
tree_sitter_query::HIGHLIGHTS_QUERY,
tree_sitter_query::INJECTIONS_QUERY,
"",
)
),
// (
// "regex",
// config_for(
// tree_sitter_regex::language(),
// query!("regex/highlights"),
// "",
// "",
// )
// ),
(
"rust",
config_for(
tree_sitter_rust::language(),
tree_sitter_rust::HIGHLIGHT_QUERY,
"rust",
tree_sitter_rust::HIGHLIGHTS_QUERY,
tree_sitter_rust::INJECTIONS_QUERY,
"",
)
),
(
"scheme",
config_for(
tree_sitter_scheme::language(),
tree_sitter_scheme::HIGHLIGHTS_QUERY,
"",
"",
)
),
(
"toml",
config_for(
tree_sitter_toml::language(),
tree_sitter_toml::HIGHLIGHT_QUERY,
"",
"",
)
),
(
"tsx",
config_for(
tree_sitter_typescript::language_tsx(),
&format!("{} {} {} {}",
query!("ecma/highlights"),
tree_sitter_javascript::HIGHLIGHT_QUERY,
tree_sitter_javascript::JSX_HIGHLIGHT_QUERY,
tree_sitter_typescript::HIGHLIGHT_QUERY,
),
tree_sitter_javascript::INJECTION_QUERY,
&format!("{} {}",
tree_sitter_javascript::LOCALS_QUERY,
tree_sitter_typescript::LOCALS_QUERY
)
)
),
(
"typescript",
config_for(
tree_sitter_typescript::language_typescript(),
&format!("{} {} {}",
query!("ecma/highlights"),
tree_sitter_javascript::HIGHLIGHT_QUERY,
tree_sitter_typescript::HIGHLIGHT_QUERY,
),
tree_sitter_javascript::INJECTION_QUERY,
&format!("{} {}",
tree_sitter_javascript::LOCALS_QUERY,
tree_sitter_typescript::LOCALS_QUERY
),
)
),
// (
// "scheme",
// config_for(
// tree_sitter_scheme::language(),
// tree_sitter_scheme::HIGHLIGHTS_QUERY,
// "",
// "",
// )
// ),
// (
// "toml",
// config_for(
// tree_sitter_toml::language(),
// tree_sitter_toml::HIGHLIGHT_QUERY,
// "",
// "",
// )
// ),
// (
// "tsx",
// config_for(
// tree_sitter_typescript::language_tsx(),
// &format!("{} {} {} {}",
// query!("ecma/highlights"),
// tree_sitter_javascript::HIGHLIGHT_QUERY,
// tree_sitter_javascript::JSX_HIGHLIGHT_QUERY,
// tree_sitter_typescript::HIGHLIGHT_QUERY,
// ),
// tree_sitter_javascript::INJECTION_QUERY,
// &format!("{} {}",
// tree_sitter_javascript::LOCALS_QUERY,
// tree_sitter_typescript::LOCALS_QUERY
// )
// )
// ),
// (
// "typescript",
// config_for(
// tree_sitter_typescript::language_typescript(),
// &format!("{} {} {}",
// query!("ecma/highlights"),
// tree_sitter_javascript::HIGHLIGHT_QUERY,
// tree_sitter_typescript::HIGHLIGHT_QUERY,
// ),
// tree_sitter_javascript::INJECTION_QUERY,
// &format!("{} {}",
// tree_sitter_javascript::LOCALS_QUERY,
// tree_sitter_typescript::LOCALS_QUERY
// ),
// )
// ),
])
});