Giter VIP home page Giter VIP logo

tree-sitter-vimdoc's Introduction

tree-sitter-vimdoc

This grammar implements the vimdoc "spec" (ref1, ref2). Predictable results are the primary goal, so that output formats (e.g. HTML) are well-formed; the input (vimdoc) is secondary. The first step should always be to try to fix the input rather than insist on a grammar that handles vimdoc's endless quirks.

Overview

  • block is the main top-level node, delimited by blank line(s) or any line starting with < (codeblock terminator).
    • contains line and line_li nodes.
  • line:
    • contains atoms (words, tags, taglinks, โ€ฆ)
    • contains headings (h1, h2, h3, column_heading) because codeblock terminated by "implicit stop" (no terminating <) consumes blank lines, so block has no way to end.
  • line_li ("list item")
    • consumes lines until blank line, codeblock, or next listitem.
    • nesting is ignored: indented listitems are parsed as siblings.
  • codeblock:
    • contained by line or line_li, because ">" can start a codeblock at the end of any line.
    • contains line nodes without word nodes: it's just the full raw text line including whitespace. This is somewhat dictated by its "preformatted" nature; parsing the contents would require loading a "child" language (injection). See #2.
    • the terminating < (and any following whitespace) is discarded (anonymous).
  • h1 = "Heading 1": ====== followed by text and optional *tags*.
  • h2 = "Heading 2": ------ followed by text and optional *tags*.
  • h3 = "Heading 3": UPPERCASE WORDS, followed by optional *tags*, followed by atoms.

Known issues

  • Input must end with newline/EOL (\n). Grammar does not support files without EOL.
  • Input must end with a blank line. Though this doesn't seem to matter in practice.
  • Spec requires that codeblock delimiter ">" must be preceded by a space (" >"), not a tab. But currently the grammar doesn't enforce this. Example: :help lcs-tab.
  • url doesn't handle surrounding parens. E.g. (https://example.com/#yay) yields word
  • url doesn't handle nested parens. E.g. (https://example.com/(foo)#yay)
  • column_heading currently only recognizes tilde ~ preceded by space (i.e. foo ~ not foo~). This covers 99% of :help files.
  • column_heading children should be plaintext. Currently its children are parsed as $._atom.

TODO

  • line_modeline ?
  • tag_heading : line(s) containing only tags, typically implies a "heading" before a block.

Release

Steps to perform a release:

  1. Bump and tag the version (choose patch/minor/major as appropriate).
    npm version patch -m "release %s"
    
  2. Bump to prerelease, without creating a tag .
    npm version --no-git-tag-version prerelease --preid dev && git add package*.json && git commit -m bump
    
  3. Push.
    git push --follow-tags
    
  4. Release the tagged commit: https://github.com/neovim/tree-sitter-vimdoc/releases/new

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.