From 5881b694c279213e01df5f4896fe604267dad9b9 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sat, 19 Mar 2022 23:57:38 +0100 Subject: [PATCH 1/6] Inital basic Org markup support thanks to tree-sitter-org --- languages.toml | 12 ++++++++++++ runtime/queries/org/highlights.scm | 19 +++++++++++++++++++ runtime/queries/org/injections.scm | 3 +++ 3 files changed, 34 insertions(+) create mode 100644 runtime/queries/org/highlights.scm create mode 100644 runtime/queries/org/injections.scm diff --git a/languages.toml b/languages.toml index 6aa5be3c5fe2..5aa1b2c8a6a6 100644 --- a/languages.toml +++ b/languages.toml @@ -976,3 +976,15 @@ auto-format = true [[grammar]] name = "hcl" source = { git = "https://github.com/MichaHoffmann/tree-sitter-hcl", rev = "3cb7fc28247efbcb2973b97e71c78838ad98a583" } + +[[language]] +name = "org" +scope = "source.org" +injection-regex = "org" +file-types = ["org"] +roots = [] +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "org" +source = { git = "https://github.com/milisims/tree-sitter-org", rev = "1c3eb533a9cf6800067357b59e03ac3f91fc3a54" } diff --git a/runtime/queries/org/highlights.scm b/runtime/queries/org/highlights.scm new file mode 100644 index 000000000000..4b94a3b84e7d --- /dev/null +++ b/runtime/queries/org/highlights.scm @@ -0,0 +1,19 @@ +(headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "*")) @markup.heading.1 +(headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "**")) @markup.heading.2 +(headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "***")) @markup.heading.3 +(headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "****")) @markup.heading.4 +(headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "*****")) @markup.heading.5 +(headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "******")) @markup.heading.6 + + (block) @markup.raw.block + (list) @markup.list.unnumbered + (property_drawer) @label + + ((expr) @markup.bold + (#match? @markup.bold "\\*.*\\*")) + + ((expr) @markup.italic + (#match? @markup.italic "/.*/")) + + ((expr) @markup.raw.inline + (#match? @markup.raw.inline "~.*~")) \ No newline at end of file diff --git a/runtime/queries/org/injections.scm b/runtime/queries/org/injections.scm new file mode 100644 index 000000000000..40e9c04104d9 --- /dev/null +++ b/runtime/queries/org/injections.scm @@ -0,0 +1,3 @@ +(block parameter: (expr) @injection.language + (contents) @injection.content + (#set! injection.include-children)) \ No newline at end of file From 7fbacc04db66682853ace8027ada4b425166fd41 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 20 Mar 2022 00:20:12 +0100 Subject: [PATCH 2/6] Add verbatim query --- runtime/queries/org/highlights.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/queries/org/highlights.scm b/runtime/queries/org/highlights.scm index 4b94a3b84e7d..022d4f4cc1ba 100644 --- a/runtime/queries/org/highlights.scm +++ b/runtime/queries/org/highlights.scm @@ -16,4 +16,7 @@ (#match? @markup.italic "/.*/")) ((expr) @markup.raw.inline - (#match? @markup.raw.inline "~.*~")) \ No newline at end of file + (#match? @markup.raw.inline "~.*~")) + + ((expr) @markup.quote + (#match? @markup.quote "=.*=")) \ No newline at end of file From 0fe965445323002bae4ba5c6a4b5a4a843761e3e Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 20 Mar 2022 12:56:04 +0100 Subject: [PATCH 3/6] Add doc generated by cargo xtask docgen --- book/src/generated/lang-support.md | 1 + 1 file changed, 1 insertion(+) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 70edafb9c1dc..a3fbe8a39387 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -42,6 +42,7 @@ | nix | ✓ | | ✓ | `rnix-lsp` | | ocaml | ✓ | | ✓ | | | ocaml-interface | ✓ | | | | +| org | ✓ | | | | | perl | ✓ | ✓ | ✓ | | | php | ✓ | ✓ | ✓ | | | prolog | | | | `swipl` | From 6c07c04c95dfde78624ca3b5966094a52b40f302 Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 20 Mar 2022 15:44:54 +0100 Subject: [PATCH 4/6] Add query for properties drawer --- runtime/queries/org/highlights.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/runtime/queries/org/highlights.scm b/runtime/queries/org/highlights.scm index 022d4f4cc1ba..a3329e381396 100644 --- a/runtime/queries/org/highlights.scm +++ b/runtime/queries/org/highlights.scm @@ -7,7 +7,9 @@ (block) @markup.raw.block (list) @markup.list.unnumbered - (property_drawer) @label + (directive) @markup.label + (property_drawer) @markup.label + ((expr) @markup.bold (#match? @markup.bold "\\*.*\\*")) From a5b00e53ada410c2eb45ddb6b7e001f5fc1c1e7a Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 20 Mar 2022 18:26:28 +0100 Subject: [PATCH 5/6] Fix formatting --- runtime/queries/org/highlights.scm | 27 +++++++++++++-------------- runtime/queries/org/injections.scm | 3 ++- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/runtime/queries/org/highlights.scm b/runtime/queries/org/highlights.scm index a3329e381396..04b0df85624f 100644 --- a/runtime/queries/org/highlights.scm +++ b/runtime/queries/org/highlights.scm @@ -5,20 +5,19 @@ (headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "*****")) @markup.heading.5 (headline (stars) @markup.heading.marker (#eq? @markup.heading.marker "******")) @markup.heading.6 - (block) @markup.raw.block - (list) @markup.list.unnumbered - (directive) @markup.label - (property_drawer) @markup.label +(block) @markup.raw.block +(list) @markup.list.unnumbered +(directive) @markup.label +(property_drawer) @markup.label - ((expr) @markup.bold - (#match? @markup.bold "\\*.*\\*")) - - ((expr) @markup.italic - (#match? @markup.italic "/.*/")) +((expr) @markup.bold + (#match? @markup.bold "\\*.*\\*")) - ((expr) @markup.raw.inline - (#match? @markup.raw.inline "~.*~")) - - ((expr) @markup.quote - (#match? @markup.quote "=.*=")) \ No newline at end of file +((expr) @markup.italic + (#match? @markup.italic "/.*/")) +((expr) @markup.raw.inline + (#match? @markup.raw.inline "~.*~")) + +((expr) @markup.quote + (#match? @markup.quote "=.*=")) diff --git a/runtime/queries/org/injections.scm b/runtime/queries/org/injections.scm index 40e9c04104d9..76ec86af4487 100644 --- a/runtime/queries/org/injections.scm +++ b/runtime/queries/org/injections.scm @@ -1,3 +1,4 @@ (block parameter: (expr) @injection.language (contents) @injection.content - (#set! injection.include-children)) \ No newline at end of file + (#set! injection.include-children)) + \ No newline at end of file From 8085a2e338808a57c464cde370e3f36edc6331ae Mon Sep 17 00:00:00 2001 From: zetashift Date: Sun, 20 Mar 2022 18:30:12 +0100 Subject: [PATCH 6/6] Fix formatting attempt #2 --- runtime/queries/org/highlights.scm | 1 + runtime/queries/org/injections.scm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/queries/org/highlights.scm b/runtime/queries/org/highlights.scm index 04b0df85624f..db8329fa60a2 100644 --- a/runtime/queries/org/highlights.scm +++ b/runtime/queries/org/highlights.scm @@ -21,3 +21,4 @@ ((expr) @markup.quote (#match? @markup.quote "=.*=")) + diff --git a/runtime/queries/org/injections.scm b/runtime/queries/org/injections.scm index 76ec86af4487..24d712d6f513 100644 --- a/runtime/queries/org/injections.scm +++ b/runtime/queries/org/injections.scm @@ -1,4 +1,4 @@ (block parameter: (expr) @injection.language (contents) @injection.content (#set! injection.include-children)) - \ No newline at end of file +