From f631706ea468b4684c6e154fb85be6dd1417efa4 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Tue, 4 Mar 2025 18:41:22 -0300 Subject: [PATCH 01/10] simple highlighting for prompt --- Cargo.lock | 176 ++++- cli/Cargo.toml | 17 +- cli/SQL.sublime-syntax | 1670 ++++++++++++++++++++++++++++++++++++++++ cli/app.rs | 1 + cli/helper.rs | 56 +- 5 files changed, 1910 insertions(+), 10 deletions(-) create mode 100644 cli/SQL.sublime-syntax diff --git a/Cargo.lock b/Cargo.lock index c12346524..b4fb40089 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,6 +208,21 @@ dependencies = [ "backtrace", ] +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + [[package]] name = "bitflags" version = "1.3.2" @@ -519,6 +534,15 @@ dependencies = [ "libc", ] +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "criterion" version = "0.5.1" @@ -675,6 +699,15 @@ dependencies = [ "uuid", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "difflib" version = "0.4.0" @@ -888,6 +921,22 @@ dependencies = [ "winapi", ] +[[package]] +name = "flate2" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + [[package]] name = "foldhash" version = "0.1.4" @@ -1320,7 +1369,7 @@ dependencies = [ "log", "num-format", "once_cell", - "quick-xml", + "quick-xml 0.26.0", "rgb", "str_stack", ] @@ -1616,6 +1665,7 @@ dependencies = [ "limbo_core", "miette", "rustyline", + "syntect", "tracing", "tracing-subscriber", ] @@ -1839,6 +1889,12 @@ dependencies = [ "uuid", ] +[[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + [[package]] name = "linkme" version = "0.3.31" @@ -2081,6 +2137,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-format" version = "0.4.4" @@ -2115,6 +2177,28 @@ version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +[[package]] +name = "onig" +version = "6.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4b31c8722ad9171c6d77d3557db078cab2bd50afcc9d09c8b315c59df8ca4f" +dependencies = [ + "bitflags 1.3.2", + "libc", + "once_cell", + "onig_sys", +] + +[[package]] +name = "onig_sys" +version = "69.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b829e3d7e9cc74c7e315ee8edb185bf4190da5acde74afd7fc59c35b1f086e7" +dependencies = [ + "cc", + "pkg-config", +] + [[package]] name = "oorandom" version = "11.1.4" @@ -2279,6 +2363,19 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +[[package]] +name = "plist" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cf17e9a1800f5f396bc67d193dc9411b59012a5876445ef450d449881e1016" +dependencies = [ + "base64", + "indexmap", + "quick-xml 0.32.0", + "serde", + "time", +] + [[package]] name = "plotters" version = "0.3.7" @@ -2328,6 +2425,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "pprof" version = "0.14.0" @@ -2480,6 +2583,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "quick-xml" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d3a6e5838b60e0e8fa7a43f22ade549a37d61f8bdbe636d0d7816191de969c2" +dependencies = [ + "memchr", +] + [[package]] name = "quickcheck" version = "1.0.3" @@ -3079,6 +3191,28 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "syntect" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "874dcfa363995604333cf947ae9f751ca3af4522c60886774c4963943b4746b1" +dependencies = [ + "bincode", + "bitflags 1.3.2", + "flate2", + "fnv", + "once_cell", + "onig", + "plist", + "regex-syntax", + "serde", + "serde_derive", + "serde_json", + "thiserror 1.0.69", + "walkdir", + "yaml-rust", +] + [[package]] name = "target-lexicon" version = "0.12.16" @@ -3206,6 +3340,37 @@ dependencies = [ "once_cell", ] +[[package]] +name = "time" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +dependencies = [ + "num-conv", + "time-core", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -3831,6 +3996,15 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" +[[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "yoke" version = "0.7.5" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index c78dae6b8..d7fa51c06 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,14 +1,14 @@ # Copyright 2023 the Limbo authors. All rights reserved. MIT license. [package] -name = "limbo_cli" -version.workspace = true authors.workspace = true default-run = "limbo" +description = "The Limbo interactive SQL shell" edition.workspace = true license.workspace = true +name = "limbo_cli" repository.workspace = true -description = "The Limbo interactive SQL shell" +version.workspace = true [package.metadata.dist] dist = true @@ -20,22 +20,23 @@ path = "main.rs" [dependencies] anyhow = "1.0.75" +cfg-if = "1.0.0" clap = { version = "4.5", features = ["derive"] } comfy-table = "7.1.4" +csv = "1.3.1" +ctrlc = "3.4.4" dirs = "5.0.1" env_logger = "0.10.1" limbo_core = { path = "../core", default-features = true, features = [ "completion", ] } +miette = { version = "7.4.0", features = ["fancy"] } rustyline = { version = "15.0.0", default-features = true, features = [ "derive", ] } -ctrlc = "3.4.4" -csv = "1.3.1" -miette = { version = "7.4.0", features = ["fancy"] } -cfg-if = "1.0.0" -tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } +syntect = "5.2.0" tracing = "0.1.41" +tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } [features] default = ["io_uring"] diff --git a/cli/SQL.sublime-syntax b/cli/SQL.sublime-syntax new file mode 100644 index 000000000..d4c9b4d12 --- /dev/null +++ b/cli/SQL.sublime-syntax @@ -0,0 +1,1670 @@ +%YAML 1.2 +--- +name: SQL +scope: source.sql +version: 2 +hidden: true + +variables: + string_escape: (?:\\.) + simple_identifier: (?:\w+) + simple_identifier_break: (?!\w) + + toplevel_reserved: |- + (?xi: alter | create | cross | delete | drop | from | grant | group | inner | insert | join + | left | on | order | outer | revoke | right | select | set | truncate | union + | update | where ) + additional_toplevel_reserved: (?!) + + # TODO: not all are supported by all dialects! + ddl_target: |- + (?xi: {{ddl_target_other}} + | (?: {{ddl_target_function_modifier}} \s+ )? {{ddl_target_function}} + | (?: {{ddl_target_index_modifier}} \s+ )? index + | (?: {{ddl_target_table_modifier}} \s+ )? table ) + ddl_target_function: |- + (?xi: procedure | function ) + ddl_target_other: |- + (?xi: aggregate | column | constraint | conversion | database | domain | group + | language | member | operator\s+class | operator | role | rule | schema | sequence + | tablespace | trigger | type | user | view ) + + ddl_target_inside_alter_table: |- + (?xi: constraint ) + + ddl_target_function_modifier: |- + (?xi: aggregate ) + ddl_target_index_modifier: |- + (?xi: clustered | fulltext | spatial | unique ) + ddl_target_table_modifier: |- + (?xi: temp(?:orary)? ) + + function_parameter_modifier: |- + (?xi: inout | in | out ) + + simple_types: |- + (?xi: boolean | bool | year ) + + types_with_optional_number: |- + (?xi: bit | datetime | int | number | n?(?:var)?char | varbinary ) + + type_modifiers: |- + (?xi: signed | unsigned | zerofill ) + + builtin_scalar_functions: |- + (?xi: current_(?: date | time(?:stamp)? ) ) + + builtin_user_functions: |- + (?xi: (?: current | session | system )_user ) + +contexts: + prototype: + - include: comments + + main: + - include: sql + + sql: + - include: statements + - include: statement-terminators + - include: expressions-or-column-names + + statements: + - include: create-statements + - include: drop-statements + - include: alter-statements + - include: dml-statements + - include: grant-statements + - include: revoke-statements + - include: other-statements + +###[ COMMENTS ]################################################################ + + comments: + - include: double-dash-comments + - include: block-comments + + double-dash-comments: + - match: '--' + scope: punctuation.definition.comment.sql + push: inside-double-dash-comment + + block-comments: + - match: /\*(?:\*(?!/))+ + scope: punctuation.definition.comment.begin.sql + push: inside-comment-docblock + - match: /\* + scope: punctuation.definition.comment.begin.sql + push: inside-comment-block + + inside-double-dash-comment: + - meta_include_prototype: false + - meta_scope: comment.line.double-dash.sql + - match: \n + pop: 1 + + inside-comment-docblock: + - meta_include_prototype: false + - meta_scope: comment.block.documentation.sql + - match: \*+/ + scope: punctuation.definition.comment.end.sql + pop: 1 + - match: ^\s*(\*)(?!\**/) + captures: + 1: punctuation.definition.comment.sql + + inside-comment-block: + - meta_include_prototype: false + - meta_scope: comment.block.sql + - match: \*+/ + scope: punctuation.definition.comment.end.sql + pop: 1 + +###[ DDL CREATE STATEMENTS ]################################################### + + create-statements: + - match: \b(?i:create)\b + scope: keyword.other.ddl.sql + push: + - create-meta + - create-target + + create-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.create.sql + - include: immediately-pop + + create-target: + - include: create-function + - include: create-index + - include: create-table + - include: create-other + - include: else-pop + + create-function: + - match: \b(?:({{ddl_target_function_modifier}})\s+)?({{ddl_target_function}})\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + set: + - expect-function-characteristics + - expect-function-parameters + - expect-function-creation-name + - create-function-condition + + create-function-condition: + - meta_include_prototype: false + - include: maybe-condition + + create-index: + - match: \b(?i:(?:({{ddl_target_index_modifier}})\s+)?(index))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + set: + - create-index-args + - expect-index-creation-name + - create-index-condition + + create-index-condition: + - meta_include_prototype: false + - include: maybe-condition + + create-index-args: + - meta_scope: meta.index.sql + - include: on-table-names + - include: create-common-args + + create-table: + - match: \b(?i:(?:({{ddl_target_table_modifier}})\s+)?(table))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + set: + - create-table-args + - maybe-column-declaration-list + - expect-table-creation-name + - create-table-condition + + create-table-condition: + - meta_include_prototype: false + - include: maybe-condition + + create-table-args: + - meta_scope: meta.table.sql + - include: create-common-args + + create-other: + - match: \b{{ddl_target_other}}\b + scope: keyword.other.ddl.sql + set: + - create-other-args + - expect-other-creation-name + - create-other-condition + + create-other-condition: + - meta_include_prototype: false + - include: maybe-condition + + create-other-args: + - match: \b(?i:(as)\s+(table))\b + captures: + 1: keyword.context.block.sql + 2: support.type.sql + set: maybe-column-declaration-list + - match: \b(?i:as)\b + scope: keyword.context.block.sql + pop: 1 + - include: grant + - include: on-table-names + - include: create-common-args + + create-common-args: + - include: expressions + - include: pop-on-top-level-reserved-word + +###[ DDL DROP STATEMENTS ]##################################################### + + drop-statements: + - match: \b(?i:drop)\b + scope: keyword.other.ddl.sql + push: + - drop-meta + - drop-target + + drop-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.drop.sql + - include: immediately-pop + + drop-target: + - include: drop-function + - include: drop-index + - include: drop-table + - include: drop-other + - include: else-pop + + drop-function: + - match: \b{{ddl_target_function}}\b + scope: keyword.other.ddl.sql + set: + - drop-function-args + - expect-function-name + - drop-function-condition + + drop-function-condition: + - meta_include_prototype: false + - include: maybe-condition + + drop-function-args: + - meta_include_prototype: false + - meta_scope: meta.function.sql + - include: immediately-pop + + drop-index: + - match: \b(?i:index)\b + scope: keyword.other.ddl.sql + set: + - drop-index-args + - expect-index-name + - drop-index-condition + + drop-index-condition: + - meta_include_prototype: false + - include: maybe-condition + + drop-index-args: + - meta_scope: meta.index.sql + - include: maybe-on-table-name + + drop-table: + - match: \b(?i:(?:({{ddl_target_table_modifier}})\s+)?(table))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + set: + - drop-table-args + - expect-table-name + - drop-table-condition + + drop-table-condition: + - meta_include_prototype: false + - include: maybe-condition + + drop-table-args: + - meta_include_prototype: false + - meta_scope: meta.table.sql + - include: immediately-pop + + drop-other: + - match: \b(?i:user)\b + scope: storage.type.sql + set: + - expect-user-name + - maybe-condition + - match: \b{{ddl_target_other}}\b + scope: keyword.other.ddl.sql + set: + - drop-other-args + - expect-other-name + - drop-other-condition + + drop-other-condition: + - meta_include_prototype: false + - include: maybe-condition + + drop-other-args: + - include: maybe-on-table-name + +###[ DDL ALTER STATEMENTS ]#################################################### + + alter-statements: + - match: \b(?i:alter)\b + scope: keyword.other.ddl.sql + push: + - alter-meta + - alter-target + + alter-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.alter.sql + - include: immediately-pop + + alter-target: + - include: alter-function + - include: alter-index + - include: alter-table + - include: alter-other + - include: else-pop + +###[ DDL ALTER FUNCTION STATEMENTS ]########################################### + + alter-function: + - match: \b(?:({{ddl_target_function_modifier}})\s+)?({{ddl_target_function}})\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + set: + - expect-function-characteristics + - expect-function-parameters + - expect-function-name + - alter-function-condition + + alter-function-condition: + - meta_include_prototype: false + - include: maybe-condition + +###[ DDL ALTER INDEX STATEMENTS ]############################################## + + alter-index: + - match: \b(?i:(?:({{ddl_target_index_modifier}})\s+)?(index))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + set: + - alter-index-args + - expect-index-name + - alter-index-condition + + alter-index-condition: + - meta_include_prototype: false + - include: maybe-condition + + alter-index-args: + - include: alter-common + - include: pop-on-top-level-reserved-word + - include: expressions-or-column-names + +###[ DDL ALTER TABLE STATEMENTS ]############################################## + + alter-table: + - match: \b(?i:(?:({{ddl_target_table_modifier}})\s+)?(table))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + set: + - alter-table-args + - expect-table-name + - alter-table-condition + + alter-table-condition: + - meta_include_prototype: false + - include: maybe-condition + + alter-table-args: + - include: alter-columns + - include: alter-common + - include: pop-on-top-level-reserved-word + - include: expressions-or-column-names + + alter-other: + - match: \b{{ddl_target_other}}\b + scope: keyword.other.ddl.sql + set: + - alter-other-args + - expect-other-name + - alter-other-condition + + alter-other-condition: + - meta_include_prototype: false + - include: maybe-condition + + alter-other-args: + - include: alter-common + - include: else-pop + + alter-columns: + - match: \b(?i:(?:(add|alter)\b(?:\s+(column)\b|(?!\s+(?:table|{{ddl_target_inside_alter_table}})\b)))) + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + push: + - expect-type + - expect-column-name-declaration + - match: \b(?i:(drop)(?:\s+(column)\b|(?!\s+{{ddl_target}}\b))) + scope: keyword.other.ddl.sql + push: expect-column-name + + alter-common: + - match: \b(?i:(add)\s+(constraint))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + push: + - maybe-column-modifier + - expect-constraint-name + - match: \b(?i:(add)\s+(?:({{ddl_target_index_modifier}})\s+)?(index))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + 3: keyword.other.ddl.sql + - match: \b(?i:(add)\s+(primary|foreign)\s+(key))\b + captures: + 1: keyword.other.ddl.sql + 2: keyword.other.ddl.sql + 3: keyword.other.ddl.sql + +###[ DDL STATEMENT PROTOTYPES ]################################################ + + maybe-on-table-name: + - include: on-table-names + - include: else-pop + + on-table-names: + - match: \b(?i:on)\b + scope: keyword.other.sql + push: expect-table-name + +###[ DML STATEMENTS ]########################################################## + + dml-statements: + - match: \b(?i:select)\b + scope: keyword.other.dml.sql + - match: \b(?i:union(?:\s+all)?)\b + scope: keyword.other.dml.sql + - match: \b(?i:(?:delete(?:\s+from)?))\b + scope: keyword.other.dml.sql + push: dml-delete + - match: \b(?i:update)\b + scope: keyword.other.dml.sql + push: dml-update + - match: \b(?i:(?:insert\s+into|truncate))\b + scope: keyword.other.dml.sql + push: expect-table-name + - include: set-statements + # expressions + - match: \b(?i:(?:default\s+)?values)\b + scope: keyword.other.dml.II.sql + - include: distinct + - include: join-expressions + - match: \b(?i:group\s+by|order\s+by|having|where)\b + scope: keyword.other.dml.sql + - match: \b(?i:from)\b + scope: keyword.other.dml.sql + push: table-name-or-subquery + - match: \b(?i:asc|desc)\b + scope: keyword.other.order.sql + + dml-delete: + - include: expect-table-name + + dml-update: + - match: (?={{simple_identifier}}\s*=) + pop: 1 + - include: expect-table-name + + distinct: + - match: \b(?i:distinct)\b + scope: keyword.other.dml.sql + + join-expressions: + - match: \b(?i:(?:(?:cross|inner|(?:full|left|right)(?:\s+outer)?)\s+)?join)\b + scope: keyword.other.dml.sql + push: + - join-condition + - table-name-or-subquery + + join-condition: + - match: \b(?i:on)\b + scope: keyword.control.conditional.sql + set: conditional-expression + - include: else-pop + + conditional-expression: + - match: (?=[,;)}]|\b(?:{{toplevel_reserved}}|{{additional_toplevel_reserved}})\b) + pop: 1 + - include: expressions + - include: expect-column-names + +###[ DML SET STATEMENTS ]###################################################### + + set-statements: + - match: \b(?i:set)\b(?!\s*\() + scope: keyword.other.dml.sql + push: + - set-meta + - set-target + + set-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.set.sql + - include: immediately-pop + + set-target: + - include: else-pop + +###[ GRANT STATEMENTS ]######################################################## + + grant-statements: + - match: \b(?i:grant(?:\s+with\s+grant\s+option)?)\b + scope: keyword.other.authorization.sql + push: + - grant-meta + - grant + + grant-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.grant.sql + - include: immediately-pop + +###[ REVOKE STATEMENTS ]####################################################### + + revoke-statements: + - match: \b(?i:revoke)\b + scope: keyword.other.ddl.sql + push: + - revoke-meta + - grant + + revoke-meta: + - meta_include_prototype: false + - meta_scope: meta.statement.revoke.sql + - include: immediately-pop + +###[ OTHER STATEMENTS ]######################################################## + + other-statements: [] + +###[ EXPRESSIONS ]############################################################# + + expressions-or-column-names: + - include: wildcard-identifiers + - include: expressions + - include: expect-column-names + + expressions: + - include: groups + - include: comma-separators + - include: operators + - include: column-alias-expressions + - include: case-expressions + - include: collate-expressions + - include: constraint-expressions + - include: literals-and-variables + - include: function-calls + - include: illegal-stray-brackets + - include: illegal-stray-parens + - match: (?=;) + pop: 1 + + column-alias-expressions: + - match: \b(?i:as)\b + scope: keyword.operator.assignment.alias.sql + push: expect-column-alias-name + + table-alias-expression: + - match: \b(?i:as)\b + scope: keyword.operator.assignment.alias.sql + set: expect-table-alias-name + + case-expressions: + - match: \b(?i:case)\b + scope: keyword.control.conditional.case.sql + push: inside-case-expression + + inside-case-expression: + - meta_scope: meta.statement.conditional.case.sql + - match: \b(?i:end)\b + scope: keyword.control.conditional.end.sql + pop: 1 + - match: \b(?i:(case)\s+(when))\b + captures: + 1: keyword.control.conditional.case.sql + 2: keyword.control.conditional.when.sql + - match: \b(?i:when)\b + scope: keyword.control.conditional.when.sql + - match: \b(?i:then)\b + scope: keyword.control.conditional.then.sql + - match: \b(?i:else)\b + scope: keyword.control.conditional.else.sql + - include: expressions-or-column-names + + collate-expressions: + - match: \b(?i:collate)\b + scope: keyword.other.sql + push: inside-collate-expression + + inside-collate-expression: + - match: '{{simple_identifier}}' + scope: support.constant.sql + pop: 1 + - include: else-pop + + constraint-expressions: + - match: \b(?i:constraint)\b + scope: storage.modifier.sql + push: expect-constraint-name + + maybe-check: + - match: \b(?i:check)\b + scope: keyword.other.sql + set: maybe-group + - include: else-pop + + maybe-column: + - match: \b(?i:column)\b + scope: keyword.other.ddl.sql + pop: 1 + - include: else-pop + + maybe-to: + - match: \b(?i:to)\b + scope: keyword.other.ddl.sql + pop: 1 + - include: else-pop + +###[ FUNCTION EXPRESSIONS ]#################################################### + + function-calls: + - include: built-in-aggregate-function-calls + - include: built-in-scalar-function-calls + - include: built-in-user-function-calls + - include: user-defined-function-calls + + built-in-aggregate-function-calls: + # List of SQL99 built-in functions from http://www.oreilly.com/catalog/sqlnut/chapter/ch04.html + - match: \b(?i:AVG|COUNT|MIN|MAX|SUM)(?=\s*\() + scope: support.function.aggregate.sql + push: function-call-arguments + + built-in-scalar-function-calls: + # List of SQL99 built-in functions from http://www.oreilly.com/catalog/sqlnut/chapter/ch04.html + - match: \b{{builtin_scalar_functions}}\b + scope: support.function.scalar.sql + push: function-call-arguments + + built-in-user-function-calls: + - match: \b{{builtin_user_functions}}\b + scope: support.function.user.sql + push: function-call-arguments + + built-in-user-function-call: + - match: \b{{builtin_user_functions}}\b + scope: support.function.user.sql + set: function-call-arguments + + user-defined-function-calls: + - match: \b{{simple_identifier}}(?=\s*\() + scope: support.function.sql + push: function-call-arguments + + function-call-arguments: + - meta_include_prototype: false + - meta_scope: meta.function-call.sql + - match: \( + scope: meta.group.sql punctuation.section.arguments.begin.sql + set: inside-function-call-arguments + - include: else-pop + + inside-function-call-arguments: + - meta_content_scope: meta.function-call.sql meta.group.sql + - match: \) + scope: meta.function-call.sql meta.group.sql punctuation.section.arguments.end.sql + pop: 1 + - match: ',' + scope: punctuation.separator.arguments.sql + - include: distinct + - include: expressions-or-column-names + +###[ GROUPS EXPRESSIONS ]###################################################### + + maybe-group: + - include: group + - include: else-pop + + group: + - match: \( + scope: punctuation.section.group.begin.sql + set: inside-group + + groups: + - match: \( + scope: punctuation.section.group.begin.sql + push: inside-group + + inside-group: + - meta_scope: meta.group.sql + - match: \) + scope: punctuation.section.group.end.sql + pop: 1 + - include: sql + +###[ COLUMN EXPRESSIONS ]###################################################### + + expect-column-declaration: + - include: column-declaration-list + - match: (?=\S) + set: + - maybe-column-modifier + - after-type + - expect-type + - column-name-declaration + - single-identifier + + maybe-column-declaration-list: + - include: column-declaration-list + - include: else-pop + + column-declaration-list: + - match: \( + scope: punctuation.section.group.begin.sql + set: inside-column-declaration-list + + inside-column-declaration-list: + - meta_scope: meta.group.table-columns.sql + - match: \) + scope: punctuation.section.group.end.sql + pop: 1 + - include: column-modifiers + - include: expressions + - include: expect-column-declarations + + expect-column-declarations: + - match: (?=\S) + push: + - maybe-column-modifier + - after-type + - expect-type + - column-name-declaration + - single-identifier + + maybe-column-modifier: + - include: column-modifiers + - include: else-pop + + column-modifiers: + - match: \b(?i:check)\b + scope: keyword.other.sql + - match: |- + \b(?xi: + (?: (?: fulltext | primary | unique ) \s+ )? key + | on \s+ (?: delete | update ) (?: \s+ cascade )? + | default + )\b + scope: storage.modifier.sql + - match: |- + \b(?xi: + foreign\s+key + )\b + scope: storage.modifier.sql + push: column-name-list + - match: \b(?i:unique)\b + scope: storage.modifier.sql + push: maybe-column-name-list + - match: \b(?i:references)\b + scope: storage.modifier.sql + push: + - maybe-column-name-list + - expect-table-name + + maybe-column-name-list: + - include: column-name-list + - include: else-pop + + column-name-list: + - match: \( + scope: punctuation.section.group.begin.sql + set: inside-column-name-list + + column-name-lists: + - match: \( + scope: punctuation.section.group.begin.sql + push: inside-column-name-list + + inside-column-name-list: + - meta_scope: meta.group.table-columns.sql + - match: \) + scope: punctuation.section.group.end.sql + pop: 1 + - include: expressions-or-column-names + +###[ FUNCTION EXPRESSIONS ]#################################################### + + expect-function-parameters: + - match: \( + scope: punctuation.section.group.begin.sql + set: inside-function-parameters + - include: else-pop + + inside-function-parameters: + - clear_scopes: 1 + - meta_scope: meta.function.parameters.sql meta.group.sql + - match: \) + scope: punctuation.section.group.end.sql + pop: 1 + - include: comma-separators + - match: (?=\S) + push: + - expect-type + - expect-parameter-name + - maybe-parameter-modifier + + expect-parameter-name: + - match: '{{simple_identifier}}' + scope: variable.parameter.sql + pop: 1 + - include: else-pop + + maybe-parameter-modifier: + - match: \b{{function_parameter_modifier}}\b + scope: storage.modifier.sql + pop: 1 + - include: else-pop + + expect-function-characteristics: + - meta_scope: meta.function.sql + - match: \b(?i:as|return)\b + scope: keyword.context.block.sql + pop: 1 + - match: \b(?i:language)\b + scope: storage.modifier.sql + push: expect-function-language-name + - match: \b(?i:returns)\b + scope: keyword.other.ddl.sql + push: expect-type + - include: create-common-args + + expect-function-language-name: + - match: '{{simple_identifier}}' + scope: constant.other.language.sql + pop: 1 + - include: else-pop + +###[ USER MANAGEMENT EXPRESSIONS ]############################################# + + grant: + - match: \b(?i:to)\b + scope: keyword.context.sql + push: expect-user-name + - include: comma-separators + - include: user-privileges + - include: pop-on-top-level-reserved-word + + user-privileges: + - include: column-name-lists + - match: \b(?i:all(?:\s+privileges)?)\b + scope: constant.language.sql + - match: \b(?i:(?:alter|create|drop|grant|revoke)\s+{{ddl_target}})\b + scope: constant.language.sql + - match: \b(?i:select|insert|update|delete|truncate|execute)\b + scope: constant.language.sql + +###[ TABLE NAMES OR SUBQUERIES ]############################################### + + table-name-or-subquery: + - meta_include_prototype: false + - include: table-subquery + - include: table-name-or-function-call + + table-subquery: + - match: (?=\() + set: + - maybe-table-alias + - group + + table-name-or-function-call: + - match: (?=\S) + pop: 1 # pop `table-name-or-subquery` before evaluating branches + branch_point: table-name-or-function-call + branch: + - table-name-not-function-call + - table-valued-function-call + + table-name-not-function-call: + - meta_include_prototype: false + - match: '' + set: + - maybe-table-alias + - table-name-fail-if-function-call + - table-name + - single-identifier + + table-name-fail-if-function-call: + - meta_include_prototype: false + - match: (?=\() + fail: table-name-or-function-call + - match: (?=\S) + pop: 1 + + table-valued-function-call: + - meta_include_prototype: false + - match: '' + set: + - maybe-table-alias + - function-call-arguments + - table-valued-function-name + - single-identifier + + table-valued-function-name: + - meta_include_prototype: false + - meta_content_scope: meta.table-valued-function-name.sql + - include: immediately-pop + + maybe-table-alias: + - include: pop-on-top-level-reserved-word + - include: table-timespecs + - include: table-alias-expression + - include: expect-table-alias-name + + table-timespecs: + - match: \b(?i:for\s+system_time)\b + scope: keyword.other.dml.sql + push: table-timespec-args + + table-timespec-args: + - match: \b(?i:as\s+of|between|and|from|to)\b + scope: keyword.operator.logical.sql + push: + - table-timespec-expression + - table-timespec-type + - match: \b(?i:all)\b + scope: constant.other.sql + pop: 1 + - include: else-pop + + table-timespec-type: + - match: \b(?i:timestamp|transaction)\b + scope: storage.type.sql + set: else-pop + - include: else-pop + + table-timespec-expression: + - include: expressions + - include: immediately-pop + +###[ TYPES ]################################################################### + + expect-type: + - meta_include_prototype: false + - include: comments + - include: built-in-type + - include: expect-user-type + + built-in-types: + - match: \b(?i:enum)\b + scope: storage.type.sql + push: + - after-type + - maybe-group + - match: |- + (?x) + \b(?: {{simple_types}} | {{types_with_optional_number}} ) + (?: ((\()(\d+)(?:\s*(,)\s*(\d+))?(\)) | \b(?!\s*\() ) ) + scope: storage.type.sql + captures: + 1: meta.parens.sql + 2: punctuation.definition.parens.begin.sql + 3: meta.number.integer.decimal.sql constant.numeric.value.sql + 4: punctuation.separator.sequence.sql + 5: meta.number.integer.decimal.sql constant.numeric.value.sql + 6: punctuation.definition.parens.end.sql + push: after-type + - match: \b{{type_modifiers}}\b + scope: storage.modifier.sql + + built-in-type: + - match: \b(?i:enum)\b + scope: storage.type.sql + set: + - after-type + - maybe-group + - match: |- + (?x) + \b(?: {{simple_types}} | {{types_with_optional_number}} ) + (?: ((\()(\d+)(?:\s*(,)\s*(\d+))?(\)) | \b(?!\s*\() ) ) + scope: storage.type.sql + captures: + 1: meta.parens.sql + 2: punctuation.definition.parens.begin.sql + 3: meta.number.integer.decimal.sql constant.numeric.value.sql + 4: punctuation.separator.sequence.sql + 5: meta.number.integer.decimal.sql constant.numeric.value.sql + 6: punctuation.definition.parens.end.sql + set: after-type + + expect-user-type: + - match: (?=\S) + set: [maybe-group, after-type, inside-user-type] + + inside-user-type: + # note: may contain foreign variable interpolation + - meta_scope: support.type.sql + - match: '{{simple_identifier_break}}' + pop: 1 + + after-type: + - match: \b{{type_modifiers}}\b + scope: storage.modifier.sql + pop: 1 + - include: assignment-operators + - include: else-pop + +###[ IDENTIFIERS ]############################################################# + + expect-table-alias-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [table-alias-name, single-identifier] + + expect-column-alias-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [column-alias-name, single-identifier] + + table-alias-name: + - meta_include_prototype: false + - meta_content_scope: meta.alias.table.sql + - include: immediately-pop + + column-alias-name: + - meta_include_prototype: false + - meta_content_scope: meta.alias.column.sql + - include: immediately-pop + + expect-column-names: + - match: (?=\S) + push: [maybe-operator, column-name, single-identifier] + + expect-column-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [column-name, single-identifier] + + column-name: + - meta_include_prototype: false + - meta_content_scope: meta.column-name.sql + - include: immediately-pop + + expect-column-name-declaration: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [column-name-declaration, single-identifier] + + column-name-declaration: + - meta_include_prototype: false + - meta_content_scope: meta.column-name.sql variable.other.member.declaration.sql + - include: immediately-pop + + expect-constraint-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - match: (?=(?i:check|foreign|primary|unique|index|key|using|with)\b) + pop: 1 + - include: comments + - match: (?=\S) + set: [constraint-name, single-identifier] + + constraint-name: + - meta_include_prototype: false + - meta_content_scope: meta.constraint-name.sql + - include: immediately-pop + + expect-database-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [database-creation-name, single-identifier] + + database-creation-name: + - meta_include_prototype: false + - meta_content_scope: entity.name.struct.database.sql + - include: immediately-pop + + expect-database-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [database-name, single-identifier] + + database-name: + - meta_include_prototype: false + - meta_content_scope: meta.database-name.sql + - include: immediately-pop + + expect-event-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [event-creation-name, single-identifier] + + event-creation-name: + - meta_include_prototype: false + - meta_scope: entity.name.event.sql + - include: immediately-pop + + expect-event-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [event-name, single-identifier] + + event-name: + - meta_include_prototype: false + - meta_scope: meta.event-name.sql + - include: immediately-pop + + expect-index-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [index-creation-name, single-identifier] + + index-creation-name: + - meta_include_prototype: false + - meta_scope: entity.name.struct.index.sql + - include: immediately-pop + + expect-index-names: + - match: (?=\S) + push: [index-name, single-identifier] + + expect-index-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [index-name, single-identifier] + + index-name: + - meta_include_prototype: false + - meta_scope: meta.index-name.sql + - include: immediately-pop + + expect-function-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [procedure-creation-name, single-identifier] + + expect-partition-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [partition-creation-name, single-identifier] + + partition-creation-name: + - meta_include_prototype: false + - meta_scope: entity.name.struct.partition.sql + - include: immediately-pop + + expect-partition-names: + - match: (?=\S) + push: [partition-name, single-identifier] + + expect-partition-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [partition-name, single-identifier] + + partition-name: + - meta_include_prototype: false + - meta_scope: meta.partition-name.sql + - include: immediately-pop + + procedure-creation-name: + - meta_include_prototype: false + - meta_content_scope: entity.name.function.sql + - include: immediately-pop + + expect-function-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [procedure-name, single-identifier] + + procedure-name: + - meta_include_prototype: false + - meta_content_scope: meta.procedure-name.sql + - include: immediately-pop + + expect-table-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [table-creation-name, single-identifier] + + table-creation-name: + - meta_include_prototype: false + - meta_scope: entity.name.struct.table.sql + - include: immediately-pop + + expect-table-names: + - match: (?=\S) + push: [table-name, single-identifier] + + expect-table-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [table-name, single-identifier] + + table-name: + - meta_include_prototype: false + - meta_content_scope: meta.table-name.sql + - include: immediately-pop + + expect-user-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - include: built-in-user-function-call + - match: (?=\S) + set: [user-name, single-identifier] + + user-name: + - meta_include_prototype: false + - meta_content_scope: meta.username.sql + - include: immediately-pop + + expect-user-name-declaration: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [user-name-declaration, single-identifier] + + user-name-declaration: + - meta_include_prototype: false + - meta_content_scope: entity.name.user.sql + - include: immediately-pop + + expect-type-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [type-creation-name, single-identifier] + + type-creation-name: + - meta_include_prototype: false + - meta_scope: entity.name.type.cql + - include: immediately-pop + + expect-other-creation-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [other-creation-name, single-identifier] + + other-creation-name: + - meta_include_prototype: false + - meta_scope: entity.name.struct.other.sql + - include: immediately-pop + + expect-other-name: + # prevent prototypes from inheriting syntaxes + - meta_include_prototype: false + - include: comments + - match: (?=\S) + set: [other-name, single-identifier] + + other-name: + - meta_include_prototype: false + - meta_scope: meta.other-name.sql + - include: immediately-pop + + single-identifier: + - meta_include_prototype: false + - include: pop-on-top-level-reserved-word + - match: '' + set: + - maybe-identifier-accessor + - identifier-part + + maybe-identifier-accessor: + - meta_include_prototype: false + - match: \s*(\.)\s*(\*) + captures: + 1: punctuation.accessor.dot.sql + 2: constant.other.wildcard.asterisk.sql + pop: 1 + - match: \s*(\.) + captures: + 1: punctuation.accessor.dot.sql + set: single-identifier + - include: immediately-pop + + identifier-part: + - meta_include_prototype: false + - include: backtick-quoted-identifier-part + - include: double-quoted-identifier-part + - include: single-quoted-identifier-part + - include: simple-identifier-part + + backtick-quoted-identifier-part: + - match: \` + scope: punctuation.definition.identifier.begin.sql + set: inside-backtick-quoted-identifier-part + + inside-backtick-quoted-identifier-part: + # note: may contain foreign variable interpolation + - match: \` + scope: punctuation.definition.identifier.end.sql + pop: 1 + + double-quoted-identifier-part: + - match: \" + scope: punctuation.definition.identifier.begin.sql + set: inside-double-quoted-identifier-part + + inside-double-quoted-identifier-part: + # note: may contain foreign variable interpolation + - match: \" + scope: punctuation.definition.identifier.end.sql + pop: 1 + + single-quoted-identifier-part: + - match: \' + scope: punctuation.definition.identifier.begin.sql + set: inside-single-quoted-identifier-part + + inside-single-quoted-identifier-part: + # note: may contain foreign variable interpolation + - match: \' + scope: punctuation.definition.identifier.end.sql + pop: 1 + + simple-identifier-part: + - match: (?=\S) + set: inside-simple-identifier-part + + inside-simple-identifier-part: + # note: may contain foreign variable interpolation + - match: '{{simple_identifier_break}}' + pop: 1 + + wildcard-identifiers: + - match: \* + scope: constant.other.wildcard.asterisk.sql + +###[ LITERALS ]################################################################ + + literals-and-variables: + - include: built-in-types + - include: constants + - include: numbers + - include: strings + + constants: + - match: \b(?i:null)\b + scope: constant.language.null.sql + + booleans: + - match: \b(?i:true)\b + scope: constant.language.boolean.true.sql + - match: \b(?i:false)\b + scope: constant.language.boolean.false.sql + + numbers: + - match: \b\d+(\.)\d+\b + scope: meta.number.float.decimal.sql constant.numeric.value.sql + captures: + 1: punctuation.separator.decimal.sql + - match: \b\d+\b + scope: meta.number.integer.decimal.sql constant.numeric.value.sql + + strings: + - match: \' + scope: punctuation.definition.string.begin.sql + push: inside-single-quoted-string + + inside-single-quoted-string: + - meta_include_prototype: false + - meta_scope: meta.string.sql string.quoted.single.sql + - match: \'\' + scope: constant.character.escape.sql + - match: \' + scope: punctuation.definition.string.end.sql + pop: 1 + - include: string-escapes + + string-escapes: + - match: '{{string_escape}}' + scope: constant.character.escape.sql + +###[ LIKE EXPRESSIONS ]######################################################## + + like-expressions: + - match: \b(?i:like)\b + scope: keyword.operator.logical.sql + branch_point: like-expressions + branch: + - like-string-not-followed-by-escape + - like-string-followed-by-escape-slash + - like-string-followed-by-escape-caret + - like-string-followed-by-escape-hash + - like-string-followed-by-unknown-escape + + like-string-not-followed-by-escape: + - meta_include_prototype: false + - match: \' + scope: punctuation.definition.string.begin.sql + set: + - like-escape-fail + - inside-like-single-quoted-string + - include: else-pop + + like-string-followed-by-escape-slash: + - meta_include_prototype: false + - match: \' + scope: punctuation.definition.string.begin.sql + set: + - like-escape-character-slash + - like-escape + - inside-like-single-quoted-string-slash-escape + - include: else-pop + + like-string-followed-by-escape-caret: + - meta_include_prototype: false + - match: \' + scope: punctuation.definition.string.begin.sql + set: + - like-escape-character-caret + - like-escape + - inside-like-single-quoted-string-caret-escape + - include: else-pop + + like-string-followed-by-escape-hash: + - meta_include_prototype: false + - match: \' + scope: punctuation.definition.string.begin.sql + set: + - like-escape-character-hash + - like-escape + - inside-like-single-quoted-string-hash-escape + - include: else-pop + + like-string-followed-by-unknown-escape: + - meta_include_prototype: false + - match: \' + scope: punctuation.definition.string.begin.sql + set: + - like-escape-character-any + - like-escape + - inside-like-single-quoted-string + - include: else-pop + + inside-like-single-quoted-string-slash-escape: + - meta_include_prototype: false + - meta_scope: meta.string.like.sql string.quoted.single.sql + - match: \\. + scope: constant.character.escape.sql + - include: inside-like-single-quoted-string + + inside-like-single-quoted-string-caret-escape: + - meta_include_prototype: false + - meta_scope: meta.string.like.sql string.quoted.single.sql + - match: \^. + scope: constant.character.escape.sql + - include: inside-like-single-quoted-string + + inside-like-single-quoted-string-hash-escape: + - meta_include_prototype: false + - meta_scope: meta.string.like.sql string.quoted.single.sql + - match: '#.' + scope: constant.character.escape.sql + - include: inside-like-single-quoted-string + + inside-like-single-quoted-string: + - meta_include_prototype: false + - meta_scope: meta.string.like.sql string.quoted.single.sql + - match: \' + scope: punctuation.definition.string.end.sql + pop: 1 + - match: '%' + scope: constant.other.wildcard.percent.sql + - match: '_' + scope: constant.other.wildcard.underscore.sql + + like-else-fail: + - match: (?=\S) + fail: like-expressions + + like-escape-fail: + - match: \b(?i:escape)\b + fail: like-expressions + - include: else-pop + + like-escape: + - match: \b(?i:escape)\b + scope: keyword.operator.word.sql + pop: 1 + - include: else-pop + + like-escape-character-any: + - meta_include_prototype: false + - match: (\')([^'])(\') + scope: meta.string.escape.sql string.quoted.single.sql + captures: + 1: punctuation.definition.string.begin.sql + 2: constant.character.escape.sql + 3: punctuation.definition.string.end.sql + pop: 1 + - include: else-pop + + like-escape-character-caret: + - meta_include_prototype: false + - match: (\')(\^)(\') + scope: meta.string.escape.sql string.quoted.single.sql + captures: + 1: punctuation.definition.string.begin.sql + 2: constant.character.escape.sql + 3: punctuation.definition.string.end.sql + pop: 1 + - include: like-else-fail + + like-escape-character-slash: + - meta_include_prototype: false + - match: (\')(\\)(\') + scope: meta.string.escape.sql string.quoted.single.sql + captures: + 1: punctuation.definition.string.begin.sql + 2: constant.character.escape.sql + 3: punctuation.definition.string.end.sql + pop: 1 + - include: like-else-fail + + like-escape-character-hash: + - meta_include_prototype: false + - match: (\')(#)(\') + scope: meta.string.escape.sql string.quoted.single.sql + captures: + 1: punctuation.definition.string.begin.sql + 2: constant.character.escape.sql + 3: punctuation.definition.string.end.sql + pop: 1 + - include: like-else-fail + +###[ OPERATORS ]############################################################### + + maybe-condition: + - meta_include_prototype: false + - include: conditions + - include: else-pop + + conditions: + - match: \b(?i:if)\b + scope: keyword.control.conditional.if.sql + - include: logical-operators + + maybe-operator: + - meta_include_prototype: false + - match: '<=>|[!<>]?=|<>|<|>' + scope: keyword.operator.comparison.sql + pop: 1 + - match: '[-+/*]' + scope: keyword.operator.arithmetic.sql + pop: 1 + - match: \b(?i:and|or|having|exists|between|in|not|is)\b + scope: keyword.operator.logical.sql + pop: 1 + - include: assignment-operators + - include: else-pop + + operators: + - match: '<=>|[!<>]?=|<>|<|>' + scope: keyword.operator.comparison.sql + - match: '[-+/*]' + scope: keyword.operator.arithmetic.sql + - include: logical-operators + + assignment-operators: + - match: '=' + scope: keyword.operator.assignment.sql + + logical-operators: + - match: \b(?i:and|or|having|exists|between|in|not|is)\b + scope: keyword.operator.logical.sql + + comma-separators: + - match: ',' + scope: punctuation.separator.sequence.sql + + statement-terminators: + - match: ';' + scope: punctuation.terminator.statement.sql + +###[ ILLEGALS ]################################################################ + + illegal-stray-brackets: + - match: \] + scope: invalid.illegal.stray.sql + + illegal-stray-parens: + - match: \) + scope: invalid.illegal.stray.sql + +###[ PROTOTYPES ]############################################################## + + else-pop: + - match: (?=\S) + pop: 1 + + immediately-pop: + - match: '' + pop: 1 + + pop-on-top-level-reserved-word: + - match: (?=[;)}]|\b(?:{{toplevel_reserved}}|{{additional_toplevel_reserved}})\b) + pop: 1 diff --git a/cli/app.rs b/cli/app.rs index 999dd935d..221311402 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -235,6 +235,7 @@ impl<'a> Limbo<'a> { opts: Settings::from(&opts), rl, }; + if opts.sql.is_some() { app.handle_first_input(opts.sql.as_ref().unwrap()); } diff --git a/cli/helper.rs b/cli/helper.rs index 3d809741f..e8e886946 100644 --- a/cli/helper.rs +++ b/cli/helper.rs @@ -5,6 +5,10 @@ use limbo_core::{Connection, StepResult}; use rustyline::completion::{extract_word, Completer, Pair}; use rustyline::highlight::Highlighter; use rustyline::{Completer, Helper, Hinter, Validator}; +use syntect::easy::HighlightLines; +use syntect::highlighting::{Style, ThemeSet}; +use syntect::parsing::SyntaxSet; +use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; macro_rules! try_result { ($expr:expr, $err:expr) => { @@ -19,17 +23,67 @@ macro_rules! try_result { pub struct LimboHelper { #[rustyline(Completer)] completer: SqlCompleter, + syntax_set: SyntaxSet, + theme_set: ThemeSet, } impl LimboHelper { pub fn new(conn: Rc, io: Arc) -> Self { + // Load only predefined syntax + let ps = SyntaxSet::load_defaults_newlines(); + let ts = ThemeSet::load_defaults(); LimboHelper { completer: SqlCompleter::new(conn, io), + syntax_set: ps, + theme_set: ts, } } } -impl Highlighter for LimboHelper {} +impl Highlighter for LimboHelper { + fn highlight<'l>(&self, line: &'l str, pos: usize) -> std::borrow::Cow<'l, str> { + let _ = pos; + // TODO use lifetimes to store highlight lines + let syntax = self.syntax_set.find_syntax_by_extension("sql").unwrap(); + let mut h = HighlightLines::new(syntax, &self.theme_set.themes["base16-ocean.dark"]); + let mut ret_line = String::new(); + for new_line in LinesWithEndings::from(line) { + let ranges: Vec<(Style, &str)> = h.highlight_line(new_line, &self.syntax_set).unwrap(); + let escaped = as_24_bit_terminal_escaped(&ranges[..], false); + ret_line.push_str(&escaped); + } + // Push this escape sequence to reset + // ret_line.push_str("\x1b[0m"); + std::borrow::Cow::Owned(ret_line) + } + + fn highlight_prompt<'b, 's: 'b, 'p: 'b>( + &'s self, + prompt: &'p str, + default: bool, + ) -> std::borrow::Cow<'b, str> { + let _ = default; + std::borrow::Cow::Owned(format!("\x1b[1;32m{}\x1b[0m", prompt)) + } + + fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> { + std::borrow::Cow::Borrowed(hint) + } + + fn highlight_candidate<'c>( + &self, + candidate: &'c str, + completion: rustyline::CompletionType, + ) -> std::borrow::Cow<'c, str> { + let _ = completion; + std::borrow::Cow::Borrowed(candidate) + } + + fn highlight_char(&self, line: &str, pos: usize, kind: rustyline::highlight::CmdKind) -> bool { + let _ = (line, pos, kind); + true + } +} pub struct SqlCompleter { conn: Rc, From 2f38740b27b301779e9614b955b6b1e66d5a3d04 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Tue, 4 Mar 2025 22:20:50 -0300 Subject: [PATCH 02/10] generated syntax dump --- cli/SQL_syntax_set_dump.packdump | Bin 0 -> 8665 bytes cli/helper.rs | 23 +++++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 cli/SQL_syntax_set_dump.packdump diff --git a/cli/SQL_syntax_set_dump.packdump b/cli/SQL_syntax_set_dump.packdump new file mode 100644 index 0000000000000000000000000000000000000000..bc86ed0f15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ns0w1rCNyrYPQi*w+v1!s=p(~CQZ~6H$#2X$~>HPR}^HDSHZAmX#?5%Pc#YXVK zd-&6^Io0lC5VNrfM`3}kY$z%la_e7`>S*#~bt09Ow8+u9v>p^qb3M_S-MSDGs9#95(!vj)A~6`U&M)7K-7i zUJ87NnU^{0jj2VYdQ6$Y4drvE!kOFghk6iG&?0+O>MPH+Qj&}B$jtuXbyF?)NXO8L z&C0iUDdnnUu6LOS=FL#(RZ<3lhJ#3@#tz5mr=-+oUka-OYguqT_A@daB^0-t+Hyx?tWn* zgF?nZ5f<`o>T3<>{5(hrG*hKyyIl=;j4xX^zXqfdUA?0Wb>FLuE>zf+JCa{|*|x)2 z3V5O|{skW*URXbu72{LgdNPZp3o%pWW@?%$a|U`i9wdAEXB~IAAGf^j*dr>1v?*}fjIMnBdaB1SO4K@j z@-4;#xreJX`py`8WKHI8n#^yf@v7b4>K&*)*_5TZ41=|CejH|kz9U^kBp;VF=q&USY>gAxJ!bsDwB3HMYkSUQ zzL6FOMA5(`+ga^w$XG-}wL+c}eMmf9psG3aneu4QiZwriTSmV${K_5Y7~jYGz?i4g z#ecG9(AvqTCzXAh8j<&OKt0qo?13kxB&}K*gECvd4F)P-aDxD?h!4Ih)oY^rUYjJZ zZNBz(o_lurb02xmg#Z)GR73XXtJ%}>aw>_UJI>d-}>j(>Jb+w6}k(Xtt@uqJ(>U?TCk3iu{HLn(X z;t4>ai(NI{eP3%!9OUCddbgNu(+ORitJ=V=v;x#|t31RD3$(>?Hhq@KGeNFB8V%dN kc7U1+($k`N^Q4s$lDn@bw85>B&Zl0V#VO~1|JR1`e+EI2n*aa+ literal 0 HcmV?d00001 diff --git a/cli/helper.rs b/cli/helper.rs index e8e886946..cc0ca7f48 100644 --- a/cli/helper.rs +++ b/cli/helper.rs @@ -5,9 +5,10 @@ use limbo_core::{Connection, StepResult}; use rustyline::completion::{extract_word, Completer, Pair}; use rustyline::highlight::Highlighter; use rustyline::{Completer, Helper, Hinter, Validator}; +use syntect::dumps::from_uncompressed_data; use syntect::easy::HighlightLines; use syntect::highlighting::{Style, ThemeSet}; -use syntect::parsing::SyntaxSet; +use syntect::parsing::{Scope, SyntaxSet}; use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; macro_rules! try_result { @@ -29,8 +30,18 @@ pub struct LimboHelper { impl LimboHelper { pub fn new(conn: Rc, io: Arc) -> Self { + // Code commented below is used to create a binary dump for the Sublime Syntax + + // let syntax = + // SyntaxDefinition::load_from_str(include_str!("./SQL.sublime-syntax"), false, None) + // .unwrap(); + // let mut ps = SyntaxSet::new().into_builder(); + // ps.add(syntax); + // let ps = ps.build(); + // dump_to_uncompressed_file(&ps, "./SQL_syntax_set_dump.packdump").unwrap(); + // Load only predefined syntax - let ps = SyntaxSet::load_defaults_newlines(); + let ps = from_uncompressed_data(include_bytes!("./SQL_syntax_set_dump.packdump")).unwrap(); let ts = ThemeSet::load_defaults(); LimboHelper { completer: SqlCompleter::new(conn, io), @@ -44,7 +55,10 @@ impl Highlighter for LimboHelper { fn highlight<'l>(&self, line: &'l str, pos: usize) -> std::borrow::Cow<'l, str> { let _ = pos; // TODO use lifetimes to store highlight lines - let syntax = self.syntax_set.find_syntax_by_extension("sql").unwrap(); + let syntax = self + .syntax_set + .find_syntax_by_scope(Scope::new("source.sql").unwrap()) + .unwrap(); let mut h = HighlightLines::new(syntax, &self.theme_set.themes["base16-ocean.dark"]); let mut ret_line = String::new(); for new_line in LinesWithEndings::from(line) { @@ -52,7 +66,7 @@ impl Highlighter for LimboHelper { let escaped = as_24_bit_terminal_escaped(&ranges[..], false); ret_line.push_str(&escaped); } - // Push this escape sequence to reset + // Push this escape sequence to reset // ret_line.push_str("\x1b[0m"); std::borrow::Cow::Owned(ret_line) } @@ -63,6 +77,7 @@ impl Highlighter for LimboHelper { default: bool, ) -> std::borrow::Cow<'b, str> { let _ = default; + // Make prompt bold std::borrow::Cow::Owned(format!("\x1b[1;32m{}\x1b[0m", prompt)) } From b123321692dda7e883aded257ec7f3027673de9a Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Wed, 5 Mar 2025 14:23:34 -0300 Subject: [PATCH 03/10] build script for syntax set dump --- Cargo.lock | 424 +++++++++++++++---------------- cli/Cargo.toml | 4 + cli/SQL.sublime-syntax | 2 +- cli/SQL_syntax_set_dump.packdump | Bin 8665 -> 0 bytes cli/app.rs | 2 +- cli/build.rs | 26 ++ cli/helper.rs | 16 +- 7 files changed, 248 insertions(+), 226 deletions(-) delete mode 100644 cli/SQL_syntax_set_dump.packdump create mode 100644 cli/build.rs diff --git a/Cargo.lock b/Cargo.lock index b4fb40089..07a6d669f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -41,20 +41,20 @@ dependencies = [ [[package]] name = "aligned-vec" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0966165eaf052580bd70eb1b32cb3d6245774c0104d1b2793e9650bf83b52a" +checksum = "af15ccceeacb9304119d97925de463bc97ae3555ee8dc8056f67b119f66e5934" dependencies = [ "equator", ] [[package]] name = "anarchist-readable-name-generator-lib" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18a1e15a87b13ae79e04e07b3714fc41d5f6993dff11662fdbe0b207c6ad0fe0" +checksum = "64ce9adb4750e64d18a46001b931cd3662957f7eefacae1b9cc3454fa00c2af1" dependencies = [ - "rand 0.8.5", + "rand 0.9.0", ] [[package]] @@ -146,9 +146,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.95" +version = "1.0.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" [[package]] name = "arrayref" @@ -231,15 +231,15 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.8.0" +version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" [[package]] name = "blake3" -version = "1.5.5" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8ee0c1824c4dea5b5f81736aff91bae041d2c07ee1192bec91054e10e3e601e" +checksum = "675f87afced0413c9bb02843499dbbd3882a237645883f71a2b59644a6d2f753" dependencies = [ "arrayref", "arrayvec", @@ -270,9 +270,9 @@ dependencies = [ [[package]] name = "built" -version = "0.7.5" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b" +checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" dependencies = [ "chrono", "git2", @@ -280,15 +280,15 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.16.0" +version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" [[package]] name = "bytemuck" -version = "1.21.0" +version = "1.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" +checksum = "b6b1fc10dbac614ebc03540c9dbd60e83887fda27794998c6528f1782047d540" [[package]] name = "byteorder" @@ -298,9 +298,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.9.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" [[package]] name = "cast" @@ -310,9 +310,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.9" +version = "1.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8293772165d9345bdaaa39b45b2109591e63fe5e6fbc23c6ff930a048aa310b" +checksum = "be714c154be609ec7f5dad223a33bf1482fff90472de28f7362806e6d4832b8c" dependencies = [ "jobserver", "libc", @@ -345,16 +345,16 @@ checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487" [[package]] name = "chrono" -version = "0.4.39" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e36cc9d416881d2e24f9a963be5fb1cd90966419ac844274161d10488b3e825" +checksum = "1a7964611d71df112cb1730f2ee67324fcf4d0fc6606acbbe9bfe06df124637c" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets 0.52.6", + "windows-link", ] [[package]] @@ -386,9 +386,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.26" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8eb5e908ef3a6efbe1ed62520fb7287959888c88485abe072543190ecc66783" +checksum = "027bb0d98429ae334a8698531da7077bdf906419543a35a55c2cb1b66437d767" dependencies = [ "clap_builder", "clap_derive", @@ -396,9 +396,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.26" +version = "4.5.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b01801b5fc6a0a232407abc821660c9c6d25a1cafc0d4f85f29fb8d9afc121" +checksum = "5589e0cba072e0f3d23791efac0fd8627b49c829c196a492e88168e6a669d863" dependencies = [ "anstream", "anstyle", @@ -408,14 +408,14 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.24" +version = "4.5.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" +checksum = "bf4ced95c6f4a675af3da73304b9ac4ed991640c36374e4b46795c49e17cf1ed" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -527,9 +527,9 @@ dependencies = [ [[package]] name = "cpufeatures" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16b80225097f2e5ae4e7179dd2266824648f3e2f49d9134d584b76389d31c4c3" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" dependencies = [ "libc", ] @@ -621,7 +621,7 @@ version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "crossterm_winapi", "parking_lot", "rustix", @@ -639,9 +639,9 @@ dependencies = [ [[package]] name = "crunchy" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" [[package]] name = "crypto-common" @@ -667,9 +667,9 @@ dependencies = [ [[package]] name = "csv-core" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5efa2b3d7902f4b634a20cae3c9c4e6209dc4779feb6863329607560143efa70" +checksum = "7d02f3b0da4c6504f86e9cd789d8dbafab48c2321be74e9987593de5a894d93d" dependencies = [ "memchr", ] @@ -686,9 +686,9 @@ dependencies = [ [[package]] name = "data-encoding" -version = "2.7.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e60eed09d8c01d3cee5b7d30acb059b76614c918fa0f992e0dd6eeb10daad6f" +checksum = "575f75dfd25738df5b91b8e43e14d44bda14637a58fae779fd2b064f8bf3e010" [[package]] name = "debugid" @@ -753,7 +753,7 @@ checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -764,9 +764,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "either" -version = "1.13.0" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d" [[package]] name = "endian-type" @@ -822,29 +822,29 @@ dependencies = [ [[package]] name = "equator" -version = "0.2.2" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c35da53b5a021d2484a7cc49b2ac7f2d840f8236a286f84202369bd338d761ea" +checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc" dependencies = [ "equator-macro", ] [[package]] name = "equator-macro" -version = "0.2.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3bf679796c0322556351f287a51b49e48f7c4986e727b5dd78c972d30e2e16cc" +checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] name = "equivalent" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" [[package]] name = "errno" @@ -923,9 +923,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.35" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" +checksum = "11faaf5a5236997af9848be0bef4db95824b1d534ebc64d0f0c6cf3e67bd38dc" dependencies = [ "crc32fast", "miniz_oxide", @@ -1017,7 +1017,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -1099,11 +1099,11 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "git2" -version = "0.19.0" +version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" +checksum = "3fda788993cc341f69012feba8bf45c0ba4f3291fcc08e214b4d5a7332d88aff" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "libc", "libgit2-sys", "log", @@ -1315,7 +1315,7 @@ checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -1341,9 +1341,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" +checksum = "8c9c992b02b5b4c94ea26e32fe5bccb7aa7d9f390ab5c1221ff895bc7ea8b652" dependencies = [ "equivalent", "hashbrown", @@ -1352,9 +1352,9 @@ dependencies = [ [[package]] name = "indoc" -version = "2.0.5" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5" +checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" [[package]] name = "inferno" @@ -1380,7 +1380,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f37dccff2791ab604f9babef0ba14fbe0be30bd368dc541e2b08d07c8aa908f3" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "inotify-sys", "libc", ] @@ -1412,13 +1412,13 @@ checksum = "cf370abdafd54d13e54a620e8c3e1145f28e46cc9d704bc6d94414559df41763" [[package]] name = "is-terminal" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "261f68e344040fbd0edea105bef17c66edf46f984ddb1115b775ce31be948f4b" +checksum = "e19b23d53f35ce9f56aebc7d1bb4e6ac1e9c0db7ac85c8d1760c04379edced37" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1444,9 +1444,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.14" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" [[package]] name = "jni" @@ -1542,15 +1542,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.169" +version = "0.2.170" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" [[package]] name = "libgit2-sys" -version = "0.17.0+1.8.1" +version = "0.18.0+1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" +checksum = "e1a117465e7e1597e8febea8bb0c410f1c7fb93b1e1cddf34363f8390367ffec" dependencies = [ "cc", "libc", @@ -1584,7 +1584,7 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "libc", "redox_syscall", ] @@ -1602,9 +1602,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.20" +version = "1.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2d16453e800a8cf6dd2fc3eb4bc99b786a9b90c663b8559a5b1a041bf89e472" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" dependencies = [ "cc", "libc", @@ -1617,7 +1617,7 @@ name = "limbo" version = "0.0.16" dependencies = [ "limbo_core", - "thiserror 2.0.11", + "thiserror 2.0.12", "tokio", ] @@ -1634,7 +1634,7 @@ version = "0.0.16" dependencies = [ "jni", "limbo_core", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -1777,7 +1777,7 @@ version = "0.0.16" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -1841,7 +1841,7 @@ dependencies = [ name = "limbo_sqlite3_parser" version = "0.0.16" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cc", "env_logger 0.11.6", "fallible-iterator", @@ -1877,7 +1877,7 @@ dependencies = [ "mimalloc", "strum", "strum_macros", - "thiserror 2.0.11", + "thiserror 2.0.12", ] [[package]] @@ -1897,22 +1897,22 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linkme" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "566336154b9e58a4f055f6dd4cbab62c7dc0826ce3c0a04e63b2d2ecd784cdae" +checksum = "22d227772b5999ddc0690e733f734f95ca05387e329c4084fe65678c51198ffe" dependencies = [ "linkme-impl", ] [[package]] name = "linkme-impl" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edbe595006d355eaf9ae11db92707d4338cd2384d16866131cc1afdbdd35d8d9" +checksum = "71a98813fa0073a317ed6a8055dcd4722a49d9b862af828ee68449adb799b6be" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -1923,9 +1923,9 @@ checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" -version = "0.7.4" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" [[package]] name = "lock_api" @@ -1939,9 +1939,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.25" +version = "0.4.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" [[package]] name = "matchers" @@ -1984,9 +1984,9 @@ dependencies = [ [[package]] name = "miette" -version = "7.4.0" +version = "7.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317f146e2eb7021892722af37cf1b971f0a70c8406f487e24952667616192c64" +checksum = "1a955165f87b37fd1862df2a59547ac542c77ef6d17c666f619d1ad22dd89484" dependencies = [ "backtrace", "backtrace-ext", @@ -2004,13 +2004,13 @@ dependencies = [ [[package]] name = "miette-derive" -version = "7.4.0" +version = "7.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23c9b935fbe1d6cbd1dac857b54a688145e2d93f48db36010514d0f612d0ad67" +checksum = "bf45bf44ab49be92fd1227a3be6fc6f617f1a337c06af54981048574d8783147" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -2030,9 +2030,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.8.3" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" dependencies = [ "adler2", ] @@ -2075,7 +2075,7 @@ version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg-if", "libc", ] @@ -2086,7 +2086,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg-if", "cfg_aliases", "libc", @@ -2108,7 +2108,7 @@ version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fee8403b3d66ac7b26aee6e40a897d85dc5ce26f44da36b8b73e987cc52e943" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "filetime", "fsevent-sys", "inotify", @@ -2173,9 +2173,9 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.2" +version = "1.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" [[package]] name = "onig" @@ -2228,9 +2228,9 @@ checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" [[package]] name = "owo-colors" -version = "4.1.0" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37767f6569cd834a413442455e0f066d0d522de8630436e2a1761d9726ba56" +checksum = "1036865bb9422d3300cf723f657c2851d0e9ab12567854b1f4eba3d77decf564" [[package]] name = "parking_lot" @@ -2268,7 +2268,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" dependencies = [ "memchr", - "thiserror 2.0.11", + "thiserror 2.0.12", "ucd-trie", ] @@ -2292,7 +2292,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -2359,9 +2359,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.31" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" [[package]] name = "plist" @@ -2421,9 +2421,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" +checksum = "350e9b48cbc6b0e028b0473b114454c6316e57336ee184ceab6e53f72c178b3e" [[package]] name = "powerfmt" @@ -2492,9 +2492,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.93" +version = "1.0.94" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" dependencies = [ "unicode-ident", ] @@ -2558,7 +2558,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -2571,7 +2571,7 @@ dependencies = [ "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -2616,9 +2616,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.38" +version = "1.0.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +checksum = "c1f1914ce909e1658d9907913b4b91947430c7d9be598b15a1912935b8c04801" dependencies = [ "proc-macro2", ] @@ -2651,8 +2651,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", - "rand_core 0.9.0", - "zerocopy 0.8.14", + "rand_core 0.9.3", + "zerocopy 0.8.21", ] [[package]] @@ -2672,7 +2672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" dependencies = [ "ppv-lite86", - "rand_core 0.9.0", + "rand_core 0.9.3", ] [[package]] @@ -2686,12 +2686,11 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.9.0" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" dependencies = [ "getrandom 0.3.1", - "zerocopy 0.8.14", ] [[package]] @@ -2716,11 +2715,11 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.8" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" +checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -2808,15 +2807,14 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.8" +version = "0.17.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +checksum = "da5349ae27d3887ca812fb375b45a4fbb36d8d12d2df394968cd86e35683fe73" dependencies = [ "cc", "cfg-if", "getrandom 0.2.15", "libc", - "spin", "untrusted", "windows-sys 0.52.0", ] @@ -2846,7 +2844,7 @@ dependencies = [ "regex", "relative-path", "rustc_version", - "syn 2.0.96", + "syn 2.0.99", "unicode-ident", ] @@ -2856,7 +2854,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c6d5e5acb6f6129fe3f7ba0a7fc77bca1942cb568535e18e7bc40262baf3110" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "fallible-iterator", "fallible-streaming-iterator", "hashlink", @@ -2891,11 +2889,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.43" +version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "errno", "libc", "linux-raw-sys", @@ -2904,9 +2902,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c45b9784283f1b2e7fb61b42047c2fd678ef0960d4f6f1eba131594cc369d4" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" [[package]] name = "rustyline" @@ -2914,7 +2912,7 @@ version = "15.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2ee1e066dc922e513bda599c6ccb5f3bb2b0ea5870a579448f2622993f0a9a2f" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", "cfg-if", "clipboard-win", "fd-lock", @@ -2939,14 +2937,14 @@ checksum = "327e9d075f6df7e25fbf594f1be7ef55cf0d567a6cb5112eeccbbd51ceb48e0d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] name = "ryu" -version = "1.0.19" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ea1a2d0a644769cc99faa24c3ad26b379b786fe7c36fd3c546254801650e6dd" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" [[package]] name = "same-file" @@ -2965,35 +2963,35 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "semver" -version = "1.0.24" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3cb6eb87a131f756572d7fb904f6e7b68633f09cca868c5df1c4b8d1a694bbba" +checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" [[package]] name = "serde" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02fc4265df13d6fa1d00ecff087228cc0a2b5f3c0e87e258d8b94a156e984c70" +checksum = "e8dfc9d19bdbf6d17e22319da49161d5d0108e4188e8b680aef6299eed22df60" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.217" +version = "1.0.218" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" +checksum = "f09503e191f4e797cb8aac08e9a4a4695c5edf6a2e70e376d961ddd5c969f82b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] name = "serde_json" -version = "1.0.139" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44f86c3acccc9c65b153fe1b85a3be07fe5515274ec9f0653b4a0875731c72a6" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" dependencies = [ "indexmap", "itoa", @@ -3054,9 +3052,9 @@ dependencies = [ [[package]] name = "smallvec" -version = "1.13.2" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" [[package]] name = "socket2" @@ -3068,12 +3066,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" - [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -3111,7 +3103,7 @@ dependencies = [ "proc-macro2", "quote", "rustversion", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -3137,9 +3129,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "symbolic-common" -version = "12.13.2" +version = "12.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8150eae9699e3c73a3e6431dc1f80d87748797c0457336af23e94c1de619ed24" +checksum = "918a8461341098b48201d587de5e059f46a21e3bb871b4c6f2be4f95f01bbe69" dependencies = [ "debugid", "memmap2", @@ -3149,9 +3141,9 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "12.13.2" +version = "12.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95f4a9846f7a8933b6d198c022faa2c9bd89e1a970bed9d9a98d25708bf8de17" +checksum = "59a41a39f701a19a0f7db09520b2e15c70f59fd16abc1c4f3d34e265ffef9228" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -3171,9 +3163,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.96" +version = "2.0.99" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5d0adab1ae378d7f53bdebc67a39f1f151407ef230f0ce2883572f5d8985c80" +checksum = "e02e925281e18ffd9d640e234264753c43edc62d64b2d4cf898f1bc5e75f3fc2" dependencies = [ "proc-macro2", "quote", @@ -3188,7 +3180,7 @@ checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -3204,7 +3196,7 @@ dependencies = [ "once_cell", "onig", "plist", - "regex-syntax", + "regex-syntax 0.8.5", "serde", "serde_derive", "serde_json", @@ -3221,13 +3213,13 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.15.0" +version = "3.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "22e5a0acb1f3f55f65cc4a866c361b2fb2a0ff6366785ae6fbb5f85df07ba230" dependencies = [ "cfg-if", "fastrand", - "getrandom 0.2.15", + "getrandom 0.3.1", "once_cell", "rustix", "windows-sys 0.59.0", @@ -3277,17 +3269,17 @@ checksum = "888d0c3c6db53c0fdab160d2ed5e12ba745383d3e85813f2ea0f2b1475ab553f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] name = "textwrap" -version = "0.16.1" +version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" +checksum = "c13547615a44dc9c452a8a534638acdf07120d4b6847c8178705da06306a3057" dependencies = [ "unicode-linebreak", - "unicode-width 0.1.14", + "unicode-width 0.2.0", ] [[package]] @@ -3301,11 +3293,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d452f284b73e6d76dd36758a0c8684b1d5be31f92b89d07fd5822175732206fc" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" dependencies = [ - "thiserror-impl 2.0.11", + "thiserror-impl 2.0.12", ] [[package]] @@ -3316,18 +3308,18 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] name = "thiserror-impl" -version = "2.0.11" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26afc1baea8a989337eeb52b6e72a039780ce45c3edfcc9c5b9d112feeb173c2" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -3342,9 +3334,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.37" +version = "0.3.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "bb041120f25f8fbe8fd2dbe4671c7c2ed74d83be2e7a77529bf7e0790ae3f472" dependencies = [ "deranged", "itoa", @@ -3357,15 +3349,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "765c97a5b985b7c11d7bc27fa927dc4fe6af3a6dfb021d28deb60d3bf51e76ef" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "e8093bc3e81c3bc5f7879de09619d06c9a5a5e45ca44dfeeb7225bae38005c5c" dependencies = [ "num-conv", "time-core", @@ -3417,7 +3409,7 @@ checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -3439,7 +3431,7 @@ checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] @@ -3483,9 +3475,9 @@ dependencies = [ [[package]] name = "typenum" -version = "1.17.0" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "1dccffe3ce07af9386bfd29e80c0ab1a8205a2fc34e4bcd40364df902cfa8f3f" [[package]] name = "ucd-trie" @@ -3504,9 +3496,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.14" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" [[package]] name = "unicode-linebreak" @@ -3534,9 +3526,9 @@ checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" [[package]] name = "unindent" -version = "0.2.3" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce" +checksum = "7264e107f553ccae879d21fbea1d6724ac785e8c3bfc762137959b5802826ef3" [[package]] name = "untrusted" @@ -3581,11 +3573,11 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.12.0" +version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "744018581f9a3454a9e15beb8a33b017183f1e7c0cd170232a2d1453b23a51c4" +checksum = "e0f540e3240398cce6128b64ba83fdbdd86129c16a3aa1a3a252efd66eb3d587" dependencies = [ - "getrandom 0.2.15", + "getrandom 0.3.1", ] [[package]] @@ -3608,9 +3600,9 @@ checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "wait-timeout" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f200f5b12eb75f8c1ed65abd4b2db8a6e1b138a20de009dacee265a2498f3f6" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" dependencies = [ "libc", ] @@ -3662,7 +3654,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", "wasm-bindgen-shared", ] @@ -3697,7 +3689,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -3761,6 +3753,12 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-link" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dccfd733ce2b1753b03b6d3c65edf020262ea35e20ccdf3e288043e6dd620e3" + [[package]] name = "windows-sys" version = "0.45.0" @@ -3981,7 +3979,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" dependencies = [ - "bitflags 2.8.0", + "bitflags 2.9.0", ] [[package]] @@ -4025,7 +4023,7 @@ checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", "synstructure", ] @@ -4041,11 +4039,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.14" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a367f292d93d4eab890745e75a778da40909cab4d6ff8173693812f79c4a2468" +checksum = "dcf01143b2dd5d134f11f545cf9f1431b13b749695cb33bcce051e7568f99478" dependencies = [ - "zerocopy-derive 0.8.14", + "zerocopy-derive 0.8.21", ] [[package]] @@ -4056,38 +4054,38 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] name = "zerocopy-derive" -version = "0.8.14" +version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3931cb58c62c13adec22e38686b559c86a30565e16ad6e8510a337cedc611e1" +checksum = "712c8386f4f4299382c9abee219bee7084f78fb939d88b6840fcc1320d5f6da2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] [[package]] name = "zerofrom" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cff3ee08c995dee1859d998dea82f7374f2826091dd9cd47def953cae446cd2e" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" dependencies = [ "zerofrom-derive", ] [[package]] name = "zerofrom-derive" -version = "0.1.5" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595eed982f7d355beb85837f651fa22e90b3c044842dc7f2c2842c086f295808" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", "synstructure", ] @@ -4110,5 +4108,5 @@ checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" dependencies = [ "proc-macro2", "quote", - "syn 2.0.96", + "syn 2.0.99", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d7fa51c06..67c90b208 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -41,3 +41,7 @@ tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } [features] default = ["io_uring"] io_uring = ["limbo_core/io_uring"] + +[build-dependencies] +syntect = "5.2.0" + diff --git a/cli/SQL.sublime-syntax b/cli/SQL.sublime-syntax index d4c9b4d12..a47b41440 100644 --- a/cli/SQL.sublime-syntax +++ b/cli/SQL.sublime-syntax @@ -12,7 +12,7 @@ variables: toplevel_reserved: |- (?xi: alter | create | cross | delete | drop | from | grant | group | inner | insert | join - | left | on | order | outer | revoke | right | select | set | truncate | union + | left | on | order | outer | right | select | set | truncate | union | update | where ) additional_toplevel_reserved: (?!) diff --git a/cli/SQL_syntax_set_dump.packdump b/cli/SQL_syntax_set_dump.packdump deleted file mode 100644 index bc86ed0f15ad5782a9edca186a46cbe1c82352cb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8665 zcmZu$1z42Z)}}*30ZECWLAnt^qy$Onlwn{77=-~RXhcLBq!A>fJEU8>r6i>rX(W~W z2ale6&wtO%_sm{<@3r5(;$3T=c?J{XuNU_3QCD02w}f%yw}5a!!L13L z=zotOFc^x2I>117K%|4C9mEM@2ZTcq5V#WrjPqNEOO~0N=C^E#g4!XWFd)JTWCwx+ ztx+(m>*ENXzja-pQUEIy91ejYfn2gu05Av%0eAqAP(w9l2!z+yHK>{|AXe z-})awzJCB-1N{a?V<8|21p3lz$rXWw*aNtM*M|Yze>?_*(e8lYHV|anKVaP5|FZ*h zK-xm!o}M>60N3dM*!trZ(B1(IwT51+0n89Q0JP!%s`u|GP#75E@-Gm-*8lBVB*@YZ z@-GK|tpm6ze*5xYKKwECPdd3|ufy*Mcd&whQSj@y|Iq+&|IzuE)Bf+>|8!5_A1AHsQ0TdyY*x4Z=F39V2If9T-kR4h=!JsctXk3PW!$m;B z5FiMB2#(GoIwXHc`wyVi!IehmmKTZlafJx4&${==*wXv|+eqC;bKt%rm|ZESwQB3&J? z7k)9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i4g z#ecG9(AvqTCzXAh8j<&OKt0qo?13kxB&}K*gECvd4F)P-aDxD?h!4Ih)oY^rUYjJZ zZNBz(o_lurb02xmg#Z)GR73XXtJ%}>aw>_UJI>d-}>j(>Jb+w6}k(Xtt@uqJ(>U?TCk3iu{HLn(X z;t4>ai(NI{eP3%!9OUCddbgNu(+ORitJ=V=v;x#|t31RD3$(>?Hhq@KGeNFB8V%dN kc7U1+($k`N^Q4s$lDn@bw85>B&Zl0V#VO~1|JR1`e+EI2n*aa+ diff --git a/cli/app.rs b/cli/app.rs index 221311402..9caa3a6ad 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -235,7 +235,7 @@ impl<'a> Limbo<'a> { opts: Settings::from(&opts), rl, }; - + if opts.sql.is_some() { app.handle_first_input(opts.sql.as_ref().unwrap()); } diff --git a/cli/build.rs b/cli/build.rs new file mode 100644 index 000000000..515725fa5 --- /dev/null +++ b/cli/build.rs @@ -0,0 +1,26 @@ +//! Build.rs script to generate a binary syntax set for syntect +//! based on the SQL.sublime-syntax file. + +use std::env; +use std::path::Path; + +use syntect::dumps::dump_to_uncompressed_file; +use syntect::parsing::SyntaxDefinition; +use syntect::parsing::SyntaxSet; + +fn main() { + println!("cargo::rerun-if-changed=SQL.sublime-syntax"); + println!("cargo::rerun-if-changed=build.rs"); + + let out_dir = env::var_os("OUT_DIR").unwrap(); + let syntax = + SyntaxDefinition::load_from_str(include_str!("./SQL.sublime-syntax"), false, None).unwrap(); + let mut ps = SyntaxSet::new().into_builder(); + ps.add(syntax); + let ps = ps.build(); + dump_to_uncompressed_file( + &ps, + Path::new(&out_dir).join("SQL_syntax_set_dump.packdump"), + ) + .unwrap(); +} diff --git a/cli/helper.rs b/cli/helper.rs index cc0ca7f48..1cc629981 100644 --- a/cli/helper.rs +++ b/cli/helper.rs @@ -30,18 +30,12 @@ pub struct LimboHelper { impl LimboHelper { pub fn new(conn: Rc, io: Arc) -> Self { - // Code commented below is used to create a binary dump for the Sublime Syntax - - // let syntax = - // SyntaxDefinition::load_from_str(include_str!("./SQL.sublime-syntax"), false, None) - // .unwrap(); - // let mut ps = SyntaxSet::new().into_builder(); - // ps.add(syntax); - // let ps = ps.build(); - // dump_to_uncompressed_file(&ps, "./SQL_syntax_set_dump.packdump").unwrap(); - // Load only predefined syntax - let ps = from_uncompressed_data(include_bytes!("./SQL_syntax_set_dump.packdump")).unwrap(); + let ps = from_uncompressed_data(include_bytes!(concat!( + env!("OUT_DIR"), + "/SQL_syntax_set_dump.packdump" + ))) + .unwrap(); let ts = ThemeSet::load_defaults(); LimboHelper { completer: SqlCompleter::new(conn, io), From 74ddf40330b7c32ccab8737c82d8cdee8bc77a67 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Wed, 5 Mar 2025 15:10:30 -0300 Subject: [PATCH 04/10] add color to headers, see how to make it configurable --- cli/app.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cli/app.rs b/cli/app.rs index 9caa3a6ad..a6cd6d03e 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -728,7 +728,9 @@ impl<'a> Limbo<'a> { let header = (0..rows.num_columns()) .map(|i| { let name = rows.get_column_name(i); - Cell::new(name).add_attribute(Attribute::Bold) + Cell::new(name) + .add_attribute(Attribute::Bold) + .fg(comfy_table::Color::AnsiValue(49)) // Green color for headers }) .collect::>(); table.set_header(header); From e73cad387f2d9182e32f5cc5b632f257d20109ab Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Wed, 5 Mar 2025 17:03:03 -0300 Subject: [PATCH 05/10] adding table colors --- cli/Cargo.toml | 13 +++++++------ cli/app.rs | 25 ++++++++++++++++--------- cli/build.rs | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 67c90b208..99add273d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -20,23 +20,24 @@ path = "main.rs" [dependencies] anyhow = "1.0.75" -cfg-if = "1.0.0" clap = { version = "4.5", features = ["derive"] } comfy-table = "7.1.4" -csv = "1.3.1" -ctrlc = "3.4.4" dirs = "5.0.1" env_logger = "0.10.1" limbo_core = { path = "../core", default-features = true, features = [ "completion", ] } -miette = { version = "7.4.0", features = ["fancy"] } rustyline = { version = "15.0.0", default-features = true, features = [ "derive", ] } -syntect = "5.2.0" -tracing = "0.1.41" +ctrlc = "3.4.4" +csv = "1.3.1" +miette = { version = "7.4.0", features = ["fancy"] } +cfg-if = "1.0.0" tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } +tracing = "0.1.41" +syntect = "5.2.0" + [features] default = ["io_uring"] diff --git a/cli/app.rs b/cli/app.rs index a6cd6d03e..dc5df06c1 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -4,7 +4,7 @@ use crate::{ input::{get_io, get_writer, DbLocation, Io, OutputMode, Settings, HELP_MSG}, opcodes_dictionary::OPCODE_DESCRIPTIONS, }; -use comfy_table::{Attribute, Cell, CellAlignment, ContentArrangement, Row, Table}; +use comfy_table::{Attribute, Cell, CellAlignment, Color, ContentArrangement, Row, Table}; use limbo_core::{Database, LimboError, OwnedValue, Statement, StepResult}; use clap::{Parser, ValueEnum}; @@ -742,24 +742,31 @@ impl<'a> Limbo<'a> { let mut row = Row::new(); row.max_height(1); for value in record.get_values() { - let (content, alignment) = match value { - OwnedValue::Null => { - (self.opts.null_value.clone(), CellAlignment::Left) - } + let (content, alignment, color) = match value { + OwnedValue::Null => ( + self.opts.null_value.clone(), + CellAlignment::Left, + Color::White, + ), OwnedValue::Integer(i) => { - (i.to_string(), CellAlignment::Right) + (i.to_string(), CellAlignment::Right, Color::DarkRed) } OwnedValue::Float(f) => { - (f.to_string(), CellAlignment::Right) + (f.to_string(), CellAlignment::Right, Color::DarkRed) + } + OwnedValue::Text(s) => { + (s.to_string(), CellAlignment::Left, Color::DarkGreen) } - OwnedValue::Text(s) => (s.to_string(), CellAlignment::Left), OwnedValue::Blob(b) => ( String::from_utf8_lossy(b).to_string(), CellAlignment::Left, + Color::DarkGreen, ), _ => unreachable!(), }; - row.add_cell(Cell::new(content).set_alignment(alignment)); + row.add_cell( + Cell::new(content).set_alignment(alignment).fg(color), + ); } table.add_row(row); } diff --git a/cli/build.rs b/cli/build.rs index 515725fa5..a47762294 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -1,5 +1,5 @@ //! Build.rs script to generate a binary syntax set for syntect -//! based on the SQL.sublime-syntax file. +//! based on the SQL.sublime-syntax file. use std::env; use std::path::Path; From 942c65224d49657d8089c8995141fab9c1bec1c7 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Wed, 5 Mar 2025 18:29:27 -0300 Subject: [PATCH 06/10] changing table colors and adding history hinter --- cli/app.rs | 29 ++++++++++++++--------------- cli/helper.rs | 12 ++++++++---- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/cli/app.rs b/cli/app.rs index dc5df06c1..b6e2c8399 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -198,6 +198,8 @@ macro_rules! query_internal { }}; } +static COLORS: &[Color] = &[Color::DarkRed, Color::DarkGreen, Color::DarkBlue]; + impl<'a> Limbo<'a> { pub fn new(rl: &'a mut rustyline::Editor) -> anyhow::Result { let opts = Opts::parse(); @@ -730,7 +732,7 @@ impl<'a> Limbo<'a> { let name = rows.get_column_name(i); Cell::new(name) .add_attribute(Attribute::Bold) - .fg(comfy_table::Color::AnsiValue(49)) // Green color for headers + .fg(Color::AnsiValue(49)) // Green color for headers }) .collect::>(); table.set_header(header); @@ -741,31 +743,28 @@ impl<'a> Limbo<'a> { let record = rows.row().unwrap(); let mut row = Row::new(); row.max_height(1); - for value in record.get_values() { - let (content, alignment, color) = match value { - OwnedValue::Null => ( - self.opts.null_value.clone(), - CellAlignment::Left, - Color::White, - ), + for (idx, value) in record.get_values().iter().enumerate() { + let (content, alignment) = match value { + OwnedValue::Null => { + (self.opts.null_value.clone(), CellAlignment::Left) + } OwnedValue::Integer(i) => { - (i.to_string(), CellAlignment::Right, Color::DarkRed) + (i.to_string(), CellAlignment::Right) } OwnedValue::Float(f) => { - (f.to_string(), CellAlignment::Right, Color::DarkRed) - } - OwnedValue::Text(s) => { - (s.to_string(), CellAlignment::Left, Color::DarkGreen) + (f.to_string(), CellAlignment::Right) } + OwnedValue::Text(s) => (s.to_string(), CellAlignment::Left), OwnedValue::Blob(b) => ( String::from_utf8_lossy(b).to_string(), CellAlignment::Left, - Color::DarkGreen, ), _ => unreachable!(), }; row.add_cell( - Cell::new(content).set_alignment(alignment).fg(color), + Cell::new(content) + .set_alignment(alignment) + .fg(COLORS[idx & COLORS.len()]), ); } table.add_row(row); diff --git a/cli/helper.rs b/cli/helper.rs index 1cc629981..a6c0e98f0 100644 --- a/cli/helper.rs +++ b/cli/helper.rs @@ -4,6 +4,7 @@ use std::sync::Arc; use limbo_core::{Connection, StepResult}; use rustyline::completion::{extract_word, Completer, Pair}; use rustyline::highlight::Highlighter; +use rustyline::hint::HistoryHinter; use rustyline::{Completer, Helper, Hinter, Validator}; use syntect::dumps::from_uncompressed_data; use syntect::easy::HighlightLines; @@ -26,6 +27,8 @@ pub struct LimboHelper { completer: SqlCompleter, syntax_set: SyntaxSet, theme_set: ThemeSet, + #[rustyline(Hinter)] + hinter: HistoryHinter, } impl LimboHelper { @@ -41,6 +44,7 @@ impl LimboHelper { completer: SqlCompleter::new(conn, io), syntax_set: ps, theme_set: ts, + hinter: HistoryHinter::new(), } } } @@ -61,7 +65,7 @@ impl Highlighter for LimboHelper { ret_line.push_str(&escaped); } // Push this escape sequence to reset - // ret_line.push_str("\x1b[0m"); + ret_line.push_str("\x1b[0m"); std::borrow::Cow::Owned(ret_line) } @@ -76,7 +80,7 @@ impl Highlighter for LimboHelper { } fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> { - std::borrow::Cow::Borrowed(hint) + std::borrow::Cow::Owned(format!("\x1b[1;2;4;246m{hint}\x1b[0m")) } fn highlight_candidate<'c>( @@ -89,8 +93,8 @@ impl Highlighter for LimboHelper { } fn highlight_char(&self, line: &str, pos: usize, kind: rustyline::highlight::CmdKind) -> bool { - let _ = (line, pos, kind); - true + let _ = (line, pos); + !matches!(kind, rustyline::highlight::CmdKind::MoveCursor) } } From e77953ad7fd0ed0260c9070310c44a7448c37077 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Thu, 6 Mar 2025 13:57:05 -0300 Subject: [PATCH 07/10] color remainder fix --- cli/app.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/app.rs b/cli/app.rs index b6e2c8399..49f93ab53 100644 --- a/cli/app.rs +++ b/cli/app.rs @@ -764,7 +764,7 @@ impl<'a> Limbo<'a> { row.add_cell( Cell::new(content) .set_alignment(alignment) - .fg(COLORS[idx & COLORS.len()]), + .fg(COLORS[idx % COLORS.len()]), ); } table.add_row(row); From ffc2e12a8388de83c326e776fc705b0b25bdd8ab Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Thu, 6 Mar 2025 14:13:01 -0300 Subject: [PATCH 08/10] lock anarchist generator dependecy to 0.12 --- Cargo.lock | 38 +++++++++++++++++++------------------- simulator/Cargo.toml | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07a6d669f..922c2243c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -50,11 +50,11 @@ dependencies = [ [[package]] name = "anarchist-readable-name-generator-lib" -version = "0.1.4" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64ce9adb4750e64d18a46001b931cd3662957f7eefacae1b9cc3454fa00c2af1" +checksum = "18a1e15a87b13ae79e04e07b3714fc41d5f6993dff11662fdbe0b207c6ad0fe0" dependencies = [ - "rand 0.9.0", + "rand 0.8.5", ] [[package]] @@ -764,9 +764,9 @@ checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" [[package]] name = "either" -version = "1.14.0" +version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7914353092ddf589ad78f25c5c1c21b7f80b0ff8621e7c814c3485b5306da9d" +checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "endian-type" @@ -2652,7 +2652,7 @@ checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_chacha 0.9.0", "rand_core 0.9.3", - "zerocopy 0.8.21", + "zerocopy 0.8.22", ] [[package]] @@ -2807,9 +2807,9 @@ dependencies = [ [[package]] name = "ring" -version = "0.17.11" +version = "0.17.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da5349ae27d3887ca812fb375b45a4fbb36d8d12d2df394968cd86e35683fe73" +checksum = "ed9b823fa29b721a59671b41d6b06e66b29e0628e207e8b1c3ceeda701ec928d" dependencies = [ "cc", "cfg-if", @@ -3129,9 +3129,9 @@ checksum = "b7401a30af6cb5818bb64852270bb722533397edcfc7344954a38f420819ece2" [[package]] name = "symbolic-common" -version = "12.14.0" +version = "12.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "918a8461341098b48201d587de5e059f46a21e3bb871b4c6f2be4f95f01bbe69" +checksum = "66135c8273581acaab470356f808a1c74a707fe7ec24728af019d7247e089e71" dependencies = [ "debugid", "memmap2", @@ -3141,9 +3141,9 @@ dependencies = [ [[package]] name = "symbolic-demangle" -version = "12.14.0" +version = "12.14.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59a41a39f701a19a0f7db09520b2e15c70f59fd16abc1c4f3d34e265ffef9228" +checksum = "42bcacd080282a72e795864660b148392af7babd75691d5ae9a3b77e29c98c77" dependencies = [ "cpp_demangle", "rustc-demangle", @@ -3334,9 +3334,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.38" +version = "0.3.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb041120f25f8fbe8fd2dbe4671c7c2ed74d83be2e7a77529bf7e0790ae3f472" +checksum = "dad298b01a40a23aac4580b67e3dbedb7cc8402f3592d7f49469de2ea4aecdd8" dependencies = [ "deranged", "itoa", @@ -4039,11 +4039,11 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcf01143b2dd5d134f11f545cf9f1431b13b749695cb33bcce051e7568f99478" +checksum = "09612fda0b63f7cb9e0af7e5916fe5a1f8cdcb066829f10f36883207628a4872" dependencies = [ - "zerocopy-derive 0.8.21", + "zerocopy-derive 0.8.22", ] [[package]] @@ -4059,9 +4059,9 @@ dependencies = [ [[package]] name = "zerocopy-derive" -version = "0.8.21" +version = "0.8.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712c8386f4f4299382c9abee219bee7084f78fb939d88b6840fcc1320d5f6da2" +checksum = "79f81d38d7a2ed52d8f034e62c568e111df9bf8aba2f7cf19ddc5bf7bd89d520" dependencies = [ "proc-macro2", "quote", diff --git a/simulator/Cargo.toml b/simulator/Cargo.toml index fd61c5dbd..a99f5536d 100644 --- a/simulator/Cargo.toml +++ b/simulator/Cargo.toml @@ -23,7 +23,7 @@ tempfile = "3.0.7" env_logger = "0.10.1" regex = "1.11.1" regex-syntax = { version = "0.8.5", default-features = false, features = ["unicode"] } -anarchist-readable-name-generator-lib = "0.1.2" +anarchist-readable-name-generator-lib = "=0.1.2" clap = { version = "4.5", features = ["derive"] } serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0" } From 5168afa8b0ab93f7f97509c1f76a6a946e86d341 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Thu, 6 Mar 2025 16:33:23 -0300 Subject: [PATCH 09/10] highlight candidate --- cli/SQL.sublime-syntax | 99 +++++++++++++++++++++--------------------- cli/helper.rs | 4 +- 2 files changed, 51 insertions(+), 52 deletions(-) diff --git a/cli/SQL.sublime-syntax b/cli/SQL.sublime-syntax index a47b41440..511725452 100644 --- a/cli/SQL.sublime-syntax +++ b/cli/SQL.sublime-syntax @@ -15,7 +15,6 @@ variables: | left | on | order | outer | right | select | set | truncate | union | update | where ) additional_toplevel_reserved: (?!) - # TODO: not all are supported by all dialects! ddl_target: |- (?xi: {{ddl_target_other}} @@ -78,14 +77,14 @@ contexts: - include: revoke-statements - include: other-statements -###[ COMMENTS ]################################################################ + ###[ COMMENTS ]################################################################ comments: - include: double-dash-comments - include: block-comments double-dash-comments: - - match: '--' + - match: "--" scope: punctuation.definition.comment.sql push: inside-double-dash-comment @@ -120,7 +119,7 @@ contexts: scope: punctuation.definition.comment.end.sql pop: 1 -###[ DDL CREATE STATEMENTS ]################################################### + ###[ DDL CREATE STATEMENTS ]################################################### create-statements: - match: \b(?i:create)\b @@ -223,7 +222,7 @@ contexts: - include: expressions - include: pop-on-top-level-reserved-word -###[ DDL DROP STATEMENTS ]##################################################### + ###[ DDL DROP STATEMENTS ]##################################################### drop-statements: - match: \b(?i:drop)\b @@ -316,7 +315,7 @@ contexts: drop-other-args: - include: maybe-on-table-name -###[ DDL ALTER STATEMENTS ]#################################################### + ###[ DDL ALTER STATEMENTS ]#################################################### alter-statements: - match: \b(?i:alter)\b @@ -337,7 +336,7 @@ contexts: - include: alter-other - include: else-pop -###[ DDL ALTER FUNCTION STATEMENTS ]########################################### + ###[ DDL ALTER FUNCTION STATEMENTS ]########################################### alter-function: - match: \b(?:({{ddl_target_function_modifier}})\s+)?({{ddl_target_function}})\b @@ -354,7 +353,7 @@ contexts: - meta_include_prototype: false - include: maybe-condition -###[ DDL ALTER INDEX STATEMENTS ]############################################## + ###[ DDL ALTER INDEX STATEMENTS ]############################################## alter-index: - match: \b(?i:(?:({{ddl_target_index_modifier}})\s+)?(index))\b @@ -375,7 +374,7 @@ contexts: - include: pop-on-top-level-reserved-word - include: expressions-or-column-names -###[ DDL ALTER TABLE STATEMENTS ]############################################## + ###[ DDL ALTER TABLE STATEMENTS ]############################################## alter-table: - match: \b(?i:(?:({{ddl_target_table_modifier}})\s+)?(table))\b @@ -444,7 +443,7 @@ contexts: 2: keyword.other.ddl.sql 3: keyword.other.ddl.sql -###[ DDL STATEMENT PROTOTYPES ]################################################ + ###[ DDL STATEMENT PROTOTYPES ]################################################ maybe-on-table-name: - include: on-table-names @@ -455,7 +454,7 @@ contexts: scope: keyword.other.sql push: expect-table-name -###[ DML STATEMENTS ]########################################################## + ###[ DML STATEMENTS ]########################################################## dml-statements: - match: \b(?i:select)\b @@ -516,7 +515,7 @@ contexts: - include: expressions - include: expect-column-names -###[ DML SET STATEMENTS ]###################################################### + ###[ DML SET STATEMENTS ]###################################################### set-statements: - match: \b(?i:set)\b(?!\s*\() @@ -533,7 +532,7 @@ contexts: set-target: - include: else-pop -###[ GRANT STATEMENTS ]######################################################## + ###[ GRANT STATEMENTS ]######################################################## grant-statements: - match: \b(?i:grant(?:\s+with\s+grant\s+option)?)\b @@ -547,7 +546,7 @@ contexts: - meta_scope: meta.statement.grant.sql - include: immediately-pop -###[ REVOKE STATEMENTS ]####################################################### + ###[ REVOKE STATEMENTS ]####################################################### revoke-statements: - match: \b(?i:revoke)\b @@ -561,11 +560,11 @@ contexts: - meta_scope: meta.statement.revoke.sql - include: immediately-pop -###[ OTHER STATEMENTS ]######################################################## + ###[ OTHER STATEMENTS ]######################################################## other-statements: [] -###[ EXPRESSIONS ]############################################################# + ###[ EXPRESSIONS ]############################################################# expressions-or-column-names: - include: wildcard-identifiers @@ -625,7 +624,7 @@ contexts: push: inside-collate-expression inside-collate-expression: - - match: '{{simple_identifier}}' + - match: "{{simple_identifier}}" scope: support.constant.sql pop: 1 - include: else-pop @@ -653,7 +652,7 @@ contexts: pop: 1 - include: else-pop -###[ FUNCTION EXPRESSIONS ]#################################################### + ###[ FUNCTION EXPRESSIONS ]#################################################### function-calls: - include: built-in-aggregate-function-calls @@ -701,12 +700,12 @@ contexts: - match: \) scope: meta.function-call.sql meta.group.sql punctuation.section.arguments.end.sql pop: 1 - - match: ',' + - match: "," scope: punctuation.separator.arguments.sql - include: distinct - include: expressions-or-column-names -###[ GROUPS EXPRESSIONS ]###################################################### + ###[ GROUPS EXPRESSIONS ]###################################################### maybe-group: - include: group @@ -729,7 +728,7 @@ contexts: pop: 1 - include: sql -###[ COLUMN EXPRESSIONS ]###################################################### + ###[ COLUMN EXPRESSIONS ]###################################################### expect-column-declaration: - include: column-declaration-list @@ -818,7 +817,7 @@ contexts: pop: 1 - include: expressions-or-column-names -###[ FUNCTION EXPRESSIONS ]#################################################### + ###[ FUNCTION EXPRESSIONS ]#################################################### expect-function-parameters: - match: \( @@ -840,7 +839,7 @@ contexts: - maybe-parameter-modifier expect-parameter-name: - - match: '{{simple_identifier}}' + - match: "{{simple_identifier}}" scope: variable.parameter.sql pop: 1 - include: else-pop @@ -865,12 +864,12 @@ contexts: - include: create-common-args expect-function-language-name: - - match: '{{simple_identifier}}' + - match: "{{simple_identifier}}" scope: constant.other.language.sql pop: 1 - include: else-pop -###[ USER MANAGEMENT EXPRESSIONS ]############################################# + ###[ USER MANAGEMENT EXPRESSIONS ]############################################# grant: - match: \b(?i:to)\b @@ -889,7 +888,7 @@ contexts: - match: \b(?i:select|insert|update|delete|truncate|execute)\b scope: constant.language.sql -###[ TABLE NAMES OR SUBQUERIES ]############################################### + ###[ TABLE NAMES OR SUBQUERIES ]############################################### table-name-or-subquery: - meta_include_prototype: false @@ -912,7 +911,7 @@ contexts: table-name-not-function-call: - meta_include_prototype: false - - match: '' + - match: "" set: - maybe-table-alias - table-name-fail-if-function-call @@ -928,7 +927,7 @@ contexts: table-valued-function-call: - meta_include_prototype: false - - match: '' + - match: "" set: - maybe-table-alias - function-call-arguments @@ -972,7 +971,7 @@ contexts: - include: expressions - include: immediately-pop -###[ TYPES ]################################################################### + ###[ TYPES ]################################################################### expect-type: - meta_include_prototype: false @@ -1029,7 +1028,7 @@ contexts: inside-user-type: # note: may contain foreign variable interpolation - meta_scope: support.type.sql - - match: '{{simple_identifier_break}}' + - match: "{{simple_identifier_break}}" pop: 1 after-type: @@ -1039,7 +1038,7 @@ contexts: - include: assignment-operators - include: else-pop -###[ IDENTIFIERS ]############################################################# + ###[ IDENTIFIERS ]############################################################# expect-table-alias-name: # prevent prototypes from inheriting syntaxes @@ -1327,7 +1326,7 @@ contexts: single-identifier: - meta_include_prototype: false - include: pop-on-top-level-reserved-word - - match: '' + - match: "" set: - maybe-identifier-accessor - identifier-part @@ -1391,14 +1390,14 @@ contexts: inside-simple-identifier-part: # note: may contain foreign variable interpolation - - match: '{{simple_identifier_break}}' + - match: "{{simple_identifier_break}}" pop: 1 wildcard-identifiers: - match: \* scope: constant.other.wildcard.asterisk.sql -###[ LITERALS ]################################################################ + ###[ LITERALS ]################################################################ literals-and-variables: - include: built-in-types @@ -1440,10 +1439,10 @@ contexts: - include: string-escapes string-escapes: - - match: '{{string_escape}}' + - match: "{{string_escape}}" scope: constant.character.escape.sql -###[ LIKE EXPRESSIONS ]######################################################## + ###[ LIKE EXPRESSIONS ]######################################################## like-expressions: - match: \b(?i:like)\b @@ -1522,7 +1521,7 @@ contexts: inside-like-single-quoted-string-hash-escape: - meta_include_prototype: false - meta_scope: meta.string.like.sql string.quoted.single.sql - - match: '#.' + - match: "#." scope: constant.character.escape.sql - include: inside-like-single-quoted-string @@ -1532,9 +1531,9 @@ contexts: - match: \' scope: punctuation.definition.string.end.sql pop: 1 - - match: '%' + - match: "%" scope: constant.other.wildcard.percent.sql - - match: '_' + - match: "_" scope: constant.other.wildcard.underscore.sql like-else-fail: @@ -1596,7 +1595,7 @@ contexts: pop: 1 - include: like-else-fail -###[ OPERATORS ]############################################################### + ###[ OPERATORS ]############################################################### maybe-condition: - meta_include_prototype: false @@ -1610,10 +1609,10 @@ contexts: maybe-operator: - meta_include_prototype: false - - match: '<=>|[!<>]?=|<>|<|>' + - match: "<=>|[!<>]?=|<>|<|>" scope: keyword.operator.comparison.sql pop: 1 - - match: '[-+/*]' + - match: "[-+/*]" scope: keyword.operator.arithmetic.sql pop: 1 - match: \b(?i:and|or|having|exists|between|in|not|is)\b @@ -1623,14 +1622,14 @@ contexts: - include: else-pop operators: - - match: '<=>|[!<>]?=|<>|<|>' + - match: "<=>|[!<>]?=|<>|<|>" scope: keyword.operator.comparison.sql - - match: '[-+/*]' + - match: "[-+/*]" scope: keyword.operator.arithmetic.sql - include: logical-operators assignment-operators: - - match: '=' + - match: "=" scope: keyword.operator.assignment.sql logical-operators: @@ -1638,14 +1637,14 @@ contexts: scope: keyword.operator.logical.sql comma-separators: - - match: ',' + - match: "," scope: punctuation.separator.sequence.sql statement-terminators: - - match: ';' + - match: ";" scope: punctuation.terminator.statement.sql -###[ ILLEGALS ]################################################################ + ###[ ILLEGALS ]################################################################ illegal-stray-brackets: - match: \] @@ -1655,14 +1654,14 @@ contexts: - match: \) scope: invalid.illegal.stray.sql -###[ PROTOTYPES ]############################################################## + ###[ PROTOTYPES ]############################################################## else-pop: - match: (?=\S) pop: 1 immediately-pop: - - match: '' + - match: "" pop: 1 pop-on-top-level-reserved-word: diff --git a/cli/helper.rs b/cli/helper.rs index a6c0e98f0..28edf4474 100644 --- a/cli/helper.rs +++ b/cli/helper.rs @@ -80,7 +80,7 @@ impl Highlighter for LimboHelper { } fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> { - std::borrow::Cow::Owned(format!("\x1b[1;2;4;246m{hint}\x1b[0m")) + std::borrow::Cow::Owned(format!("\x1b[1;2;4;38;5;246m{hint}\x1b[0m")) // Bold dim grey underline } fn highlight_candidate<'c>( @@ -89,7 +89,7 @@ impl Highlighter for LimboHelper { completion: rustyline::CompletionType, ) -> std::borrow::Cow<'c, str> { let _ = completion; - std::borrow::Cow::Borrowed(candidate) + std::borrow::Cow::Owned(format!("\x1b[38;5;69m{candidate}\x1b[0m")) } fn highlight_char(&self, line: &str, pos: usize, kind: rustyline::highlight::CmdKind) -> bool { From 8c5b631bafc86d9842f18eee0ef202c0ec3de444 Mon Sep 17 00:00:00 2001 From: pedrocarlo Date: Thu, 6 Mar 2025 21:44:23 -0300 Subject: [PATCH 10/10] nu_ansi_term to facilitate stylizing strings --- Cargo.lock | 12 +++++++++++- cli/Cargo.toml | 1 + cli/helper.rs | 37 ++++++++++++++++++++++++++----------- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 922c2243c..588cc563e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1664,6 +1664,7 @@ dependencies = [ "env_logger 0.10.2", "limbo_core", "miette", + "nu-ansi-term 0.50.1", "rustyline", "syntect", "tracing", @@ -2137,6 +2138,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "nu-ansi-term" +version = "0.50.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a28e057d01f97e61255210fcff094d74ed0466038633e95017f5beb68e4399" +dependencies = [ + "windows-sys 0.52.0", +] + [[package]] name = "num-conv" version = "0.1.0" @@ -3462,7 +3472,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ "matchers", - "nu-ansi-term", + "nu-ansi-term 0.46.0", "once_cell", "regex", "sharded-slab", diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 99add273d..9ad47aa79 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -37,6 +37,7 @@ cfg-if = "1.0.0" tracing-subscriber = { version = "0.3.19", features = ["env-filter"] } tracing = "0.1.41" syntect = "5.2.0" +nu-ansi-term = "0.50.1" [features] diff --git a/cli/helper.rs b/cli/helper.rs index 28edf4474..37cd462b8 100644 --- a/cli/helper.rs +++ b/cli/helper.rs @@ -2,13 +2,14 @@ use std::rc::Rc; use std::sync::Arc; use limbo_core::{Connection, StepResult}; +use nu_ansi_term::{Color, Style}; use rustyline::completion::{extract_word, Completer, Pair}; use rustyline::highlight::Highlighter; use rustyline::hint::HistoryHinter; use rustyline::{Completer, Helper, Hinter, Validator}; use syntect::dumps::from_uncompressed_data; use syntect::easy::HighlightLines; -use syntect::highlighting::{Style, ThemeSet}; +use syntect::highlighting::ThemeSet; use syntect::parsing::{Scope, SyntaxSet}; use syntect::util::{as_24_bit_terminal_escaped, LinesWithEndings}; @@ -58,13 +59,17 @@ impl Highlighter for LimboHelper { .find_syntax_by_scope(Scope::new("source.sql").unwrap()) .unwrap(); let mut h = HighlightLines::new(syntax, &self.theme_set.themes["base16-ocean.dark"]); - let mut ret_line = String::new(); - for new_line in LinesWithEndings::from(line) { - let ranges: Vec<(Style, &str)> = h.highlight_line(new_line, &self.syntax_set).unwrap(); - let escaped = as_24_bit_terminal_escaped(&ranges[..], false); - ret_line.push_str(&escaped); - } - // Push this escape sequence to reset + let ranges = { + let mut ret_ranges = Vec::new(); + for new_line in LinesWithEndings::from(line) { + let ranges: Vec<(syntect::highlighting::Style, &str)> = + h.highlight_line(new_line, &self.syntax_set).unwrap(); + ret_ranges.extend(ranges); + } + ret_ranges + }; + let mut ret_line = as_24_bit_terminal_escaped(&ranges[..], false); + // Push this escape sequence to reset color modes at the end of the string ret_line.push_str("\x1b[0m"); std::borrow::Cow::Owned(ret_line) } @@ -76,11 +81,19 @@ impl Highlighter for LimboHelper { ) -> std::borrow::Cow<'b, str> { let _ = default; // Make prompt bold - std::borrow::Cow::Owned(format!("\x1b[1;32m{}\x1b[0m", prompt)) + let style = Style::new().bold().fg(Color::Green); + let styled_str = style.paint(prompt); + std::borrow::Cow::Owned(styled_str.to_string()) } fn highlight_hint<'h>(&self, hint: &'h str) -> std::borrow::Cow<'h, str> { - std::borrow::Cow::Owned(format!("\x1b[1;2;4;38;5;246m{hint}\x1b[0m")) // Bold dim grey underline + let style = Style::new() + .bold() + .dimmed() + .underline() + .fg(Color::Fixed(246)); + let styled_str = style.paint(hint); + std::borrow::Cow::Owned(styled_str.to_string()) // Bold dim grey underline } fn highlight_candidate<'c>( @@ -89,7 +102,9 @@ impl Highlighter for LimboHelper { completion: rustyline::CompletionType, ) -> std::borrow::Cow<'c, str> { let _ = completion; - std::borrow::Cow::Owned(format!("\x1b[38;5;69m{candidate}\x1b[0m")) + let style = Style::new().fg(Color::Fixed(69)); + let styled_str = style.paint(candidate); + std::borrow::Cow::Owned(styled_str.to_string()) } fn highlight_char(&self, line: &str, pos: usize, kind: rustyline::highlight::CmdKind) -> bool {