Skip to content

Instantly share code, notes, and snippets.

@CosmicToast
Created August 13, 2020 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CosmicToast/d8bdd20d538569a4c2c546133b789c04 to your computer and use it in GitHub Desktop.
Save CosmicToast/d8bdd20d538569a4c2c546133b789c04 to your computer and use it in GitHub Desktop.
Toast's Syntax Files
Toast's Syntax Files
Arbitrary syntax implementations for things I thought were missing.
The format is $PROG.$NAME.$EXT
For example, gedit.gemini.lang or micro.gemini.yaml.
All of these are written by me and available under the CC0.
Instructions based on prog (remove the $PROG. prefix first):
gedit: put in ~/.local/share/gtksourceview-4/language-specs/
micro: put in ~/.config/micro/syntax/
<?xml version="1.0" encoding="UTF-8"?>
<!-- v0.14.2 -->
<language id="gemini" name="Gemini" version="2.0" _section="Markup">
<metadata>
<property name="mimetypes">text/gemini</property>
<property name="globs">*.gmi</property>
</metadata>
<styles>
<style id="link-marker" name="Link Marker" map-to="def:link-symbol" />
<style id="link" name="Link" map-to="def:link-destination" />
<style id="link-title" name="Link Title" map-to="def:link-text" />
<style id="pre" name="Preformatted" map-to="def:preformatted-section" />
<style id="pre-alt" name="Preformatted Alt Text" map-to="def:emphasis" />
<style id="header" name="Header" map-to="def:heading" />
<style id="list" name="Unordered List" map-to="def:list-marker" />
<style id="blockquote" name="Blockquote" map-to="def:insertion" />
</styles>
<definitions>
<!-- Examples:
=> url Link
=> url
=>url Link
=>url
-->
<context id="link">
<match extended="true">
^
(=>) # identifier
[ ]? # optional whitespace
(\w+) # the link
( .*) # the title
$
</match>
<include>
<context sub-pattern="1" style-ref="link-marker" />
<context sub-pattern="2" class="no-spell-check" style-ref="link" />
<context sub-pattern="3" style-ref="link-title" />
</include>
</context>
<!-- Starts with ``` and ends with ``` -->
<context id="pre" class="no-spell-check" style-ref="pre">
<start>^```(.*)$</start>
<end>^```</end> <!-- technically it's not valid to have anything after this, but the failure conditional is undesirable -->
<include>
<context sub-pattern="1" where="start" style-ref="pre-alt" />
</include>
</context>
<!-- Examples:
# Header 1
## Header 2
###Header 3
-->
<context id="header" style-ref="header">
<match>^#{1,3}.+$</match>
</context>
<!-- Examples:
* list1
* list2
-->
<context id="list" style-ref="list">
<match>^\* </match>
</context>
<!-- Examples:
> line1
> an entirely unrelated line
-->
<context id="blockquote" style-ref="blockquote">
<match>^>.+$</match>
</context>
<context id="gemini">
<include>
<context ref="link" />
<context ref="pre" />
<context ref="header" />
<context ref="list" />
<context ref="blockquote" />
</include>
</context>
</definitions>
</language>
filetype: gemini
detect:
filename: "(\\.gmi$|\\.gemini$)"
rules:
# links
- constant: "^=>"
# preformatted toggles/lines
- special:
start: "^```"
end: "^```"
rules: []
# headings
- special: "^#{1,3}.*$"
# unordered lists
- identifier: "^\\* "
# quotes
- statement: "^>.*$"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment